Skip to content

Commit

Permalink
keystone: passwords: SetModelManager
Browse files Browse the repository at this point in the history
To quash avoid informer error "virtual object is nil"
  • Loading branch information
yousong committed Jun 21, 2020
1 parent 7d47ac4 commit f1dfcd5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/keystone/models/passwords.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,19 @@ func (manager *SPasswordManager) savePassword(localUserId int, password string,
if err != nil {
return errors.Wrap(err, "seclib2.BcryptPassword")
}
rec := SPassword{}
rec.LocalUserId = localUserId
rec.PasswordHash = hash
rec.Password = shaPassword(password)
rec := &SPassword{
LocalUserId: localUserId,
PasswordHash: hash,
Password: shaPassword(password),
}
rec.SetModelManager(PasswordManager, rec)
now := time.Now()
rec.CreatedAtInt = now.UnixNano() / 1000
if o.Options.PasswordExpirationSeconds > 0 && !isSystemAccount {
rec.ExpiresAt = now.Add(time.Second * time.Duration(o.Options.PasswordExpirationSeconds))
rec.ExpiresAtInt = rec.ExpiresAt.UnixNano() / 1000
}
err = manager.TableSpec().Insert(context.TODO(), &rec)
err = manager.TableSpec().Insert(context.TODO(), rec)
if err != nil {
return errors.Wrap(err, "Insert")
}
Expand Down

0 comments on commit f1dfcd5

Please sign in to comment.