MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / TelegramLogin

Function TelegramLogin

controller/telegram.go:71–98  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

69}
70
71func TelegramLogin(c *gin.Context) {
72 if !common.TelegramOAuthEnabled {
73 c.JSON(200, gin.H{
74 "message": "管理员未开启通过 Telegram 登录以及注册",
75 "success": false,
76 })
77 return
78 }
79 params := c.Request.URL.Query()
80 if !checkTelegramAuthorization(params, common.TelegramBotToken) {
81 c.JSON(200, gin.H{
82 "message": "无效的请求",
83 "success": false,
84 })
85 return
86 }
87
88 telegramId := params["id"][0]
89 user := model.User{TelegramId: telegramId}
90 if err := user.FillUserByTelegramId(); err != nil {
91 c.JSON(200, gin.H{
92 "message": err.Error(),
93 "success": false,
94 })
95 return
96 }
97 setupLogin(&user, c)
98}
99
100func checkTelegramAuthorization(params map[string][]string, token string) bool {
101 strs := []string{}

Callers

nothing calls this directly

Calls 4

FillUserByTelegramIdMethod · 0.95
setupLoginFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected