Fixed problem when session not found
This commit is contained in:
parent
7031c0100e
commit
ddb49bad13
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module notes
|
||||
go 1.21.0
|
||||
|
||||
require (
|
||||
git.gibonuddevalla.se/go/webservice v0.1.1
|
||||
git.gibonuddevalla.se/go/webservice v0.2.0
|
||||
github.com/google/uuid v1.5.0
|
||||
github.com/gorilla/websocket v1.5.0
|
||||
github.com/jmoiron/sqlx v1.3.5
|
||||
|
@ -31,7 +31,7 @@ class App extends Component {
|
||||
let app_el = document.getElementById('app')
|
||||
|
||||
if (!this.session.initialized) {
|
||||
return html`<div>Validating session</div>`
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.session.authenticated()) {
|
||||
@ -130,8 +130,16 @@ class App extends Component {
|
||||
.then(json => {
|
||||
// An application level error occured
|
||||
if (!json.OK) {
|
||||
switch (json.Code) {
|
||||
case '001-0001': // Session not found
|
||||
this.session.reset()
|
||||
location.href = '/'
|
||||
break
|
||||
|
||||
default:
|
||||
return reject({ app: json })
|
||||
}
|
||||
}
|
||||
return resolve(json)
|
||||
})
|
||||
.catch(err => reject({ comm: err }))
|
||||
|
@ -32,9 +32,6 @@ export class Session {
|
||||
this.UserID = res.Session.UserID // could be 0
|
||||
this.initialized = true
|
||||
this.app.forceUpdate()
|
||||
} else {
|
||||
// Session has probably expired. A new is required.
|
||||
this.create()
|
||||
}
|
||||
})
|
||||
.catch(this.app.responseError)
|
||||
@ -43,12 +40,17 @@ export class Session {
|
||||
this.app.request('/_session/new', {})
|
||||
.then(res => {
|
||||
this.UUID = res.Session.UUID
|
||||
window.localStorage.setItem('session.UUID', this.Session.UUID)
|
||||
window.localStorage.setItem('session.UUID', this.UUID)
|
||||
this.initialized = true
|
||||
this.app.forceUpdate()
|
||||
})
|
||||
.catch(this.responseError)
|
||||
}//}}}
|
||||
reset() {//{{{
|
||||
window.localStorage.removeItem('session.UUID')
|
||||
this.initialized = false
|
||||
this.UserID = 0
|
||||
}//}}}
|
||||
authenticate(username, password) {//{{{
|
||||
this.app.login.current.authentication_failed.value = false
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user