datasquirel/dist/client/auth/post-login.js
Benjamin Toby 7e8bb37c09 Updates
2025-07-05 14:59:30 +01:00

23 lines
754 B
JavaScript

import getCsrfHeaderName from "../../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
*/
export default function postLogin(res) {
try {
if (!res.payload)
return false;
if (!res.payload.csrf_k)
return false;
localStorage.setItem(getCsrfHeaderName(), res.payload.csrf_k);
localStorage.setItem("user", JSON.stringify(res.payload));
return true;
}
catch (error) {
return false;
}
}