fix(auth): send login token in POST body

This commit is contained in:
Orvanix
2026-03-12 17:15:07 +00:00
parent b20673e7ea
commit 81712ad3ce
4 changed files with 20 additions and 15 deletions
+2 -2
View File
@@ -11,9 +11,9 @@ import crypto from 'crypto';
const logger = RMABLogger.create('API.Auth.TokenLogin');
export async function GET(request: NextRequest) {
export async function POST(request: NextRequest) {
try {
const token = request.nextUrl.searchParams.get('token');
const { token } = await request.json();
if (!token) {
return NextResponse.json({ error: 'Missing token parameter' }, { status: 400 });
+6 -2
View File
@@ -22,7 +22,11 @@ function TokenLoginContent() {
return;
}
fetch(`/api/auth/token/login?token=${encodeURIComponent(token)}`)
fetch('/api/auth/token/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ token }),
})
.then((res) => res.json())
.then((data) => {
if (data.error) {
@@ -35,7 +39,7 @@ function TokenLoginContent() {
localStorage.setItem('user', JSON.stringify(data.user));
setAuthData(data.user, data.accessToken);
window.location.href = '/';
window.location.href = '/';
})
.catch(() => {
router.replace('/login');