This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccount/resources/views/account/login.php

67 lines
2.5 KiB
PHP
Raw Permalink Normal View History

2019-04-24 18:46:41 +00:00
<?php include(__DIR__."/../layout/top.php"); ?>
2019-04-28 12:49:10 +00:00
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script><br>
2019-04-24 18:46:41 +00:00
<div class="row">
<div class="col-md-12">
2019-04-28 12:49:10 +00:00
<h3>Login</h3>
2019-04-24 18:46:41 +00:00
<form method="post" id="login">
<b>Username:</b> <span id="msg_username"></span>
<input name="username" placeholder="Username" class="form-control">
<b>Password:</b> <span id="msg_password"></span>
<input name="password" type="password" placeholder="Password" class="form-control">
2019-04-28 12:49:10 +00:00
<div id="captcha" style="padding-top: 10px;">
</div>
<input type="submit" id="loginButton" disabled class="btn btn-success" value="Login" style="margin-top: 10px;">
2019-04-24 18:46:41 +00:00
</form>
2019-05-02 10:57:17 +00:00
<hr>
<a href="/gui/passwordReset">Forgot Password</a>
2019-04-24 18:46:41 +00:00
</div>
</div>
<script language="JavaScript">
2019-04-28 12:49:10 +00:00
var captchaConfig = {};
function getCaptchaConfig() {
$.ajax({
type: "GET",
url: "/api/v1/user/captcha",
success: function (res) {
captchaConfig = res.data;
if(captchaConfig["login"]) {
grecaptcha.render('captcha', {
'sitekey' : captchaConfig["key"]
});
}
$("#loginButton").removeAttr('disabled');
}
});
}
$(window).on( "load", function() {
getCaptchaConfig();
});
2019-04-24 18:46:41 +00:00
$(document).ready(function () {
2019-04-28 12:49:10 +00:00
getCaptchaConfig();
2019-04-24 18:46:41 +00:00
console.log("READY");
$("#login").submit(function (e) {
e.preventDefault();
var form = $(this);
$.ajax({
type: "POST",
2019-04-28 12:49:10 +00:00
url: "/api/v1/user/login",
2019-04-24 18:46:41 +00:00
data: form.serialize(), // serializes the form's elements.
success: function (data) {
window.location.href = "/";
},
error: function (data) {
if(data.status == 422) {
2019-04-28 12:49:10 +00:00
$.each(data.responseJSON.data, function( key, value ) {
2019-04-24 18:46:41 +00:00
$("#msg_"+key).html(value[0]);
});
2019-04-28 12:49:10 +00:00
} else {
swal(data.responseJSON.msg, '', "error")
2019-04-24 18:46:41 +00:00
}
2019-04-28 12:49:10 +00:00
grecaptcha.reset();
2019-04-24 18:46:41 +00:00
}
});
});
});
</script>
<?php include(__DIR__."/../layout/bottom.php"); ?>