generated from fahricansecer/boilerplate-fe
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import baseUrl from "@/config/base-url";
|
||||
import { authService } from "@/lib/api/example/auth/service";
|
||||
import { authApi } from "@/lib/api/api-service";
|
||||
import NextAuth from "next-auth";
|
||||
import Credentials from "next-auth/providers/credentials";
|
||||
|
||||
@@ -38,22 +37,19 @@ const handler = NextAuth({
|
||||
}
|
||||
|
||||
// Normal mod: backend'e istek at
|
||||
const res = await authService.login({
|
||||
const res = await authApi.login({
|
||||
email: credentials.email,
|
||||
password: credentials.password,
|
||||
});
|
||||
|
||||
console.log("res", res);
|
||||
|
||||
const response = res;
|
||||
|
||||
// Backend returns ApiResponse<TokenResponseDto>
|
||||
// Structure: { data: { accessToken, refreshToken, expiresIn, user }, message, statusCode }
|
||||
if (!res.success || !response?.data?.accessToken) {
|
||||
throw new Error(response?.message || "Giriş başarısız");
|
||||
// Axios interceptor otomatik unwrap yapıyor:
|
||||
// Backend { success, data: { accessToken, refreshToken, user } } sarıyor
|
||||
// Interceptor sonrası res = { accessToken, refreshToken, user }
|
||||
if (!res?.accessToken) {
|
||||
throw new Error("Giriş başarısız");
|
||||
}
|
||||
|
||||
const { accessToken, refreshToken, user } = response.data;
|
||||
const { accessToken, refreshToken, user } = res;
|
||||
|
||||
return {
|
||||
id: user.id,
|
||||
|
||||
Reference in New Issue
Block a user