PageSourceSearch

https://followeran.com/en/wp-content/themes/onum/custom/helpers/auth-helper.js

js followeran.com collected 2026-09-26 05:54:25 UTC 2,709 bytes, 85 lines download raw bytes

1import {userWalletAPI} from "../api/api-panel.js";
2import Message from "helpers-message-helper";
3import {usersService} from "api-auth";
4
5const message = new Message({stack: 1});
6
7// ========== Get user token ==========
8export const getUserToken = () => {
9    return localStorage.getItem("uwt-en") || null;
10};
11
12// ========== Get user wallet ==========
13export const getWalletBalance = (cb) => {
14    usersService.getWallet({
15        onSuccess: (res) => {
16            const result = res["data"];
17
18            cb(result["wallet"]);
19        },
20        onFailure: ({response}) => {
21            if (response) message.error(response["messages"]["notification"]["text"]);
22            else message.apiError("");
23            logout();
24        }
25    });
26
27    /*const formData = {
28        email: localStorage.getItem("email-en"),
29        user_token: getUserToken()
30    };
31    userWalletAPI(formData, async (isOk, res) => {
32        // ? ---------- Handle Response ----------
33        if (isOk) {
34            res = await res["data"];
35
36            if (res["success"]) {
37                cb(res["message"]["wallet"]);
38            } else if (res["code"] == -1) {
39                // message.warning("Please register to complete the process");
40            } else if (res["code"] == -30) {
41                // message.warning("Please register to complete the process");
42            }
43            // ? ---------- Handle Error ----------
44        } else {
45            message.apiError();
46        }
47    });*/
48};
49
50// ========== Get user profile ==========
51export const getUserProfile = () => {
52    return {
53        fullname: localStorage.getItem("fullname-en") || "Not Set",
54        email: localStorage.getItem("email-en"),
55        utw: localStorage.getItem("uwt-en"),
56    };
57};
58
59// ========== Is authenticated ==========
60export const isAuthenticated = (e) => {
61    return (localStorage.getItem("email-en") && localStorage.getItem("uwt-en"));
62};
63
64// ========== Is not authenticated ==========
65export const isNotAuthenticated = (e) => {
66    return (!localStorage.getItem("email-en") || !localStorage.getItem("uwt-en"));
67};
68
69// ========== Logout ==========
70export const logout = () => {
71    localStorage.removeItem("email-en");
72    localStorage.removeItem("uwt-en");
73    localStorage.removeItem("fullname-en");
74    localStorage.removeItem("user_wallet-en");
75
76    google.accounts.id.disableAutoSelect();
77    localStorage.removeItem("userAccount");
78    localStorage.removeItem("onTabSignInGoogle");
79
80    if (location.href.includes("/my-account")) {
81        location.href = jQuery(document).config("baseUrl");
82    } else {
83        location.reload();
84    }
85};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.