re-authenticate api when user data changes (closes #137)

this re-authenticates a bit more often than necessary, but I think it's fine for now
This commit is contained in:
Gwendolyn 2023-12-18 11:44:08 +01:00
parent 6a5097a0b6
commit aa011154ff
2 changed files with 6 additions and 1 deletions

View file

@ -1736,6 +1736,7 @@ c3nav = {
window.location.reload();
},
_set_user_data: function (data) {
c3nav_api.authenticate();
c3nav.user_data = data;
var $user = $('header #user');
$user.find('span').text(data.title);

View file

@ -5,7 +5,11 @@
constructor(base ) {
this.base = base;
this.auth_promise = fetch(this.base+'auth/session/', {
this.auth_promise = this.authenticate();
}
authenticate() {
return fetch(this.base+'auth/session/', {
credentials: 'include',
method: 'GET',
})