fix(auth): improve query to find invitation (#9743)
This commit is contained in:
@ -70,7 +70,6 @@ export class GoogleAuthController {
|
|||||||
currentWorkspace && workspacePersonalInviteToken && email
|
currentWorkspace && workspacePersonalInviteToken && email
|
||||||
? await this.authService.findInvitationForSignInUp({
|
? await this.authService.findInvitationForSignInUp({
|
||||||
currentWorkspace,
|
currentWorkspace,
|
||||||
workspacePersonalInviteToken,
|
|
||||||
email,
|
email,
|
||||||
})
|
})
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|||||||
@ -68,7 +68,6 @@ export class MicrosoftAuthController {
|
|||||||
currentWorkspace && workspacePersonalInviteToken && email
|
currentWorkspace && workspacePersonalInviteToken && email
|
||||||
? await this.authService.findInvitationForSignInUp({
|
? await this.authService.findInvitationForSignInUp({
|
||||||
currentWorkspace,
|
currentWorkspace,
|
||||||
workspacePersonalInviteToken,
|
|
||||||
email,
|
email,
|
||||||
})
|
})
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|||||||
@ -475,35 +475,29 @@ export class AuthService {
|
|||||||
return url.toString();
|
return url.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
async findInvitationForSignInUp({
|
async findInvitationForSignInUp(
|
||||||
currentWorkspace,
|
params: {
|
||||||
workspacePersonalInviteToken,
|
currentWorkspace: Workspace;
|
||||||
email,
|
} & ({ workspacePersonalInviteToken: string } | { email: string }),
|
||||||
}: {
|
) {
|
||||||
currentWorkspace: Workspace | null;
|
|
||||||
workspacePersonalInviteToken?: string;
|
|
||||||
email?: string;
|
|
||||||
}) {
|
|
||||||
if (!currentWorkspace || !workspacePersonalInviteToken) return undefined;
|
|
||||||
|
|
||||||
const qr = this.appTokenRepository
|
const qr = this.appTokenRepository
|
||||||
.createQueryBuilder('appToken')
|
.createQueryBuilder('appToken')
|
||||||
.where('"appToken"."workspaceId" = :workspaceId', {
|
.where('"appToken"."workspaceId" = :workspaceId', {
|
||||||
workspaceId: currentWorkspace.id,
|
workspaceId: params.currentWorkspace.id,
|
||||||
})
|
})
|
||||||
.andWhere('"appToken".type = :type', {
|
.andWhere('"appToken".type = :type', {
|
||||||
type: AppTokenType.InvitationToken,
|
type: AppTokenType.InvitationToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (workspacePersonalInviteToken) {
|
if ('workspacePersonalInviteToken' in params) {
|
||||||
qr.andWhere('"appToken".value = :personalInviteToken', {
|
qr.andWhere('"appToken".value = :personalInviteToken', {
|
||||||
personalInviteToken: workspacePersonalInviteToken,
|
personalInviteToken: params.workspacePersonalInviteToken,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (email) {
|
if ('email' in params) {
|
||||||
qr.andWhere('"appToken".context->>\'email\' = :email', {
|
qr.andWhere('"appToken".context->>\'email\' = :email', {
|
||||||
email,
|
email: params.email,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user