same thing continues to happen. I cant change credentials... please debo
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
import db from '@/lib/db';
|
import db from '@/lib/db';
|
||||||
import type { User } from '@/lib/types';
|
import type { User } from '@/lib/types';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { auth } from '@/app/api/auth/[...nextauth]/route';
|
import { auth } from '@/lib/auth';
|
||||||
|
|
||||||
const UserUpdateSchema = z.object({
|
const UserUpdateSchema = z.object({
|
||||||
name: z.string().min(1, 'Name is required'),
|
name: z.string().min(1, 'Name is required'),
|
||||||
@@ -46,8 +46,8 @@ export async function updateUser(
|
|||||||
const { name, email, password } = validated.data;
|
const { name, email, password } = validated.data;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// In a real application, you should hash the password!
|
||||||
if (password && password.trim().length > 0) {
|
if (password && password.trim().length > 0) {
|
||||||
// In a real application, hash the password
|
|
||||||
const stmt = db.prepare(
|
const stmt = db.prepare(
|
||||||
'UPDATE users SET name = ?, email = ?, password = ? WHERE id = ?'
|
'UPDATE users SET name = ?, email = ?, password = ? WHERE id = ?'
|
||||||
);
|
);
|
||||||
|
|||||||
+5
-1
@@ -1,7 +1,11 @@
|
|||||||
|
|
||||||
'use server';
|
'use server';
|
||||||
import { signOut as nextAuthSignOut } from '@/app/api/auth/[...nextauth]/route';
|
import { signOut as nextAuthSignOut, auth as nextAuth } from '@/app/api/auth/[...nextauth]/route';
|
||||||
|
|
||||||
export async function signOut() {
|
export async function signOut() {
|
||||||
await nextAuthSignOut({ redirectTo: '/login' });
|
await nextAuthSignOut({ redirectTo: '/login' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function auth() {
|
||||||
|
return nextAuth();
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user