Finished password reset workflow. Remove all password tokens upon successful reset.
This commit is contained in:
parent
bd5bbab47c
commit
ed9413ee17
8 changed files with 107 additions and 56 deletions
|
|
@ -152,6 +152,15 @@ func (c *Client) GetValidPasswordToken(ctx echo.Context, token string, userID in
|
|||
return nil, InvalidTokenError{}
|
||||
}
|
||||
|
||||
func (c *Client) DeletePasswordTokens(ctx echo.Context, userID int) error {
|
||||
_, err := c.orm.PasswordToken.
|
||||
Delete().
|
||||
Where(passwordtoken.HasUserWith(user.ID(userID))).
|
||||
Exec(ctx.Request().Context())
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) RandomToken(length int) (string, error) {
|
||||
b := make([]byte, length)
|
||||
if _, err := rand.Read(b); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue