Fixes in controllers and login
This commit is contained in:
parent
9f21c3a87e
commit
7ac0f6c850
4 changed files with 197 additions and 31 deletions
67
modules/admin/templates/check_auth.php
Normal file
67
modules/admin/templates/check_auth.php
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<?=$this->layout('login_tpl', ['title' => $title])?>
|
||||
<?=$this->start('content')?>
|
||||
<form method="post" name="auth_submit" id="auth_submit">
|
||||
<p><label for="auth_code"></label><input type="text" name="auth_code" id="auth_code_form" placeholder="<?=_('Code')?>"/></p>
|
||||
<p class="error" id="username_error"></p>
|
||||
<?=PhangoApp\PhaUtils\Utils::set_csrf_key($name_token='csrf_token', $length_token=80)?>
|
||||
<p>
|
||||
<input type="submit" id="button_submit" class="button" value="<?=_('Send auth code')?>" />
|
||||
</p>
|
||||
</form>
|
||||
<?=$this->end('content')?>
|
||||
<?=$this->start('footer_js')?>
|
||||
<script language="Javascript">
|
||||
$(document).ready( function () {
|
||||
|
||||
$("#auth_submit").submit( function () {
|
||||
|
||||
$('.error').html('');
|
||||
|
||||
$('#loader-wrapper').show();
|
||||
|
||||
$.ajax({
|
||||
url: "<?=$this->make_url('admin', 'app', ['login'])?>",
|
||||
method: "POST",
|
||||
dataType: "json",
|
||||
data: {'auth_code': $('#auth_code_form').val()},
|
||||
success: function (data) {
|
||||
|
||||
if(data.error==0)
|
||||
{
|
||||
console.log('Success');
|
||||
|
||||
$('#loader-wrapper').hide();
|
||||
|
||||
location.href="<?=$this->make_url('admin')?>";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$('#loader-wrapper').hide();
|
||||
|
||||
$('#csrf_token').attr('value', data.csrf_token);
|
||||
|
||||
$('#username_error').html(data.error_form.username_error);
|
||||
}
|
||||
|
||||
},
|
||||
error: function (data) {
|
||||
|
||||
$('#loader-wrapper').hide();
|
||||
|
||||
alert('Error');
|
||||
|
||||
console.log(data);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
<?=$this->end('footer_js')?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue