File tree Expand file tree Collapse file tree
packages/server/api/src/app Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ export async function getProjectAndToken(
2323 tablesRefreshToken : string ;
2424 projectRole : ProjectMemberRole ;
2525} > {
26- const updatedUser = await userService . getOneOrFail ( { id : user . id } ) ;
26+ const updatedUser = await userService . getOneOrThrow ( { id : user . id } ) ;
2727
2828 const project = await projectService . getOneForUser ( updatedUser ) ;
2929 if ( isNil ( project ) ) {
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ export async function assignDefaultOrganization(user: User): Promise<void> {
3131 organizationId : organization . id ,
3232 } ) ;
3333
34- const updatedUser = await userService . getOneOrFail ( { id : user . id } ) ;
34+ const updatedUser = await userService . getOneOrThrow ( { id : user . id } ) ;
3535 const project = await projectService . getOneForUser ( updatedUser ) ;
3636
3737 if ( isNil ( project ) ) {
Original file line number Diff line number Diff line change @@ -101,8 +101,18 @@ export const userService = {
101101 async get ( { id } : IdParams ) : Promise < User | null > {
102102 return userRepo ( ) . findOneBy ( { id } ) ;
103103 } ,
104- async getOneOrFail ( { id } : IdParams ) : Promise < User > {
105- return userRepo ( ) . findOneByOrFail ( { id } ) ;
104+ async getOneOrThrow ( { id } : IdParams ) : Promise < User > {
105+ const user = await this . get ( { id } ) ;
106+ if ( isNil ( user ) ) {
107+ throw new ApplicationError ( {
108+ code : ErrorCode . ENTITY_NOT_FOUND ,
109+ params : {
110+ entityId : id ,
111+ entityType : 'user' ,
112+ } ,
113+ } ) ;
114+ }
115+ return user ;
106116 } ,
107117
108118 async getDefaultAdmin ( ) : Promise < User | null > {
@@ -201,7 +211,7 @@ export const userService = {
201211 password : hashedPassword ,
202212 } ) ;
203213
204- return userService . getOneOrFail ( { id } ) ;
214+ return userService . getOneOrThrow ( { id } ) ;
205215 } ,
206216
207217 async updateEmail ( { id, newEmail } : UpdateEmailParams ) : Promise < void > {
You can’t perform that action at this time.
0 commit comments