- SignIn component. Added also in the Toolbar (Header.ts)
This commit is contained in:
@@ -19,6 +19,7 @@ import globalroutines from './../../globalroutines/index'
|
||||
|
||||
|
||||
import { cfgrouter } from '../../router/route-config'
|
||||
import { static_data } from '@src/db/static_data'
|
||||
// import { static_data } from '@src/db/static_data'
|
||||
|
||||
let stateConnDefault = 'online'
|
||||
@@ -285,6 +286,7 @@ namespace Actions {
|
||||
}
|
||||
|
||||
function createPushSubscription(context) {
|
||||
console.log('createPushSubscription')
|
||||
|
||||
// If Already subscribed, don't send to the Server DB
|
||||
// if (state.wasAlreadySubOnDb) {
|
||||
@@ -296,6 +298,9 @@ namespace Actions {
|
||||
// return
|
||||
// }
|
||||
|
||||
if (!static_data.functionality.PWA)
|
||||
return
|
||||
|
||||
if (!('serviceWorker' in navigator)) {
|
||||
return
|
||||
}
|
||||
@@ -417,23 +422,25 @@ namespace Actions {
|
||||
await globalroutines(null, 'clearalldata', table, null)
|
||||
}
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
// REMOVE ALL SUBSCRIPTION
|
||||
console.log('REMOVE ALL SUBSCRIPTION...')
|
||||
await navigator.serviceWorker.ready.then((reg) => {
|
||||
console.log('... Ready')
|
||||
reg.pushManager.getSubscription().then((subscription) => {
|
||||
console.log(' Found Subscription...')
|
||||
if (subscription) {
|
||||
subscription.unsubscribe().then((successful) => {
|
||||
// You've successfully unsubscribed
|
||||
console.log('You\'ve successfully unsubscribed')
|
||||
}).catch((e) => {
|
||||
// Unsubscription failed
|
||||
})
|
||||
}
|
||||
if (static_data.functionality.PWA) {
|
||||
if ('serviceWorker' in navigator) {
|
||||
// REMOVE ALL SUBSCRIPTION
|
||||
console.log('REMOVE ALL SUBSCRIPTION...')
|
||||
await navigator.serviceWorker.ready.then((reg) => {
|
||||
console.log('... Ready')
|
||||
reg.pushManager.getSubscription().then((subscription) => {
|
||||
console.log(' Found Subscription...')
|
||||
if (subscription) {
|
||||
subscription.unsubscribe().then((successful) => {
|
||||
// You've successfully unsubscribed
|
||||
console.log('You\'ve successfully unsubscribed')
|
||||
}).catch((e) => {
|
||||
// Unsubscription failed
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
await deleteSubscriptionToServer(context)
|
||||
|
||||
@@ -198,9 +198,14 @@ namespace Mutations {
|
||||
state.name = ''
|
||||
state.surname = ''
|
||||
resetArrToken(state.tokens)
|
||||
state.x_auth_token = ''
|
||||
state.verified_email = false
|
||||
state.categorySel = 'personal'
|
||||
|
||||
state.servercode = 0
|
||||
state.resStatus = 0
|
||||
state.isLogged = false
|
||||
state.isAdmin = false
|
||||
state.x_auth_token = ''
|
||||
}
|
||||
|
||||
function setErrorCatch(state: IUserState, axerr: Types.AxiosError) {
|
||||
@@ -554,7 +559,7 @@ namespace Actions {
|
||||
// state.isLogged = true
|
||||
state.isLogged = isLogged
|
||||
if (isLogged) {
|
||||
console.log('state.isLogged')
|
||||
console.log('state.isLogged', state.isLogged)
|
||||
GlobalStore.mutations.setleftDrawerOpen(localStorage.getItem(tools.localStorage.leftDrawerOpen) === 'true')
|
||||
GlobalStore.mutations.setCategorySel(localStorage.getItem(tools.localStorage.categorySel))
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import { lists } from './lists'
|
||||
import { static_data } from '@src/db/static_data'
|
||||
import { IColl, ITimeLineEntry, ITimeLineMain } from '@src/model/GlobalStore'
|
||||
import { func_tools } from '@src/store/Modules/toolsext'
|
||||
import { serv_constants } from '@src/store/Modules/serv_constants'
|
||||
|
||||
export interface INotify {
|
||||
color?: string | 'primary'
|
||||
@@ -2107,8 +2108,86 @@ export const tools = {
|
||||
} else {
|
||||
return mythis.$t('msg.myAppName')
|
||||
}
|
||||
},
|
||||
|
||||
loginOk(mythis, ispageLogin: boolean) {
|
||||
// console.log('loginOk')
|
||||
|
||||
if (toolsext.getLocale() !== '') {
|
||||
mythis.$i18n.locale = toolsext.getLocale()
|
||||
} // Set Lang
|
||||
else {
|
||||
UserStore.mutations.setlang(mythis.$i18n.locale)
|
||||
} // Set Lang
|
||||
|
||||
if (process.env.DEBUG) {
|
||||
console.log('LANG ORA=', toolsext.getLocale())
|
||||
}
|
||||
|
||||
globalroutines(mythis, 'loadapp', '')
|
||||
|
||||
tools.checkErrors(mythis, tools.OK, ispageLogin)
|
||||
},
|
||||
|
||||
loginInCorso(mythis) {
|
||||
// console.log('loginInCorso')
|
||||
|
||||
let msg = mythis.$t('login.incorso')
|
||||
if (process.env.DEBUG) {
|
||||
msg += ' ' + process.env.MONGODB_HOST
|
||||
}
|
||||
mythis.$q.loading.show({ message: msg })
|
||||
},
|
||||
|
||||
checkErrors(mythis, riscode, ispageLogin?: boolean) {
|
||||
// console.log('checkErrors: ', riscode)
|
||||
try {
|
||||
if (riscode === tools.OK) {
|
||||
tools.showNotif(mythis.$q, mythis.$t('login.completato'), { color: 'positive', icon: 'check' })
|
||||
if (ispageLogin) {
|
||||
mythis.$router.push('/')
|
||||
}
|
||||
} else if (riscode === serv_constants.RIS_CODE_LOGIN_ERR) {
|
||||
|
||||
// Wait N seconds to avoid calling many times...
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve('anything')
|
||||
}, 3000)
|
||||
}).then(() => {
|
||||
setTimeout(() => {
|
||||
console.log('HIDE...')
|
||||
mythis.$q.loading.hide()
|
||||
}, 500)
|
||||
tools.showNotif(mythis.$q, mythis.$t('login.errato'), { color: 'negative', icon: 'notifications' })
|
||||
mythis.iswaitingforRes = false
|
||||
if (ispageLogin) {
|
||||
mythis.$router.push('/signin')
|
||||
}
|
||||
})
|
||||
|
||||
} else if (riscode === tools.ERR_SERVERFETCH) {
|
||||
tools.showNotif(mythis.$q, mythis.$t('fetch.errore_server'), { color: 'negative', icon: 'notifications' })
|
||||
} else if (riscode === tools.ERR_GENERICO) {
|
||||
const msg = mythis.$t('fetch.errore_generico') + UserStore.mutations.getMsgError(riscode)
|
||||
tools.showNotif(mythis.$q, msg, { color: 'negative', icon: 'notifications' })
|
||||
} else {
|
||||
tools.showNotif(mythis.$q, 'Errore num ' + riscode, { color: 'negative', icon: 'notifications' })
|
||||
}
|
||||
|
||||
if (riscode !== serv_constants.RIS_CODE_LOGIN_ERR) {
|
||||
mythis.iswaitingforRes = false
|
||||
setTimeout(() => {
|
||||
mythis.$q.loading.hide()
|
||||
}, 200)
|
||||
}
|
||||
|
||||
} finally {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// getLocale() {
|
||||
// if (navigator.languages && navigator.languages.length > 0) {
|
||||
// return navigator.languages[0]
|
||||
|
||||
Reference in New Issue
Block a user