Skip to content

Commit 33069ba

Browse files
committed
handle logout
1 parent 0dabb6f commit 33069ba

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/app.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -770,14 +770,16 @@ function embedNbApp () {
770770
this.activeClass = newClass
771771
},
772772
onSessionEnd: async function () {
773-
const token = localStorage.getItem("nb.user");
774-
const config = { headers: { Authorization: 'Bearer ' + token }, params: { url: this.sourceURL } }
775-
await axios.post(`/api/spotlights/log/session/end`, {
776-
action: 'SESSION_END',
777-
type: 'NONE',
778-
class_id: this.activeClass.id,
779-
role: this.user.role.toUpperCase()
780-
}, config)
773+
if (this.activeClass.id){
774+
const token = localStorage.getItem("nb.user");
775+
const config = { headers: { Authorization: 'Bearer ' + token }, params: { url: this.sourceURL } }
776+
await axios.post(`/api/spotlights/log/session/end`, {
777+
action: 'SESSION_END',
778+
type: 'NONE',
779+
class_id: this.activeClass.id,
780+
role: this.user.role.toUpperCase()
781+
}, config)
782+
}
781783
},
782784
onLogout: async function () {
783785
await this.onSessionEnd()

0 commit comments

Comments
 (0)