add auth login error handling
This commit is contained in:
parent
7cb14bc850
commit
b36a961d80
3 changed files with 42 additions and 22 deletions
|
|
@ -24,6 +24,7 @@ const state = reactive<AuthState>({
|
|||
const AUTH_KEY = 'crimata_token';
|
||||
|
||||
const token = window.localStorage.getItem(AUTH_KEY);
|
||||
console.log('token: ',token)
|
||||
|
||||
if (token) {
|
||||
const { loading, error, data, send } = useIpc('auth-user');
|
||||
|
|
@ -31,11 +32,12 @@ if (token) {
|
|||
state.authenticating = true;
|
||||
|
||||
// authenticate token against crimata-platform
|
||||
console.log('sending token to main')
|
||||
send({
|
||||
token: token
|
||||
});
|
||||
|
||||
watch([loading], () => {
|
||||
watch(loading, () => {
|
||||
if (error.value) {
|
||||
console.log('ERROR: failed authentication')
|
||||
window.localStorage.removeItem(AUTH_KEY);
|
||||
|
|
@ -46,6 +48,8 @@ if (token) {
|
|||
|
||||
state.authenticating = false;
|
||||
})
|
||||
} else {
|
||||
console.log('no token to send')
|
||||
}
|
||||
|
||||
export const useAuth = () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue