Skip to content

Commit 2158073

Browse files
author
Christopher Schinnerl
authored
Merge pull request #194 from SkynetLabs/ivo/recover_unconfirmed
Allow account recovery from unconfirmed emails.
2 parents 2a81946 + a602aa9 commit 2158073

File tree

2 files changed

+1
-16
lines changed

2 files changed

+1
-16
lines changed

api/handlers.go

-5
Original file line numberDiff line numberDiff line change
@@ -1013,11 +1013,6 @@ func (api *API) userRecoverRequestPOST(_ *database.User, w http.ResponseWriter,
10131013
api.WriteError(w, errors.AddContext(err, "failed to fetch the user with this email"), http.StatusInternalServerError)
10141014
return
10151015
}
1016-
// Verify that the user's email is confirmed.
1017-
if u.EmailConfirmationToken != "" {
1018-
api.WriteError(w, errors.New("user's email is not confirmed. it cannot be used for account recovery"), http.StatusBadRequest)
1019-
return
1020-
}
10211016
// Generate a new recovery token and add it to the user's account.
10221017
u.RecoveryToken, err = lib.GenerateUUID()
10231018
if err != nil {

test/api/handlers_test.go

+1-11
Original file line numberDiff line numberDiff line change
@@ -733,18 +733,8 @@ func testUserAccountRecovery(t *testing.T, at *test.AccountsTester) {
733733
if len(msgs) != 1 || msgs[0].Subject != "Account access attempted" {
734734
t.Fatalf("Expected to find a single email with subject '%s', got %v", "Account access attempted", msgs)
735735
}
736-
// Request recovery with a valid but unconfirmed email.
737-
_, err = at.UserRecoverRequestPOST(u.Email)
738-
if err == nil || !strings.Contains(err.Error(), badRequest) {
739-
t.Fatalf("Expected '%s', got '%s'", badRequest, err)
740-
}
741-
// Confirm the email.
742-
_, err = at.UserConfirmGET(u.EmailConfirmationToken)
743-
if err != nil {
744-
t.Fatal(err)
745-
}
746736
// Request recovery with a valid email. We expect there to be a single email
747-
// with the recovery token.
737+
// with the recovery token. The email is unconfirmed but we don't mind that.
748738
bodyParams := url.Values{}
749739
bodyParams.Set("email", u.Email)
750740
_, err = at.UserRecoverRequestPOST(u.Email)

0 commit comments

Comments
 (0)