mirror of
https://github.com/documize/community.git
synced 2025-08-02 20:15:26 +02:00
authConfig persistence bug, session vars bug
This commit is contained in:
parent
585c4468c1
commit
6f98db5c29
8 changed files with 693 additions and 660 deletions
|
@ -30,16 +30,20 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
|||
authConfig: null,
|
||||
};
|
||||
|
||||
switch (data.authProvider) {
|
||||
case constants.AuthProvider.Keycloak:
|
||||
data.authConfig = this.get('appMeta.authConfig');
|
||||
break;
|
||||
case constants.AuthProvider.Documize:
|
||||
data.authConfig = '';
|
||||
break;
|
||||
}
|
||||
return new Ember.RSVP.Promise((resolve) => {
|
||||
this.get('global').getAuthConfig().then((config) => {
|
||||
switch (data.authProvider) {
|
||||
case constants.AuthProvider.Keycloak:
|
||||
data.authConfig = config;
|
||||
break;
|
||||
case constants.AuthProvider.Documize:
|
||||
data.authConfig = '';
|
||||
break;
|
||||
}
|
||||
|
||||
return data;
|
||||
resolve(data);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
activate() {
|
||||
|
|
|
@ -65,6 +65,17 @@ export default Ember.Service.extend({
|
|||
}
|
||||
},
|
||||
|
||||
// Returns auth config for Documize instance.
|
||||
getAuthConfig() {
|
||||
if(this.get('sessionService.isGlobalAdmin')) {
|
||||
return this.get('ajax').request(`global/auth`, {
|
||||
method: 'GET'
|
||||
}).then((response) => {
|
||||
return response;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Saves auth config for Documize instance.
|
||||
saveAuthConfig(config) {
|
||||
if(this.get('sessionService.isGlobalAdmin')) {
|
||||
|
|
|
@ -26,20 +26,25 @@ export default SimpleAuthSession.extend({
|
|||
currentFolder: null,
|
||||
isMac: false,
|
||||
isMobile: false,
|
||||
authenticated: computed('user.id', function () {
|
||||
return this.get('user.id') !== '0';
|
||||
|
||||
user: computed('isAuthenticated', 'session.content.authenticated.user', function () {
|
||||
if (this.get('isAuthenticated')) {
|
||||
let user = this.get('session.content.authenticated.user') || { id: '' };
|
||||
let data = this.get('store').normalize('user', user);
|
||||
return this.get('store').push(data);
|
||||
}
|
||||
}),
|
||||
isAdmin: computed('user', function () {
|
||||
let data = this.get('user');
|
||||
return data.get('admin');
|
||||
authenticated: computed('session.content.authenticated.user', function () {
|
||||
return this.get('session.content.authenticated.user.id') !== '0';
|
||||
}),
|
||||
isEditor: computed('user', function () {
|
||||
let data = this.get('user');
|
||||
return data.get('editor');
|
||||
isAdmin: computed('session.content.authenticated.user', function () {
|
||||
return this.get('session.content.authenticated.user.admin') === true;
|
||||
}),
|
||||
isGlobalAdmin: computed('user', function () {
|
||||
let data = this.get('user');
|
||||
return data.get('global');
|
||||
isEditor: computed('session.content.authenticated.user', function () {
|
||||
return this.get('session.content.authenticated.user.editor') === true;
|
||||
}),
|
||||
isGlobalAdmin: computed('session.content.authenticated.user', function () {
|
||||
return this.get('session.content.authenticated.user.global') === true;
|
||||
}),
|
||||
|
||||
init() {
|
||||
|
@ -49,14 +54,6 @@ export default SimpleAuthSession.extend({
|
|||
this.set('isMobile', is.mobile());
|
||||
},
|
||||
|
||||
user: computed('isAuthenticated', 'session.content.authenticated.user', function () {
|
||||
if (this.get('isAuthenticated')) {
|
||||
let user = this.get('session.content.authenticated.user') || { id: '' };
|
||||
let data = this.get('store').normalize('user', user);
|
||||
return this.get('store').push(data);
|
||||
}
|
||||
}),
|
||||
|
||||
logout() {
|
||||
this.get('localStorage').clearAll();
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
"ember-export-application-global": "^1.0.5",
|
||||
"ember-load-initializers": "^0.6.0",
|
||||
"ember-resolver": "^2.0.3",
|
||||
"ember-simple-auth": "1.2.0",
|
||||
"ember-simple-auth": "1.2.2",
|
||||
"ember-source": "~2.12.0",
|
||||
"loader.js": "^4.2.3"
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue