## Summary - [x] Remove defaultWorkspace in user - [x] Remove all occurrence of defaultWorkspace and defaultWorkspaceId - [x] Improve activate workspace flow - [x] Improve security on social login - [x] Add `ImpersonateGuard` - [x] Allow to use impersonation with couple `User/Workspace` - [x] Prevent unexpected reload on activate workspace - [x] Scope login token with workspaceId Fix https://github.com/twentyhq/twenty/issues/9033#event-15714863042
16 lines
464 B
TypeScript
16 lines
464 B
TypeScript
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
import { GqlExecutionContext } from '@nestjs/graphql';
|
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
export class ImpersonateGuard implements CanActivate {
|
|
canActivate(
|
|
context: ExecutionContext,
|
|
): boolean | Promise<boolean> | Observable<boolean> {
|
|
const ctx = GqlExecutionContext.create(context);
|
|
const request = ctx.getContext().req;
|
|
|
|
return request.user.canImpersonate === true;
|
|
}
|
|
}
|