add tanstack/react-query
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
'use server'
|
||||
|
||||
import { SignupFormSchema, loginFormSchema } from '@/app/lib/definitions';
|
||||
import { createSession, deleteSession, getSessionToken } from '@/app/lib/session';
|
||||
import { createSession, deleteSession, getSessionData } from '@/app/lib/session';
|
||||
import { redirect } from 'next/navigation'
|
||||
|
||||
export async function logout() {
|
||||
const token = await getSessionToken();
|
||||
const token = await getSessionData('token');
|
||||
|
||||
try {
|
||||
await fetch('http://localhost:8080/api/auth/logout', {
|
||||
await fetch('http://localhost/api/auth/logout', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@@ -39,7 +39,7 @@ export async function authorization(
|
||||
|
||||
try {
|
||||
const { email, password } = validatedFields.data;
|
||||
const response = await fetch('http://localhost:8080/api/auth/login', {
|
||||
const response = await fetch('http://localhost/api/auth/login', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
@@ -52,7 +52,7 @@ export async function authorization(
|
||||
});
|
||||
if (response.ok) {
|
||||
let parsed = await response.json();
|
||||
await createSession(parsed.token);
|
||||
await createSession(parsed.token, parsed.email);
|
||||
} else {
|
||||
throw new Error('Something went wrong. from server');
|
||||
}
|
||||
@@ -96,7 +96,7 @@ export async function registration(
|
||||
|
||||
try {
|
||||
const { full_name, email, password } = validatedFields.data;
|
||||
const response = await fetch('http://localhost:8080/api/auth/register', {
|
||||
const response = await fetch('http://localhost/api/auth/register', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ fullName: full_name, email, password }),
|
||||
headers: {
|
||||
@@ -107,7 +107,7 @@ export async function registration(
|
||||
|
||||
if (response.ok) {
|
||||
let parsed = await response.json();
|
||||
await createSession(parsed.token);
|
||||
await createSession(parsed.token, email);
|
||||
} else {
|
||||
throw new Error('Something went wrong. from server');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user