ntfy/web/src/app/Session.js

27 lines
513 B
JavaScript
Raw Normal View History

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