add comments

This commit is contained in:
Settel 2023-01-29 15:36:06 +01:00
parent a243deb79e
commit 1dcd26ffcf
2 changed files with 27 additions and 0 deletions

View File

@ -25,8 +25,11 @@ export default (): useAuth => {
user.setUserInfo(userInfo) user.setUserInfo(userInfo)
useI18n({}).setLang(userInfo.lang) useI18n({}).setLang(userInfo.lang)
if (allowRoles.indexOf(userInfo.role) >= 0 ) { if (allowRoles.indexOf(userInfo.role) >= 0 ) {
// user is authenticated and authorized, let the user in
return return
} }
// user is authenticated but not authorized for this page
if (user.isAdmin) { if (user.isAdmin) {
document.location.pathname = '/admin' document.location.pathname = '/admin'
// can't use navigateTo() for it fails with DOMException if two consecutive redirects happen (at least in docker container) // can't use navigateTo() for it fails with DOMException if two consecutive redirects happen (at least in docker container)
@ -35,6 +38,7 @@ export default (): useAuth => {
document.location.pathname = '/play' document.location.pathname = '/play'
} }
} catch (e) { } catch (e) {
// user is not authenticated
if (allowRoles.indexOf('') == -1 ) { if (allowRoles.indexOf('') == -1 ) {
document.location.pathname = '/' document.location.pathname = '/'
} }

View File

@ -0,0 +1,23 @@
import { defineStore } from 'pinia'
export type Serverinfo = {
isInitialized: boolean
}
export const useServerinfoStore = defineStore('ServerinfoStore', {
state: () => {
return {
Serverinfo: {
isInitialized: false,
} as Serverinfo,
}
},
getters: {
isInitialized: (state): boolean => state.Serverinfo.isInitialized,
},
actions: {
setServerinfo(Serverinfo: Serverinfo): void {
this.Serverinfo = Serverinfo
},
},
})