diff options
| author | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2023-04-11 11:06:38 +0700 |
|---|---|---|
| committer | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2023-04-11 11:06:38 +0700 |
| commit | 3df233e0c23e7d4503931ab6ec8ffc41642ac104 (patch) | |
| tree | ccc032defe422f5fafc4a08af672833b2fe41835 /src/core/utils/auth.js | |
| parent | 006c77a85786c24199db157d1d70f48b47311d35 (diff) | |
| parent | f0a720441def88187b3913268238c379362fb9d3 (diff) | |
Merge branch 'master' into development_tri/feedback_UAT
Diffstat (limited to 'src/core/utils/auth.js')
| -rw-r--r-- | src/core/utils/auth.js | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/core/utils/auth.js b/src/core/utils/auth.js index 13e0e79d..cddff2b8 100644 --- a/src/core/utils/auth.js +++ b/src/core/utils/auth.js @@ -1,18 +1,32 @@ import { deleteCookie, getCookie, setCookie } from 'cookies-next' +/** + * Retrieves authentication data from cookie and returns it as an object. + * + * @returns {Object|boolean} - Returns the authentication data as an object if available in cookie, otherwise `false`. + */ const getAuth = () => { let auth = getCookie('auth') - if (auth) { - return JSON.parse(auth) - } + if (auth) return JSON.parse(auth) return false } +/** + * Sets the authentication data in cookie with the given user data. + * + * @param {Object} user - The user data to be set as authentication data in cookie. + * @returns {boolean} - Returns `true`. + */ const setAuth = (user) => { setCookie('auth', JSON.stringify(user)) return true } +/** + * Deletes the authentication data stored in cookie. + * + * @returns {boolean} - Returns `true`. + */ const deleteAuth = () => { deleteCookie('auth') return true |
