feat: login with github

This commit is contained in:
Nevo David 2024-07-05 15:22:33 +07:00
parent 11b6ac693c
commit be868c1ca5
1 changed files with 2 additions and 2 deletions

View File

@ -30,9 +30,9 @@ export async function middleware(request: NextRequest) {
const url = new URL(nextUrl).search;
if (nextUrl.href.indexOf('/auth') === -1 && !authCookie) {
const providers = ['google', 'github'];
const providers = ['google', 'settings'];
const findIndex = providers.find(p => nextUrl.href.indexOf(p) > -1);
const additional = !findIndex ? '' : (url.indexOf('?') > -1 ? '&' : '?') + `provider=${findIndex.toUpperCase()}`;
const additional = !findIndex ? '' : (url.indexOf('?') > -1 ? '&' : '?') + `provider=${(findIndex === 'settings' ? 'github' : findIndex).toUpperCase()}`;
return NextResponse.redirect(new URL(`/auth${url}${additional}`, nextUrl.href));
}