Skip to content

Commit

Permalink
CB-3995 move anonymous id to const (#2292)
Browse files Browse the repository at this point in the history
Co-authored-by: Daria Marutkina <[email protected]>
  • Loading branch information
devnaumov and dariamarutkina authored Jan 12, 2024
1 parent f463ea5 commit 2bd727a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion webapp/packages/core-authentication/src/UserInfoResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export interface ILoginOptions {
linkUser?: boolean;
}

export const ANONYMOUS_USER_ID = 'anonymous';

@injectable()
export class UserInfoResource extends CachedDataResource<UserInfo | null, void, UserInfoIncludes> {
readonly onUserChange: ISyncExecutor<string>;
Expand Down Expand Up @@ -66,7 +68,7 @@ export class UserInfoResource extends CachedDataResource<UserInfo | null, void,
}

getId(): string {
return this.data?.userId || 'anonymous';
return this.data?.userId || ANONYMOUS_USER_ID;
}

hasToken(providerId: string): boolean {
Expand Down
4 changes: 2 additions & 2 deletions webapp/packages/core-projects/src/ProjectsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import { computed, makeObservable } from 'mobx';

import { UserDataService, UserInfoResource } from '@cloudbeaver/core-authentication';
import { ANONYMOUS_USER_ID, UserDataService, UserInfoResource } from '@cloudbeaver/core-authentication';
import { Dependency, injectable } from '@cloudbeaver/core-di';
import { Executor, ExecutorInterrupter, IExecutor, ISyncExecutor, SyncExecutor } from '@cloudbeaver/core-executor';
import { CachedMapAllKey, resourceKeyList, ResourceKeyUtils } from '@cloudbeaver/core-resource';
Expand Down Expand Up @@ -36,7 +36,7 @@ export class ProjectsService extends Dependency {
if (this.userInfoResource.data) {
project = this.projectInfoResource.getUserProject(this.userInfoResource.data.userId);
} else {
project = this.projectInfoResource.get('anonymous');
project = this.projectInfoResource.get(ANONYMOUS_USER_ID);
}

return project;
Expand Down

0 comments on commit 2bd727a

Please sign in to comment.