From dce28f4aa029819bdd798d10d524bbd5b524c922 Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 4 Mar 2019 11:39:11 +0800 Subject: [PATCH] - fullfill ChangePassword --- business/auth2/authprovider/password/password.go | 7 ++++++- controllers/auth2.go | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/business/auth2/authprovider/password/password.go b/business/auth2/authprovider/password/password.go index f085f82fd..140976686 100644 --- a/business/auth2/authprovider/password/password.go +++ b/business/auth2/authprovider/password/password.go @@ -20,12 +20,17 @@ type Auther struct { authprovider.DefAuther } +var ( + AutherObj *Auther +) + var ( ErrUserAndPassNotMatch = errors.New("用户名密码不匹配") ) func init() { - auth2.RegisterAuther(AuthType, new(Auther)) + AutherObj = new(Auther) + auth2.RegisterAuther(AuthType, AutherObj) } func (a *Auther) VerifySecret(userID, passMD5 string) (authBind *model.AuthBind, err error) { diff --git a/controllers/auth2.go b/controllers/auth2.go index 51754e89f..1107e7d61 100644 --- a/controllers/auth2.go +++ b/controllers/auth2.go @@ -8,6 +8,7 @@ import ( "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/auth2" + "git.rosy.net.cn/jx-callback/business/auth2/authprovider/password" "git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin" "git.rosy.net.cn/jx-callback/business/jxcallback/auth" "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" @@ -194,6 +195,10 @@ func (c *Auth2Controller) RemoveAuthBind() { // @router /ChangePassword [put] func (c *Auth2Controller) ChangePassword() { c.callChangePassword(func(params *tAuth2ChangePasswordParams) (retVal interface{}, errCode string, err error) { + authInfo, err := c.getAuth2Info(params.Ctx) + if err == nil { + err = password.AutherObj.ChangePassword(authInfo.GetID(), params.OldPwd, params.NewPwd) + } return retVal, "", err }) }