mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: implement api for "forgot password?" flow (#14915)
Relates to https://github.com/coder/coder/issues/14232 This implements two endpoints (names subject to change): - `/api/v2/users/otp/request` - `/api/v2/users/otp/change-password`
This commit is contained in:
@@ -10528,11 +10528,34 @@ func (q *sqlQuerier) UpdateUserGithubComUserID(ctx context.Context, arg UpdateUs
|
||||
return err
|
||||
}
|
||||
|
||||
const updateUserHashedOneTimePasscode = `-- name: UpdateUserHashedOneTimePasscode :exec
|
||||
UPDATE
|
||||
users
|
||||
SET
|
||||
hashed_one_time_passcode = $2,
|
||||
one_time_passcode_expires_at = $3
|
||||
WHERE
|
||||
id = $1
|
||||
`
|
||||
|
||||
type UpdateUserHashedOneTimePasscodeParams struct {
|
||||
ID uuid.UUID `db:"id" json:"id"`
|
||||
HashedOneTimePasscode []byte `db:"hashed_one_time_passcode" json:"hashed_one_time_passcode"`
|
||||
OneTimePasscodeExpiresAt sql.NullTime `db:"one_time_passcode_expires_at" json:"one_time_passcode_expires_at"`
|
||||
}
|
||||
|
||||
func (q *sqlQuerier) UpdateUserHashedOneTimePasscode(ctx context.Context, arg UpdateUserHashedOneTimePasscodeParams) error {
|
||||
_, err := q.db.ExecContext(ctx, updateUserHashedOneTimePasscode, arg.ID, arg.HashedOneTimePasscode, arg.OneTimePasscodeExpiresAt)
|
||||
return err
|
||||
}
|
||||
|
||||
const updateUserHashedPassword = `-- name: UpdateUserHashedPassword :exec
|
||||
UPDATE
|
||||
users
|
||||
SET
|
||||
hashed_password = $2
|
||||
hashed_password = $2,
|
||||
hashed_one_time_passcode = NULL,
|
||||
one_time_passcode_expires_at = NULL
|
||||
WHERE
|
||||
id = $1
|
||||
`
|
||||
|
||||
Reference in New Issue
Block a user