1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

feat: add ability to reset api key (resolve #29)

This commit is contained in:
Ferdinand Mütsch
2020-06-07 19:58:06 +02:00
parent 0294425de0
commit 0eac9a8854
4 changed files with 70 additions and 30 deletions

View File

@ -82,6 +82,11 @@ func (srv *UserService) Update(user *models.User) (*models.User, error) {
return user, nil
}
func (srv *UserService) ResetApiKey(user *models.User) (*models.User, error) {
user.ApiKey = uuid.NewV4().String()
return srv.Update(user)
}
func (srv *UserService) MigrateMd5Password(user *models.User, login *models.Login) (*models.User, error) {
user.Password = login.Password
if err := utils.HashPassword(user, srv.Config.PasswordSalt); err != nil {