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

Use nicer error message for login nonce error #13432

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions shell/assets/translations/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3392,6 +3392,7 @@ login:
invalidSamlAttrs: "Invalid saml attributes"
noResponse: "No response received"
error: An error occurred logging in. Please try again.
invalidResponseError: Invalid response received to login request. Please try again.
clientError: Invalid username or password. Please try again.
specificError: 'An error occurred logging in: {msg}'
useLocal: Use a local user
Expand Down
2 changes: 2 additions & 0 deletions shell/pages/auth/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ export default {
return this.t('login.clientError');
} else if (this.err === LOGIN_ERRORS.CLIENT || this.err === LOGIN_ERRORS.SERVER) {
return this.t('login.error');
} else if (this.err === LOGIN_ERRORS.NONCE) {
return this.t('login.invalidResponseError');
}

return this.err?.length ? this.t('login.specificError', { msg: this.err }) : '';
Expand Down
9 changes: 4 additions & 5 deletions shell/store/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ export const BASE_SCOPES = {

const KEY = 'rc_nonce';

const ERR_NONCE = 'nonce';

export const LOGIN_ERRORS = {
CLIENT: 'client',
CLIENT_UNAUTHORIZED: 'client_unauthorized',
SERVER: 'server'
SERVER: 'server',
NONCE: 'nonce',
Copy link
Member

Choose a reason for hiding this comment

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

wondered if we should also change this, as it's in the url. higher risk, it's not an un-factual state and would help product support though

};

export const state = function() {
Expand Down Expand Up @@ -267,13 +266,13 @@ export const actions = {
try {
parsed = JSON.parse(expectJSON);
} catch {
return ERR_NONCE;
return LOGIN_ERRORS.NONCE;
}

const expect = parsed.nonce;

if ( !expect || expect !== nonce ) {
return ERR_NONCE;
return LOGIN_ERRORS.NONCE;
}

const body = { code };
Expand Down