feat: refine navigation and account access flow
This commit is contained in:
+8
-4
@@ -93,6 +93,13 @@ async function authPlugin(fastify, { config, googleClient } = {}) {
|
||||
path: '/',
|
||||
},
|
||||
});
|
||||
|
||||
fastify.get('/auth/google/select-account', async (request, reply) => {
|
||||
const authorizationUri = await fastify.googleOAuth2.generateAuthorizationUri(request, reply);
|
||||
const url = new URL(authorizationUri);
|
||||
url.searchParams.set('prompt', 'select_account');
|
||||
return reply.redirect(url.href);
|
||||
});
|
||||
} else {
|
||||
fastify.get('/auth/google', async () => {
|
||||
throw new AppError('Google OAuth가 설정되지 않았습니다.', {
|
||||
@@ -133,10 +140,7 @@ async function authPlugin(fastify, { config, googleClient } = {}) {
|
||||
}
|
||||
const allowedAccount = await fastify.allowedEmailRepository.findByEmail(payload.email);
|
||||
if (!allowedAccount) {
|
||||
throw new AppError('허용되지 않은 Google 계정입니다.', {
|
||||
statusCode: 403,
|
||||
code: 'GOOGLE_EMAIL_NOT_ALLOWED',
|
||||
});
|
||||
return reply.redirect('/login?error=account-not-allowed');
|
||||
}
|
||||
|
||||
const user = await fastify.userRepository.upsertGoogleUser({
|
||||
|
||||
Reference in New Issue
Block a user