Error handling in login/signup
This commit is contained in:
parent
edd632fd76
commit
536c791f66
2 changed files with 14 additions and 1 deletions
|
|
@ -19,6 +19,8 @@ export default {
|
|||
body: JSON.stringify(data)
|
||||
})
|
||||
} catch (err) {
|
||||
console.log("oops");
|
||||
|
||||
console.error(err)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,6 +65,11 @@ declare global {
|
|||
|
||||
const response = await API.login(key)
|
||||
|
||||
if (response.error) {
|
||||
alert(response.error)
|
||||
return
|
||||
}
|
||||
|
||||
localStorage.setItem('token', response.token)
|
||||
localStorage.setItem('key', response.password)
|
||||
|
||||
|
|
@ -89,6 +94,11 @@ declare global {
|
|||
|
||||
const response = await API.signup(nickname)
|
||||
|
||||
if (response.error) {
|
||||
alert(response.error)
|
||||
return
|
||||
}
|
||||
|
||||
localStorage.setItem('token', response.token)
|
||||
localStorage.setItem('key', response.password)
|
||||
|
||||
|
|
@ -106,7 +116,8 @@ declare global {
|
|||
function logout() {
|
||||
const sure = confirm("Are you sure you want to logout? " +
|
||||
"You won't be able to login again without #key. " +
|
||||
"Make sure you copied key before log out!")
|
||||
"Make sure you copied #key before log out!\n\n" +
|
||||
"The #key: " + window.myStuff.key)
|
||||
|
||||
if (!sure)
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue