-
Notifications
You must be signed in to change notification settings - Fork 32
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
Small login bugs #1788
Small login bugs #1788
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,7 @@ | |
<v-row> | ||
<v-btn | ||
type="submit" | ||
@click.prevent="verifyPassword" | ||
@click.prevent="() => verifyPassword()" | ||
size="large" | ||
color="success" | ||
:disabled="!formValid" | ||
|
@@ -138,6 +138,11 @@ export default { | |
} | ||
}) | ||
}, | ||
mounted: function () { | ||
if (localStorage.openc3Token) { | ||
this.verifyPassword(localStorage.openc3Token, true) | ||
} | ||
}, | ||
methods: { | ||
showReset: function () { | ||
this.reset = true | ||
|
@@ -147,28 +152,33 @@ export default { | |
const redirect = new URLSearchParams(window.location.search).get( | ||
'redirect', | ||
) | ||
if (redirect.startsWith('/tools/')) { | ||
if (redirect?.startsWith('/tools/')) { | ||
// Valid relative redirect URL | ||
window.location = decodeURI(redirect) | ||
} else { | ||
window.location = '/' | ||
} | ||
}, | ||
verifyPassword: function () { | ||
verifyPassword: function (token, noAlert) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this ever called with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's called with |
||
token ||= this.password | ||
this.showAlert = false | ||
Api.post('/openc3-api/auth/verify', { | ||
data: { | ||
token: this.password, | ||
token, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}, | ||
...this.options, | ||
}) | ||
.then((response) => { | ||
this.login(response) | ||
}) | ||
.catch((error) => { | ||
this.alert = 'Incorrect password' | ||
if (error?.status === 401) { | ||
this.alert = 'Incorrect password' | ||
} else { | ||
this.alert = error.message || 'Something went wrong...' | ||
} | ||
this.alertType = 'warning' | ||
this.showAlert = true | ||
this.showAlert = !noAlert | ||
}) | ||
}, | ||
setPassword: function () { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this work since verifyPassword takes 2 parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All js function arguments default to
undefined
if you don't pass them in. So for when it's called from here, the||=
operator on line 163 will settoken
, and the!
operator on line 181 will negateundefined
to setthis.showAlert
to true.This line could be written as
@click.prevent="() => verifyPassword(password, false)"
(or evenverifyPassword(null, false)
) but it's unnecessary to be explicit