Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion addon/services/app-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export default class AppCacheService extends Service {

get cachePrefix() {
const userId = this.currentUser.id ?? 'anon';
return `${userId}:${this.currentUser.companyId}:`;
const companyId = this.currentUser.companyId ?? 'no-org';
return `${userId}:${companyId}:`;
}

@action setEmberData(key, value, except = []) {
Expand Down
51 changes: 26 additions & 25 deletions addon/services/current-user.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,9 @@ export default class CurrentUserService extends Service.extend(Evented) {
async load() {
if (this.session.isAuthenticated) {
const user = await this.store.findRecord('user', 'me');
const snapshot = await this.getUserSnapshot(user);

this.set('user', user);
this.set('userSnapshot', snapshot);
this.trigger('user.loaded', user);

// Set permissions
this.permissions = this.getUserPermissions(user);
// set user
this.setUser(user);

// Load preferences
await this.loadPreferences();
Expand All @@ -91,25 +86,9 @@ export default class CurrentUserService extends Service.extend(Evented) {

try {
const user = await this.store.queryRecord('user', { me: true });
const snapshot = await this.getUserSnapshot(user);

// Set current user
this.set('user', user);
this.set('userSnapshot', snapshot);
this.trigger('user.loaded', user);

// Set permissions
this.permissions = this.getUserPermissions(user);

// Set environment from user option
this.theme.setEnvironment();

// Set locale
if (user.locale) {
this.setLocale(user.locale);
} else {
await this.loadLocale();
}
// set user
this.setUser(user);

// Load user whois data
await this.loadWhois();
Expand Down Expand Up @@ -309,4 +288,26 @@ export default class CurrentUserService extends Service.extend(Evented) {

return defaultValue;
}

async setUser(user) {
const snapshot = await this.getUserSnapshot(user);

// Set current user
this.set('user', user);
this.set('userSnapshot', snapshot);
this.trigger('user.loaded', user);

// Set permissions
this.permissions = this.getUserPermissions(user);

// Set environment from user option
this.theme.setEnvironment();

// Set locale
if (user.locale) {
this.setLocale(user.locale);
} else {
await this.loadLocale();
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fleetbase/ember-core",
"version": "0.3.10",
"version": "0.3.11",
"description": "Provides all the core services, decorators and utilities for building a Fleetbase extension for the Console.",
"keywords": [
"fleetbase-core",
Expand Down
Loading