Show authentication errors

This commit is contained in:
Mattias Erming 2014-07-25 04:36:09 -07:00
parent c341d7a0b6
commit c484b83aca
5 changed files with 24 additions and 4 deletions

View File

@ -541,6 +541,10 @@ button {
#sign-in .btn { #sign-in .btn {
margin-top: 25px; margin-top: 25px;
} }
#sign-in .error {
color: #e74c3c;
margin-top: 1em;
}
#connect label { #connect label {
display: block; display: block;
margin-top: 10px; margin-top: 10px;

View File

@ -15,7 +15,7 @@
<link rel="shortcut icon" href="/img/favicon.png"> <link rel="shortcut icon" href="/img/favicon.png">
</head> </head>
<body class="<%= public ? "public" : "signed-out" %>"> <body class="<%= public ? "public" : "" %>">
<div id="wrap"> <div id="wrap">
<div id="viewport"> <div id="viewport">
@ -57,6 +57,9 @@
<input class="input" type="password" name="password"> <input class="input" type="password" name="password">
</label> </label>
</div> </div>
<div class="col-xs-12 error" style="display: none;">
Authentication failed.
</div>
<div class="col-xs-12"> <div class="col-xs-12">
<button type="submit" class="btn"> <button type="submit" class="btn">
Sign in Sign in

View File

@ -58,8 +58,16 @@ $(function() {
}); });
socket.on("auth", function(data) { socket.on("auth", function(data) {
$("body").addClass("signed-out"); var body = $("body");
$("#sign-in input[name='user']").val($.cookie("user") || ""); var login = $("#sign-in");
if (body.hasClass("signed-out")) {
var error = login.find(".error");
error.show().closest("form").one("submit", function() {
error.hide();
});
}
body.addClass("signed-out");
login.find("input[name='user']").val($.cookie("user") || "");
sidebar.find(".sign-in") sidebar.find(".sign-in")
.click() .click()
.end() .end()

View File

@ -129,11 +129,16 @@ function auth(data) {
}); });
init(socket, client); init(socket, client);
} else { } else {
var success = 0;
_.each(clients, function(client) { _.each(clients, function(client) {
if (client.config.name == data.name && client.config.password == data.password) { if (client.config.name == data.name && client.config.password == data.password) {
init(socket, client); init(socket, client);
success++;
} }
}); });
if (!success) {
socket.emit("auth");
}
} }
} }

View File

@ -1,7 +1,7 @@
{ {
"name": "shout", "name": "shout",
"description": "A web IRC client", "description": "A web IRC client",
"version": "0.8.4", "version": "0.8.5",
"homepage": "http://github.com/erming/shout", "homepage": "http://github.com/erming/shout",
"author": { "author": {
"name": "Mattias Erming", "name": "Mattias Erming",