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 utils = require("../utils");
|
||||||
const templates = require("../../views");
|
const templates = require("../../views");
|
||||||
|
|
||||||
|
const login = $("#sign-in").html(templates.windows.sign_in());
|
||||||
|
|
||||||
socket.on("auth", function(data) {
|
socket.on("auth", function(data) {
|
||||||
// If we reconnected and serverHash differs, that means the server restarted
|
// If we reconnected and serverHash differs, that means the server restarted
|
||||||
// And we will reload the page to grab the latest version
|
// And we will reload the page to grab the latest version
|
||||||
@ -21,10 +23,24 @@ socket.on("auth", function(data) {
|
|||||||
let token;
|
let token;
|
||||||
const user = storage.get("user");
|
const user = storage.get("user");
|
||||||
|
|
||||||
const login = $("#sign-in")
|
login.find(".btn").prop("disabled", false);
|
||||||
.html(templates.windows.sign_in())
|
|
||||||
.find(".btn")
|
login.find("form").on("submit", function() {
|
||||||
.prop("disabled", false);
|
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 (!data.success) {
|
||||||
if (login.length === 0) {
|
if (login.length === 0) {
|
||||||
|
@ -24,10 +24,9 @@ socket.on("configuration", function(data) {
|
|||||||
options.initialize();
|
options.initialize();
|
||||||
webpush.initialize();
|
webpush.initialize();
|
||||||
|
|
||||||
// TODO: #sign-in needs to be handled in auth.js otherwise its broken
|
const forms = $("#connect form, #change-password form");
|
||||||
const forms = $("#sign-in, #connect, #change-password");
|
|
||||||
|
|
||||||
forms.on("submit", "form", function() {
|
forms.on("submit", function() {
|
||||||
const form = $(this);
|
const form = $(this);
|
||||||
const event = form.data("event");
|
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);
|
socket.emit(event, values);
|
||||||
|
|
||||||
return false;
|
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
|
// Need to set the first "lastvalue", so it can be used in the below function
|
||||||
const nick = $(this);
|
const nick = $(this);
|
||||||
nick.data("lastvalue", nick.val());
|
nick.data("lastvalue", nick.val());
|
||||||
});
|
})
|
||||||
|
.on("input", function() {
|
||||||
forms.on("input", ".nick", function() {
|
|
||||||
const nick = $(this).val();
|
const nick = $(this).val();
|
||||||
const usernameInput = forms.find(".username");
|
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="row">
|
||||||
<div class="col-xs-12">
|
<div class="col-xs-12">
|
||||||
<h1 class="title">Sign in to The Lounge</h1>
|
<h1 class="title">Sign in to The Lounge</h1>
|
||||||
|
Loading…
Reference in New Issue
Block a user