Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: invited users should have a temporary password generated #1644

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion internal/api/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ func (a *API) verifyPost(w http.ResponseWriter, r *http.Request, params *VerifyP
func (a *API) signupVerify(r *http.Request, ctx context.Context, conn *storage.Connection, user *models.User) (*models.User, error) {
config := a.config

shouldUpdatePassword := false
if !user.HasPassword() && user.InvitedAt != nil {
// sign them up with temporary password, and require application
// to present the user with a password set form
Expand All @@ -318,11 +319,12 @@ func (a *API) signupVerify(r *http.Request, ctx context.Context, conn *storage.C
if err := user.SetPassword(ctx, password, config.Security.DBEncryption.Encrypt, config.Security.DBEncryption.EncryptionKeyID, config.Security.DBEncryption.EncryptionKey); err != nil {
return nil, err
}
shouldUpdatePassword = true
}

err := conn.Transaction(func(tx *storage.Connection) error {
var terr error
if !user.HasPassword() && user.InvitedAt != nil {
if shouldUpdatePassword {
if terr = user.UpdatePassword(tx, nil); terr != nil {
return internalServerError("Error storing password").WithInternalError(terr)
}
Expand Down
Loading