RegisterUser支持token
This commit is contained in:
@@ -44,6 +44,8 @@ const (
|
||||
MinCaptchaLen = 4
|
||||
MaxCaptchaWidth = 400
|
||||
MaxCaptchaHeight = 400
|
||||
|
||||
InternalAuthSecret = "a36ca416-c85e-4dcf-aff9-590be3d2f8a2"
|
||||
)
|
||||
|
||||
type IUser interface {
|
||||
@@ -224,7 +226,7 @@ func SendVerifyCode(authToken, captchaID, captchaValue, authID string) (verfifyC
|
||||
// 公众号登录:authIDTypeD是UserIDEmpty,authSecret是code(这个函数是被微信的回调调用,不是直接被客户端调用)
|
||||
// 微信登录:authIDType是UserIDEmpty,authSecret是code(这个函数是被微信的回调调用,不是直接被客户端调用)
|
||||
// 小程序登录:authIDType是UserIDEmpty,authSecret是jsCode
|
||||
func Login(ctx *Context, authType, authID, authIDType, authSecret string) (authInfo *AuthInfo, err error) {
|
||||
func LoginInternal(ctx *Context, authType, authID, authIDType, authSecret string) (authInfo *AuthInfo, err error) {
|
||||
authType = strings.ToLower(authType)
|
||||
authIDType = strings.ToLower(authIDType)
|
||||
if handler := authers[authType]; handler != nil {
|
||||
@@ -279,6 +281,13 @@ func Login(ctx *Context, authType, authID, authIDType, authSecret string) (authI
|
||||
return authInfo, err
|
||||
}
|
||||
|
||||
func Login(ctx *Context, authType, authID, authIDType, authSecret string) (authInfo *AuthInfo, err error) {
|
||||
if authSecret == InternalAuthSecret {
|
||||
authSecret = ""
|
||||
}
|
||||
return LoginInternal(ctx, authIDType, authID, authIDType, authSecret)
|
||||
}
|
||||
|
||||
// 通过临时TOKEN绑定新创建的用户
|
||||
func BindUser(inauthInfo *AuthInfo, user IUser) (outauthInfo *AuthInfo, err error) {
|
||||
if err = AddAuthBind(user, inauthInfo); err == nil {
|
||||
|
||||
@@ -71,7 +71,9 @@ func (a *Auther) VerifySecret(mobileNumber, code string) (authBindEx *auth2.Auth
|
||||
globals.SugarLogger.Debugf("VerifySecret mobileNumber:%s, code:%s", mobileNumber, code)
|
||||
|
||||
err = ErrVerifyCodeIsWrong
|
||||
if (auth2.TestMobileMap[mobileNumber] == 1 && code == TestVerifyCode) || a.VerifyCode(mobileNumber, code) {
|
||||
if (code == auth2.InternalAuthSecret ||
|
||||
auth2.TestMobileMap[mobileNumber] == 1 && code == TestVerifyCode) ||
|
||||
a.VerifyCode(mobileNumber, code) {
|
||||
err = nil
|
||||
}
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user