Updates
This commit is contained in:
parent
7551749784
commit
2118a55ab6
20
client/auth/post-login.ts
Normal file
20
client/auth/post-login.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { APILoginFunctionReturn } from "../../package-shared/types";
|
||||
|
||||
/**
|
||||
* 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: APILoginFunctionReturn): boolean {
|
||||
try {
|
||||
if (!res.payload) return false;
|
||||
if (!res.payload.csrf_k) return false;
|
||||
localStorage.setItem("csrf", res.payload.csrf_k);
|
||||
localStorage.setItem("user", JSON.stringify(res.payload));
|
||||
return true;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -11,14 +11,8 @@ import serializeCookies from "../package-shared/utils/serialize-cookies";
|
||||
import EJSON from "../package-shared/utils/ejson";
|
||||
import numberfy from "../package-shared/utils/numberfy";
|
||||
import slugify from "../package-shared/utils/slugify";
|
||||
import postLogin from "./auth/post-login";
|
||||
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Media Functions Object
|
||||
*/
|
||||
const media = {
|
||||
imageInputToBase64: imageInputToBase64,
|
||||
imageInputFileToBase64: imageInputFileToBase64,
|
||||
@ -35,7 +29,8 @@ const auth = {
|
||||
github: {
|
||||
getAccessToken: getGithubAccessToken,
|
||||
},
|
||||
logout: logout,
|
||||
logout,
|
||||
postLogin,
|
||||
};
|
||||
|
||||
const utils = {
|
||||
|
9
dist/client/auth/post-login.d.ts
vendored
Normal file
9
dist/client/auth/post-login.d.ts
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
import { APILoginFunctionReturn } from "../../package-shared/types";
|
||||
/**
|
||||
* 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: APILoginFunctionReturn): boolean;
|
24
dist/client/auth/post-login.js
vendored
Normal file
24
dist/client/auth/post-login.js
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = postLogin;
|
||||
/**
|
||||
* 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("csrf", res.payload.csrf_k);
|
||||
localStorage.setItem("user", JSON.stringify(res.payload));
|
||||
return true;
|
||||
}
|
||||
catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
2
dist/client/index.d.ts
vendored
2
dist/client/index.d.ts
vendored
@ -9,6 +9,7 @@ import serializeQuery from "../package-shared/utils/serialize-query";
|
||||
import serializeCookies from "../package-shared/utils/serialize-cookies";
|
||||
import numberfy from "../package-shared/utils/numberfy";
|
||||
import slugify from "../package-shared/utils/slugify";
|
||||
import postLogin from "./auth/post-login";
|
||||
/**
|
||||
* Main Export
|
||||
*/
|
||||
@ -26,6 +27,7 @@ declare const datasquirelClient: {
|
||||
getAccessToken: typeof getGithubAccessToken;
|
||||
};
|
||||
logout: typeof logout;
|
||||
postLogin: typeof postLogin;
|
||||
};
|
||||
fetch: {
|
||||
fetchApi: typeof fetchApi;
|
||||
|
8
dist/client/index.js
vendored
8
dist/client/index.js
vendored
@ -16,12 +16,7 @@ const serialize_cookies_1 = __importDefault(require("../package-shared/utils/ser
|
||||
const ejson_1 = __importDefault(require("../package-shared/utils/ejson"));
|
||||
const numberfy_1 = __importDefault(require("../package-shared/utils/numberfy"));
|
||||
const slugify_1 = __importDefault(require("../package-shared/utils/slugify"));
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
/**
|
||||
* Media Functions Object
|
||||
*/
|
||||
const post_login_1 = __importDefault(require("./auth/post-login"));
|
||||
const media = {
|
||||
imageInputToBase64: imageInputToBase64_1.default,
|
||||
imageInputFileToBase64: imageInputFileToBase64_1.default,
|
||||
@ -38,6 +33,7 @@ const auth = {
|
||||
getAccessToken: getAccessToken_2.default,
|
||||
},
|
||||
logout: logout_1.default,
|
||||
postLogin: post_login_1.default,
|
||||
};
|
||||
const utils = {
|
||||
serializeQuery: serialize_query_1.default,
|
||||
|
1
dist/index.d.ts
vendored
1
dist/index.d.ts
vendored
@ -76,6 +76,7 @@ declare const datasquirel: {
|
||||
getAccessToken: typeof import("./client/auth/github/getAccessToken").default;
|
||||
};
|
||||
logout: typeof import("./client/auth/logout").default;
|
||||
postLogin: typeof import("./client/auth/post-login").default;
|
||||
};
|
||||
fetch: {
|
||||
fetchApi: typeof import("./client/fetch").default;
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@moduletrace/datasquirel",
|
||||
"version": "3.4.6",
|
||||
"version": "3.4.7",
|
||||
"description": "Cloud-based SQL data management tool",
|
||||
"main": "dist/index.js",
|
||||
"bin": {
|
||||
|
Loading…
Reference in New Issue
Block a user