summaryrefslogtreecommitdiff
path: root/src/helpers/auth.js
diff options
context:
space:
mode:
authorRafi Zadanly <rafizadanly@gmail.com>2022-11-17 17:28:31 +0700
committerRafi Zadanly <rafizadanly@gmail.com>2022-11-17 17:28:31 +0700
commitb01a5a7de6303c2752358f970e8d71daa1a16596 (patch)
tree6e3be86e0669096e1657e388f900ead4011f679d /src/helpers/auth.js
parent8f9d12c64ff25e0065439d769fe79ec416bc3df8 (diff)
Auth component and cookie function
Diffstat (limited to 'src/helpers/auth.js')
-rw-r--r--src/helpers/auth.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/helpers/auth.js b/src/helpers/auth.js
new file mode 100644
index 00000000..4504564c
--- /dev/null
+++ b/src/helpers/auth.js
@@ -0,0 +1,25 @@
+import { deleteCookie, getCookie, setCookie } from 'cookies-next';
+
+const getAuth = () => {
+ let auth = getCookie('auth');
+ if (auth) {
+ return JSON.parse(auth);
+ }
+ return false;
+}
+
+const setAuth = (user) => {
+ setCookie('auth', JSON.stringify(user));
+ return true;
+}
+
+const deleteAuth = () => {
+ deleteCookie('auth');
+ return true;
+}
+
+export {
+ getAuth,
+ setAuth,
+ deleteAuth
+}; \ No newline at end of file