Skip to content

Commit

Permalink
fix: change msg returned upon verifying one email change link
Browse files Browse the repository at this point in the history
  • Loading branch information
kangmingtay committed Sep 23, 2021
1 parent 407e20c commit 355fae5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion api/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ func (a *API) Verify(w http.ResponseWriter, r *http.Request) error {
user, terr = a.recoverVerify(ctx, tx, params)
case emailChangeVerification:
user, terr = a.emailChangeVerify(ctx, tx, params)
if user == nil && terr == nil {
rurl := a.prepRedirectURL("Confirmation link accepted. Please proceed to confirm link sent to the other email", params.RedirectTo)
http.Redirect(w, r, rurl, http.StatusFound)
return nil
}
case smsVerification:
if params.Phone == "" {
return unprocessableEntityError("Sms Verification requires a phone number")
Expand Down Expand Up @@ -297,6 +302,12 @@ func (a *API) prepErrorRedirectURL(err *HTTPError, r *http.Request, rurl string)
return rurl + "#" + q.Encode()
}

func (a *API) prepRedirectURL(message string, rurl string) string {
q := url.Values{}
q.Set("message", message)
return rurl + "#" + q.Encode()
}

func (a *API) emailChangeVerify(ctx context.Context, conn *storage.Connection, params *VerifyParams) (*models.User, error) {
instanceID := getInstanceID(ctx)
config := a.getConfig(ctx)
Expand Down Expand Up @@ -337,7 +348,7 @@ func (a *API) emailChangeVerify(ctx context.Context, conn *storage.Connection, p
if err != nil {
return nil, err
}
return nil, acceptedTokenError("Email change request accepted").WithInternalError(redirectWithQueryError)
return nil, nil
}
}

Expand Down

0 comments on commit 355fae5

Please sign in to comment.