1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2024-11-01 01:21:15 +01:00
ntfy/web/src/app/Session.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
546 B
JavaScript
Raw Normal View History

2022-12-02 21:37:48 +01:00
class Session {
store(username, token) {
localStorage.setItem("user", username);
localStorage.setItem("token", token);
}
reset() {
localStorage.removeItem("user");
localStorage.removeItem("token");
}
2022-12-26 04:29:55 +01:00
resetAndRedirect(url) {
this.reset();
window.location.href = url;
}
2022-12-08 02:44:20 +01:00
exists() {
return this.username() && this.token();
}
2022-12-02 21:37:48 +01:00
username() {
return localStorage.getItem("user");
}
token() {
return localStorage.getItem("token");
}
}
const session = new Session();
export default session;