+ AuthBind中添加BindType

- 合并函数GetAuthBindsByAuthID2
- User中的mobile与email改为可为null
This commit is contained in:
gazebo
2019-09-03 15:35:54 +08:00
parent 73c5656be2
commit dad8adc4bf
10 changed files with 58 additions and 49 deletions

View File

@@ -61,7 +61,7 @@ func (a *DefAuther) GetUserType() (userType int8) {
func (a *DefAuther) UnionFindAuthBind(curAuthType string, unionAuthTypeList []string, openID, unionID string, authDetail interface{}) (authBindEx *auth2.AuthBindEx, err error) {
db := dao.GetDB()
var authBind *model.AuthBind
if authBind, err = dao.GetAuthBind(db, "", curAuthType, openID); err == nil { // 直接找到了
if authBind, err = dao.GetAuthBind(db, "", model.AuthBindTypeAuth, curAuthType, openID); err == nil { // 直接找到了
authBindEx = &auth2.AuthBindEx{
AuthBind: *authBind,
}
@@ -71,7 +71,7 @@ func (a *DefAuther) UnionFindAuthBind(curAuthType string, unionAuthTypeList []st
} else if dao.IsNoRowsError(err) { // 直接找不到尝试unionID
if unionID != "" { // 且有unionID
var authBindList []*model.AuthBind
if authBindList, err = dao.GetAuthBindsByAuthID2(db, unionID, unionAuthTypeList); err == nil && len(authBindList) > 0 { // 通过unionID找到至少一个认证方式
if authBindList, err = dao.GetUserBindAuthInfo(db, "", model.AuthBindTypeAuth, unionID, unionAuthTypeList); err == nil && len(authBindList) > 0 { // 通过unionID找到至少一个认证方式
authBind = authBindList[0]
authBind.Type = curAuthType
authBind.AuthID = openID

View File

@@ -37,7 +37,7 @@ func init() {
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 {
if authBind, err = dao.GetAuthBind(dao.GetDB(), "", model.AuthBindTypeAuth, AuthType, userID); err == nil {
if err = a.checkPassword(authBind, passMD5); err == nil {
authBindEx = &auth2.AuthBindEx{
AuthBind: *authBind,
@@ -55,7 +55,7 @@ func (a *Auther) ChangePassword(userID, oldPassMD5, newPassMD5 string) (err erro
db := dao.GetDB()
salt := utils.GetUUID()
encryptPwd := a.encryptPassword(newPassMD5, salt)
if authBind, err = dao.GetAuthBind(db, "", AuthType, userID); err == nil {
if authBind, err = dao.GetAuthBind(db, "", model.AuthBindTypeAuth, AuthType, userID); err == nil {
if err = a.checkPassword(authBind, oldPassMD5); err == nil || authBind.AuthSecret == "" { // 如果原密码为空,不判断原密码,代表重置密码
_, err = dao.UpdateEntityLogically(db, authBind, map[string]interface{}{
"AuthSecret": encryptPwd,