Fix sign in
This commit is contained in:
parent
8d88779918
commit
90861effb4
@ -6,6 +6,8 @@ const storage = require("../localStorage");
|
||||
const utils = require("../utils");
|
||||
const templates = require("../../views");
|
||||
|
||||
const login = $("#sign-in").html(templates.windows.sign_in());
|
||||
|
||||
socket.on("auth", function(data) {
|
||||
// If we reconnected and serverHash differs, that means the server restarted
|
||||
// And we will reload the page to grab the latest version
|
||||
@ -21,10 +23,24 @@ socket.on("auth", function(data) {
|
||||
let token;
|
||||
const user = storage.get("user");
|
||||
|
||||
const login = $("#sign-in")
|
||||
.html(templates.windows.sign_in())
|
||||
.find(".btn")
|
||||
.prop("disabled", false);
|
||||
login.find(".btn").prop("disabled", false);
|
||||
|
||||
login.find("form").on("submit", function() {
|
||||
const form = $(this);
|
||||
|
||||
form.find(".btn").attr("disabled", true);
|
||||
|
||||
const values = {};
|
||||
$.each(form.serializeArray(), function(i, obj) {
|
||||
values[obj.name] = obj.value;
|
||||
});
|
||||
|
||||
storage.set("user", values.user);
|
||||
|
||||
socket.emit("auth", values);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
if (!data.success) {
|
||||
if (login.length === 0) {
|
||||
|
@ -24,10 +24,9 @@ socket.on("configuration", function(data) {
|
||||
options.initialize();
|
||||
webpush.initialize();
|
||||
|
||||
// TODO: #sign-in needs to be handled in auth.js otherwise its broken
|
||||
const forms = $("#sign-in, #connect, #change-password");
|
||||
const forms = $("#connect form, #change-password form");
|
||||
|
||||
forms.on("submit", "form", function() {
|
||||
forms.on("submit", function() {
|
||||
const form = $(this);
|
||||
const event = form.data("event");
|
||||
|
||||
@ -40,22 +39,18 @@ socket.on("configuration", function(data) {
|
||||
}
|
||||
});
|
||||
|
||||
if (values.user) {
|
||||
storage.set("user", values.user);
|
||||
}
|
||||
|
||||
socket.emit(event, values);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
forms.on("focusin", ".nick", function() {
|
||||
$(".nick")
|
||||
.on("focusin", function() {
|
||||
// Need to set the first "lastvalue", so it can be used in the below function
|
||||
const nick = $(this);
|
||||
nick.data("lastvalue", nick.val());
|
||||
});
|
||||
|
||||
forms.on("input", ".nick", function() {
|
||||
})
|
||||
.on("input", function() {
|
||||
const nick = $(this).val();
|
||||
const usernameInput = forms.find(".username");
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
<form class="container" method="post" action="" data-event="auth">
|
||||
<form class="container" method="post" action="">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<h1 class="title">Sign in to The Lounge</h1>
|
||||
|
Loading…
Reference in New Issue
Block a user