Skip to content

Commit

Permalink
Added missing file
Browse files Browse the repository at this point in the history
  • Loading branch information
umerfaruk committed Aug 13, 2024
1 parent 49bdc16 commit 5520543
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/domain/repositories/userRepository.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { isJsonString } from "../../helpers";
import Cookies from "js-cookie";

var remove_sub_domain = function (v) {
var is_co = v.match(/\.co\./);
v = v.split(".");
v = v.slice(is_co ? -3 : -2);
v = v.join(".");
return v;
};

var domain = remove_sub_domain(window.location.hostname);

export const getUser = () => {
var userCookie = Cookies.get("user", { domain: domain });
if (userCookie && isJsonString(userCookie)) {
return JSON.parse(userCookie);
}
return null;
};

export const setUser = (user) => {
Cookies.set("user", JSON.stringify(user), {
domain: domain,
});
};

export const clearUser = () => {
Cookies.remove("user", { domain: domain });
};

0 comments on commit 5520543

Please sign in to comment.