Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const logout = function() {
resetLoginInfo()
Notify.create({
message: 'You have been logged out.',
type: 'info'
})
// @todo check if current route is !== from login then go to login else do nothing
console.info('compare the location.href with / if different then push / to router, check that you dont loop infinitly')
if (location.hash.replace('#/', '/') !== '/') {
router.push('/')
}
}
created() {
const defaultUser = {
user: {
username: 'inconnu'
}
}
this.user = defaultUser
if (typeof localStorage == 'undefined') {
Notify.create({
message: `No localStorage feature available in the browser`,
type: 'warning'
})
}
IsLoggedInObservable.subscribe(isLoggedIn => {
if (!isLoggedIn
|| !isLoggedIn.me) {
this.user = defaultUser
} else {
this.user = isLoggedIn.me
}
this.isLoading = false
}, err => {
// @todo we may have different message belongs to err
Notify.create({
.then(res => {
Notify.create({
message: `Invalid token, please try again`,
type: 'warning'
})
})
.catch(err => console.warn('axios middleware CsrfTokenRetreiveOnInvalidResponse', 'getToken', err))
onError(({ networkError }) => {
if (423 === networkError.statusCode) {
getToken()
.then(res => Toast.create.warning(`Invalid token, please try again`))
.catch(err => console.warn('apollo onError', 'getToken', err))
} else {
console.warn(`Unknown error ${networkError.statusCode}`, networkError)
Notify.create({
message: `Unknown error ${networkError.statusCode}`,
type: 'warning'
})
}
})