(c *gin.Context)
| 780 | } |
| 781 | |
| 782 | func 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 | |
| 816 | type topUpRequest struct { |
| 817 | Key string `json:"key"` |
nothing calls this directly
no test coverage detected