修改登录逻辑
默认先websoket鉴权判断是否需要登录
This commit is contained in:
parent
97cb80e556
commit
46eadf7f8d
@ -403,9 +403,6 @@ export default class App extends Mixins(BaseMixin, ThemeMixin) {
|
||||
this.appHeight()
|
||||
window.addEventListener('resize', this.appHeight)
|
||||
window.addEventListener('orientationchange', this.appHeight)
|
||||
if (!localStorage.getItem('token')) {
|
||||
this.$refs.loginRef.showDialog=true
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -21,19 +21,26 @@ export const actions: ActionTree<ServerState, RootState> = {
|
||||
|
||||
// identify client
|
||||
try {
|
||||
let token = null
|
||||
if (localStorage.getItem('token')) {
|
||||
token = localStorage.getItem('token')
|
||||
} else {
|
||||
token = null
|
||||
let token = localStorage.getItem('token')
|
||||
|
||||
let data = {
|
||||
client_name: 'mainsail',
|
||||
version: rootState.packageVersion,
|
||||
type: 'web',
|
||||
url: 'https://github.com/mainsail-crew/mainsail',
|
||||
}
|
||||
const connection = await Vue.$socket.emitAndWait('server.connection.identify', {
|
||||
|
||||
let dataWithToken = {
|
||||
client_name: 'mainsail',
|
||||
version: rootState.packageVersion,
|
||||
type: 'web',
|
||||
url: 'https://github.com/mainsail-crew/mainsail',
|
||||
access_token: token
|
||||
})
|
||||
}
|
||||
|
||||
let wsData = token ? dataWithToken : data;
|
||||
|
||||
const connection = await Vue.$socket.emitAndWait('server.connection.identify', wsData)
|
||||
commit('setConnectionId', connection.connection_id)
|
||||
} catch (e: any) {
|
||||
if (e.message === 'Unauthorized') {
|
||||
|
Loading…
x
Reference in New Issue
Block a user