datasquirel/dist/client/auth/post-login.js
Benjamin Toby cc29a3c107 Updates
2025-05-04 19:13:19 +01:00

29 lines
1.0 KiB
JavaScript

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = postLogin;
const get_csrf_header_name_1 = __importDefault(require("../../package-shared/actions/get-csrf-header-name"));
/**
* Client Setup After Login
* ===============================================================================
* @description This function sets local storage variables like `csrf` after a user
* is logged in. Use this in conjunction with the `datasquirel.user.loginUser`
* function
*/
function postLogin(res) {
try {
if (!res.payload)
return false;
if (!res.payload.csrf_k)
return false;
localStorage.setItem((0, get_csrf_header_name_1.default)(), res.payload.csrf_k);
localStorage.setItem("user", JSON.stringify(res.payload));
return true;
}
catch (error) {
return false;
}
}