fix: get user cookies
Deskripsi: - prefentif undefined value cookies No Issues
This commit is contained in:
@@ -1,12 +1,14 @@
|
|||||||
'use server'
|
'use server'
|
||||||
|
|
||||||
import { pwd_key_config, prisma } from "@/module/_global";
|
import { prisma, pwd_key_config } from "@/module/_global";
|
||||||
import { unsealData } from "iron-session";
|
import { unsealData } from "iron-session";
|
||||||
import { cookies } from "next/headers";
|
import { cookies } from "next/headers";
|
||||||
|
|
||||||
export default async function funGetUserByCookies() {
|
export default async function funGetUserByCookies() {
|
||||||
const sessionCookie = cookies().get("sessionCookieSDM");
|
const sessionCookie = cookies().get("sessionCookieSDM")
|
||||||
const userId : any = await unsealData(sessionCookie!.value, {
|
|
||||||
|
if (sessionCookie != undefined) {
|
||||||
|
const userId: any = await unsealData(sessionCookie.value, {
|
||||||
password: pwd_key_config,
|
password: pwd_key_config,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -38,4 +40,17 @@ export default async function funGetUserByCookies() {
|
|||||||
theme: warna,
|
theme: warna,
|
||||||
showNotification: userId?.showNotification
|
showNotification: userId?.showNotification
|
||||||
};
|
};
|
||||||
|
}else{
|
||||||
|
return {
|
||||||
|
id: undefined,
|
||||||
|
idUserRole: undefined,
|
||||||
|
name: undefined,
|
||||||
|
idVillage: undefined,
|
||||||
|
idGroup: undefined,
|
||||||
|
idPosition: undefined,
|
||||||
|
theme: undefined,
|
||||||
|
showNotification: undefined
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user