Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug:修改头像并提交后,密码也会被改了 #538

Closed
bitxx opened this issue Aug 17, 2021 · 7 comments
Closed

bug:修改头像并提交后,密码也会被改了 #538

bitxx opened this issue Aug 17, 2021 · 7 comments

Comments

@bitxx
Copy link

bitxx commented Aug 17, 2021

 RT

@wenjianzhang
Copy link
Member

wenjianzhang commented Aug 19, 2021

请完整的描述您的问题!

@bitxx
Copy link
Author

bitxx commented Aug 20, 2021

请完整的描述您的问题!

后台账户登录后,修改账户资料那里,剪裁变更头像并提交后,当前账户的密码也被改了。
调试跟踪后发现,应该是更新头像时,调用的save保存的SysUser,密码又被二次加密了。

@wenjianzhang
Copy link
Member

最新版本吗?

@zhr930219
Copy link

我也发现这问题了,更新头像后,就无法登陆了

@chenshiwei-io
Copy link

请完整的描述您的问题!

后台账户登录后,修改账户资料那里,剪裁变更头像并提交后,当前账户的密码也被改了。 调试跟踪后发现,应该是更新头像时,调用的save保存的SysUser,密码又被二次加密了。

我也遇到了,是gorm 更新结构体的所有字段覆盖了

@brucewangzhihua
Copy link

//密码长度小于60是没有加密过的密码,更新前需要加密
func (e *SysUser) BeforeUpdate(_ *gorm.DB) error {
var err error
if len(e.Password) < 60 {
err = e.Encrypt()
}
return err
}

@brucewangzhihua
Copy link

导致这个问题的原因是更新用户任何信息都是全量更新,而更新前埋了一个钩子对密码进行了一次加密。这样就造成了二次加密

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants