diff --git a/html/templates/auth/login.html b/html/templates/auth/login.html
index 6ac3901..04c3c7e 100644
--- a/html/templates/auth/login.html
+++ b/html/templates/auth/login.html
@@ -5,8 +5,8 @@
Remember me ?
- Validate
- Cancel
+ Validate
+ Cancel
\ No newline at end of file
diff --git a/html/templates/auth/reg.html b/html/templates/auth/reg.html
index ed9f830..6cdb9be 100644
--- a/html/templates/auth/reg.html
+++ b/html/templates/auth/reg.html
@@ -2,8 +2,8 @@
New Agent
-
-
+
+
Factions
diff --git a/js/controllers/login.js b/js/controllers/login.js
index a6a3cae..b809da2 100644
--- a/js/controllers/login.js
+++ b/js/controllers/login.js
@@ -9,15 +9,15 @@ export default function login(temp_engine) {
temp_engine.after_render((temp_engine) => {
menu_mod(temp_engine);
- temp_engine.add_event("#val", "click", () => {
+ temp_engine.add_event("#btn-login", "click", () => {
const is_checked = $("#box-remember").is(":checked");
const token = $("#in-token").val();
auth.store = is_checked;
auth.login(token)
});
- temp_engine.add_event("#cancel", "click", () => {
- $("#in-token").val("");
+ temp_engine.add_event("#btn-cancel", "click", () => {
+ $("#input-token").val("");
$("#box-remember").prop("checked", false);
});
});
diff --git a/js/controllers/reg.js b/js/controllers/reg.js
index 5ef831b..b9931bb 100644
--- a/js/controllers/reg.js
+++ b/js/controllers/reg.js
@@ -5,11 +5,44 @@ import home from "./home.js";
import menu_mod from "./menu_mod.js";
export default function reg(temp_engine) {
- let auth = new Auth(true);
+ let auth = new Auth();
temp_engine.after_render((temp_engine) => {
menu_mod(temp_engine);
+
+ Faction.list_all((factions) => {
+ factions.forEach(faction => {
+ const option = `${faction.symbol} `;
+ $("#group-faction").append(option);
+ });
+ });
+
+ temp_engine.add_event("#btn-register", "click", () => {
+ const is_checked = $("#box-remember").is(":checked");
+ const symbol = $("#input-name").val();
+ const faction = $("#input-faction").val();
+ auth.store = is_checked;
+ auth.register({name: symbol, faction: faction});
+ });
+
+ temp_engine.add_event("#btn-cancel", "click", () => {
+ $("#input-name").val("");
+ $("#box-remember").prop("checked", false);
+ });
});
+ auth.done((agent) => {
+ My.agent = agent;
+ if(auth.store) localStorage.setItem("token", agent.token);
+ home(temp_engine);
+ });
+
+ auth.fail((errors) => {
+ $(".errors").html("");
+ errors.forEach(error => {
+ $(".errors").append(`${error}
`);
+ });
+ })
+
temp_engine.render(`templates/auth/reg.html`);
}
\ No newline at end of file