Skip to content

chore: improve error message for incorrect login type #8349

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

Merged
merged 2 commits into from
Jul 7, 2023

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented Jul 6, 2023

Fixes #8345

Before

Screenshot from 2023-06-28 16-09-47

After

(link takes you to /login)

Screenshot from 2023-07-06 14-05-11

@Emyrk Emyrk requested a review from bpmct July 6, 2023 18:06
@Emyrk Emyrk changed the title chore: add better error in wrong login type chore: improve error message for incorrect login type Jul 6, 2023
@Emyrk Emyrk requested a review from johnstcn July 7, 2023 14:07
Comment on lines 1376 to 1385
addedMsg := ""
if user.LoginType == database.LoginTypePassword {
addedMsg = " You can convert your account to use this login type by visiting your account settings."
}
return database.User{}, httpError{
code: http.StatusForbidden,
msg: fmt.Sprintf("Incorrect login type, attempting to use %q but user is of login type %q",
params.LoginType,
user.LoginType,
),
code: http.StatusForbidden,
renderStaticPage: true,
msg: "Incorrect login type",
detail: fmt.Sprintf("Attempting to use login type %q, but the user has the login type %q.%s",
params.LoginType, user.LoginType, addedMsg),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to dedupe this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably. I'll do it

Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Only nit I have is potential deduplication of the httpError when login type mismatch detected.

@Emyrk Emyrk merged commit a297a01 into main Jul 7, 2023
@Emyrk Emyrk deleted the stevenmasley/incorrect_login_error branch July 7, 2023 15:33
@github-actions github-actions bot locked and limited conversation to collaborators Jul 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve error for invalid login type
3 participants