Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(be): fix validation logic #94

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class SessionTokenValidationGuard implements CanActivate {
private readonly sessionsAuthRepository: SessionsAuthRepository,
) {}

async canActivate(context: ExecutionContext): Promise<boolean> {
async canActivate(context: ExecutionContext) {
const request = context.switchToHttp().getRequest();
const session_id = request.body?.session_id || request.query?.session_id;
const create_user_token = request.body?.create_user_token || request.query?.create_user_token;
Expand All @@ -29,8 +29,8 @@ export class SessionTokenValidationGuard implements CanActivate {
throw new ForbiddenException('세션이 만료되었습니다.');
}

const token = await this.sessionsAuthRepository.findTokenByToken(session_id, create_user_token);
if (!token) {
const token = await this.sessionsAuthRepository.findByToken(create_user_token);
if (!token || token.session_id !== session_id) {
throw new ForbiddenException('해당 세션에 접근할 권한이 없습니다.');
}

Expand Down
Loading