logging improvements

This commit is contained in:
Michael Quigley 2023-01-12 15:01:34 -05:00
parent f40e6efb24
commit 63edd0ed48
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
2 changed files with 5 additions and 4 deletions

View File

@ -38,15 +38,16 @@ func (self *inviteHandler) Handle(params account.InviteParams) middleware.Respon
defer func() { _ = tx.Rollback() }()
if self.cfg.Registration != nil && self.cfg.Registration.TokenStrategy == "store" {
invite, err := str.GetInviteTokenByToken(params.Body.Token, tx)
inviteToken, err := str.GetInviteTokenByToken(params.Body.Token, tx)
if err != nil {
logrus.Error(err)
logrus.Errorf("cannot get invite token '%v' for '%v': %v", params.Body.Token, params.Body.Email, err)
return account.NewInviteBadRequest()
}
if err := str.DeleteInviteToken(invite.Id, tx); err != nil {
if err := str.DeleteInviteToken(inviteToken.Id, tx); err != nil {
logrus.Error(err)
return account.NewInviteInternalServerError()
}
logrus.Infof("using invite token '%v' to process invite request for '%v'", inviteToken.Token, params.Body.Email)
}
token, err = createToken()

View File

@ -23,7 +23,7 @@ func (str *Store) CreateInviteTokens(inviteTokens []*InviteToken, tx *sqlx.Tx) e
}
stmt, err := tx.Prepare(fmt.Sprintf(sql, strings.Join(queries, ",")))
if err != nil {
return errors.Wrap(err, "error preparing invite_tokenss insert statement")
return errors.Wrap(err, "error preparing invite_tokens insert statement")
}
if _, err := stmt.Exec(invs...); err != nil {
return errors.Wrap(err, "error executing invites_tokens insert statement")