Skip to content

Commit

Permalink
fix: improve flow when logging in and there are disabled domains in play
Browse files Browse the repository at this point in the history
  • Loading branch information
niekcandaele committed Oct 28, 2024
1 parent f1940b9 commit acaee9c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/app-api/src/controllers/UserController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class UserController {
}

@Get('/me')
@UseBefore(AuthService.getAuthMiddleware([]))
@UseBefore(AuthService.getAuthMiddleware([], false))
@ResponseSchema(MeOutoutDTOAPI)
@OpenAPI({
summary: 'Get the current logged in user',
Expand Down
5 changes: 3 additions & 2 deletions packages/app-api/src/service/AuthService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Routes, RESTGetAPICurrentUserGuildsResult } from 'discord-api-types/v10
import oauth from 'passport-oauth2';
import { DiscordService } from './DiscordService.js';
import { domainStateMiddleware } from '../middlewares/domainStateMiddleware.js';
import { DomainService } from './DomainService.js';
import { DOMAIN_STATES, DomainService } from './DomainService.js';

interface DiscordUserInfo {
id: string;
Expand Down Expand Up @@ -193,7 +193,8 @@ export class AuthService extends DomainScoped {
log.warn(`No domain found for identity ${identity.id}`);
throw new errors.UnauthorizedError();
}
domainId = domains[0].id;
// Find the first active domain
domainId = domains.find((d) => d.state === DOMAIN_STATES.ACTIVE)?.id;

// Set the domain cookie
if (req.res?.cookie)
Expand Down

0 comments on commit acaee9c

Please sign in to comment.