Implement authentication and access control

This commit is contained in:
Zaid Abdulla committed 2018-12-26 00:22:07 -08:00
1 parent e1bdcda191
commit 327cb78f1a
27 files changed
+600 -167

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
"use strict";
import m from "mithril";
import * as store from "./store";
import * as notifications from "./notifications";
const userMenu = {
view: () => {
if (window.username)
return m(
"div.user-menu",
window.username,
m(
"button",
{
onclick: e => {
e.target.disabled = true;
store
.logOut()
.then(() => {
location.hash = "";
location.reload();
})
.catch(err => {
e.target.disabled = false;
notifications.push("error", err.message);
});
return false;
}
},
"Log out"
)
);
else
return m(
"div.user-menu",
m(
"a",
{
href: "#!/login?" + m.buildQueryString({ continue: m.route.get() })
},
"Log in"
)
);
}
};
export default userMenu;