MCPcopy Index your code
hub / github.com/aiprodcoder/MIXAPI / EmailBind

Function EmailBind

controller/user.go:782–814  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

780}
781
782func EmailBind(c *gin.Context) {
783 email := c.Query("email")
784 code := c.Query("code")
785 if !common.VerifyCodeWithKey(email, code, common.EmailVerificationPurpose) {
786 c.JSON(http.StatusOK, gin.H{
787 "success": false,
788 "message": "验证码错误或已过期",
789 })
790 return
791 }
792 session := sessions.Default(c)
793 id := session.Get("id")
794 user := model.User{
795 Id: id.(int),
796 }
797 err := user.FillUserById()
798 if err != nil {
799 common.ApiError(c, err)
800 return
801 }
802 user.Email = email
803 // no need to check if this email already taken, because we have used verification code to check it
804 err = user.Update(false)
805 if err != nil {
806 common.ApiError(c, err)
807 return
808 }
809 c.JSON(http.StatusOK, gin.H{
810 "success": true,
811 "message": "",
812 })
813 return
814}
815
816type topUpRequest struct {
817 Key string `json:"key"`

Callers

nothing calls this directly

Calls 5

FillUserByIdMethod · 0.95
UpdateMethod · 0.95
VerifyCodeWithKeyFunction · 0.92
ApiErrorFunction · 0.92
GetMethod · 0.80

Tested by

no test coverage detected