Skip to content
Snippets Groups Projects
Commit 73cb6e4d authored by xamgore's avatar xamgore
Browse files

Closes #23: Auth window

parents d86ff7af 946fc0c5
Branches
Tags
No related merge requests found
$(function() $(function () {
{ var jProfiler = $('#profileInfo').first();
var jProfiler = $('#profileInfo').first();
var isOpened = false; var isOpened = false;
var flag = false; var flag = false;
var jLogin = $('#login');
var jPass = $('#password');
// Показ профиля при нажатии // Показ профиля при нажатии
$('#settingsButton').click(function () $('#settingsButton').click(function () {
{ $.get(URLdir + "window/settings", function (data) {
$.get(URLdir + "window/settings", function(data){
wnd.open(JSON.parse(data)); wnd.open(JSON.parse(data));
}); });
}); });
$(document).click(function() { $(document).click(function () {
if (flag === true) { if (flag === true) {
flag = false; flag = false;
} else if (isOpened === true) { } else if (isOpened === true) {
jProfiler.slideUp(200);//css('display', 'none'); jProfiler.slideUp(200);//css('display', 'none');
isOpened = false; isOpened = false;
} }
}); });
$(".profile_wrapper").click(function() { $(".profile_wrapper").click(function () {
flag = true; flag = true;
}); });
$('#username').click(function() { $('#username').click(function () {
flag = true; flag = true;
if(isOpened) if (isOpened) {
{
jProfiler.slideUp(200);//css('display', 'none'); jProfiler.slideUp(200);//css('display', 'none');
isOpened = false; isOpened = false;
} }
else else {
{
jProfiler.slideDown(200);//css('display', 'block'); jProfiler.slideDown(200);//css('display', 'block');
isOpened = true; isOpened = true;
} }
...@@ -44,55 +42,71 @@ $(function() ...@@ -44,55 +42,71 @@ $(function()
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: URLdir + "handler/Session/closeSession", url: URLdir + "handler/Session/closeSession",
success: function(data) { success: function (data) {
$('.popup_overlay').css('display', 'block'); $('.popup_overlay').css('display', 'block');
jLogin.focus();
$('#signin_b').click(function()
{
$.post(URLdir + 'handler/sign/in', {'login': $('#login').val(), 'password': $.sha1($('#password').val())},
function(data)
{
data = $.parseJSON(data);
if(data.success === true)
{
$('.popup_overlay').css('display', 'none');
//location.reload();
setSessionTimer(15);
}
else
{
$('.auth_error').show();
}
});
});
} }
}); });
} }
function setSessionTimer(time) { function setSessionTimer(time) {
timer = setTimeout(function() { timer = setTimeout(function () {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: URLdir + "handler/Session/getSessionTime", url: URLdir + "handler/Session/getSessionTime",
success: function(data) success: function (data) {
{
data = $.parseJSON(data); data = $.parseJSON(data);
wait = parseInt(data, 10); wait = parseInt(data, 10);
if (wait <= 10) { if (wait <= 10) {
closeSession(); closeSession();
return;
} else { } else {
setSessionTimer(wait-10); setSessionTimer(wait - 10);
} }
} }
}); });
}, 1000*time); }, 1000 * time);
} }
setSessionTimer(1); setSessionTimer(1);
});
\ No newline at end of file function authorize(login, pass) {
$.post(URLdir + 'handler/sign/in', {
'login': login,
'password': $.sha1(pass)
},
function (data) {
data = $.parseJSON(data);
if (data.success) {
$('.popup_overlay').hide();
setSessionTimer(15);
} else {
$('.auth_error').show();
}
});
}
function checkFieldsAndAuthorize() {
var login = jLogin.val();
var pass = jPass.val();
if (login.length > 0 && pass.length > 0) {
authorize(login, pass);
} else {
!login.length ? jLogin.focus() : jPass.focus();
}
}
jLogin.keypress(function (event) {
if (event.keyCode == 13)
checkFieldsAndAuthorize();
});
jPass.keypress(function (event) {
if (event.keyCode == 13)
checkFieldsAndAuthorize();
});
$('#signin_b').click(checkFieldsAndAuthorize);
});
...@@ -6,6 +6,12 @@ ...@@ -6,6 +6,12 @@
color: #aaaaaa; color: #aaaaaa;
} }
.auth_title
{
font-size: x-large;
margin-bottom: 0.5em;
}
.auth_form .auth_form
{ {
padding: 3px; padding: 3px;
...@@ -74,7 +80,7 @@ ...@@ -74,7 +80,7 @@
max-width: 300px; max-width: 300px;
padding: 20px; padding: 20px;
border: 3px solid #fff; border: 3px solid #fff;
border-radius: 10px; border-radius: 7px;
box-shadow: inset 0 1px 2px 1px rgba(0,0,0,.4); box-shadow: inset 0 1px 2px 1px rgba(0,0,0,.4);
background: #fff; background: #fff;
vertical-align: middle vertical-align: middle
...@@ -111,4 +117,4 @@ ...@@ -111,4 +117,4 @@
-webkit-transform: scale3d(1,1,1); -webkit-transform: scale3d(1,1,1);
-webkit-box-shadow: 0 3px 20px rgba(0,0,0,0.9); -webkit-box-shadow: 0 3px 20px rgba(0,0,0,0.9);
} }
} }
\ No newline at end of file
<div class="popup_overlay"> <div class="popup_overlay">
<div class="popup"> <div class="popup">
<form action="sign" method='POST' id='signin_f'> <form action="sign" method='POST' id='signin_f'>
<div class="session_info">Пожалуйста, авторизируйтесь заново</div> <div class='auth_title'>Авторизация</div>
<div class='auth_error'>Неправильный логин/E-Mail или пароль</div>
<div class='inputs'> <div class='inputs'>
<div class="auth_form"> <div class="auth_form">
<input type="text" id="login" name="login" placeholder="Логин или E-Mail" value=""> <input type="text" id="login" name="login" placeholder="Логин или E-Mail" value="">
...@@ -21,4 +20,4 @@ ...@@ -21,4 +20,4 @@
{{ HTML.anchor('sign/up', 'Активировать аккаунт')|raw }} | {{ HTML.anchor('remind', 'Забыли пароль?')|raw }} {{ HTML.anchor('sign/up', 'Активировать аккаунт')|raw }} | {{ HTML.anchor('remind', 'Забыли пароль?')|raw }}
</div> </div>
</div> </div>
</div> </div>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment