File tree Expand file tree Collapse file tree
server/api/src/app/authentication Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,7 +3,10 @@ import { AuthenticationResponse } from '@openops/shared';
33import { userService } from '../../user/user-service' ;
44import { getProjectAndToken } from '../context/create-project-auth-context' ;
55import { createUser } from '../new-user/create-user' ;
6- import { assignDefaultOrganization } from '../new-user/organization-assignment' ;
6+ import {
7+ addUserToDefaultWorkspace ,
8+ assignDefaultOrganization ,
9+ } from '../new-user/organization-assignment' ;
710import { SignInParams , SignUpParams } from '../types' ;
811import {
912 assertPasswordMatches ,
@@ -17,6 +20,8 @@ export const authenticationService = {
1720
1821 await assignDefaultOrganization ( user ) ;
1922
23+ await addUserToDefaultWorkspace ( user ) ;
24+
2025 const projectContext = await getProjectAndToken ( user , tablesRefreshToken ) ;
2126 return buildAuthResponse ( projectContext ) ;
2227 } ,
Original file line number Diff line number Diff line change @@ -30,9 +30,10 @@ export async function assignDefaultOrganization(user: User): Promise<void> {
3030 id : user . id ,
3131 organizationId : organization . id ,
3232 } ) ;
33+ }
3334
34- const updatedUser = await userService . getOneOrThrow ( { id : user . id } ) ;
35- const project = await projectService . getOneForUser ( updatedUser ) ;
35+ export async function addUserToDefaultWorkspace ( user : User ) : Promise < void > {
36+ const project = await projectService . getOneForUser ( user ) ;
3637
3738 if ( isNil ( project ) ) {
3839 throw new ApplicationError ( {
@@ -43,19 +44,10 @@ export async function assignDefaultOrganization(user: User): Promise<void> {
4344 } ) ;
4445 }
4546
46- await addUserToDefaultWorkspace ( {
47- email : user . email ,
48- workspaceId : project . tablesWorkspaceId ,
49- } ) ;
50- }
51-
52- async function addUserToDefaultWorkspace ( values : {
53- email : string ;
54- workspaceId : number ;
55- } ) : Promise < void > {
5647 const { token : defaultToken } = await authenticateAdminUserInOpenOpsTables ( ) ;
5748
5849 await openopsTables . addUserToWorkspace ( defaultToken , {
59- ...values ,
50+ email : user . email ,
51+ workspaceId : project . tablesWorkspaceId ,
6052 } ) ;
6153}
Original file line number Diff line number Diff line change @@ -42,6 +42,10 @@ export const User = Type.Object({
4242
4343export type User = Static < typeof User > ;
4444
45+ export type UserWithOrganization = User & {
46+ organizationId : OpenOpsId ;
47+ } ;
48+
4549export const UserMeta = Type . Object ( {
4650 id : Type . String ( ) ,
4751 email : Type . String ( ) ,
You can’t perform that action at this time.
0 commit comments