- dingding auth

This commit is contained in:
gazebo
2019-03-07 21:15:19 +08:00
parent 123ffd4353
commit ce109a60b3
16 changed files with 238 additions and 85 deletions

View File

@@ -34,14 +34,19 @@ func init() {
auth2.RegisterAuther(AuthType, AutherObj)
}
func (a *Auther) VerifySecret(userID, passMD5 string) (authBind *model.AuthBind, err error) {
func (a *Auther) VerifySecret(userID, passMD5 string) (authBindEx *auth2.AuthBindEx, err error) {
globals.SugarLogger.Debugf("localpass VerifySecret userID:%s", userID)
var authBind *model.AuthBind
if authBind, err = dao.GetAuthBind(dao.GetDB(), "", AuthType, userID); err == nil {
err = a.checkPassword(authBind, passMD5)
if err = a.checkPassword(authBind, passMD5); err == nil {
authBindEx = &auth2.AuthBindEx{
AuthBind: *authBind,
}
}
} else if dao.IsNoRowsError(err) {
err = auth2.ErrUserAuthTypeNotExist
}
return authBind, err
return authBindEx, err
}
// 特殊接口
@@ -58,12 +63,14 @@ func (a *Auther) ChangePassword(userID, oldPassMD5, newPassMD5 string) (err erro
}, "admin", nil)
}
} else if dao.IsNoRowsError(err) {
err = a.AddAuthBind(&model.AuthBind{
UserID: userID,
Type: AuthType,
AuthID: userID,
AuthSecret: encryptPwd,
AuthSecret2: salt,
err = a.AddAuthBind(&auth2.AuthBindEx{
AuthBind: model.AuthBind{
UserID: userID,
Type: AuthType,
AuthID: userID,
AuthSecret: encryptPwd,
AuthSecret2: salt,
},
}, "admin")
}
return err