2019-04-24 18:46:41 +00:00
|
|
|
<?php include(__DIR__."/../layout/top.php"); ?>
|
2019-04-28 15:55:38 +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">
|
|
|
|
<h3>Register</h3>
|
|
|
|
<?php if(!empty($msg)) { ?>
|
|
|
|
<div class="alert alert-warning" role="alert">
|
|
|
|
<?php echo $msg; ?>
|
|
|
|
</div>
|
|
|
|
<?php } ?>
|
|
|
|
<form method="post" id="register">
|
|
|
|
<input name="invite" placeholder="Username" class="form-control" value="<?php echo $invite; ?>" style="display: none;">
|
|
|
|
<b>Username:</b> <span id="msg_username" class="msg"></span>
|
|
|
|
<?php
|
|
|
|
if(!empty($username)) {
|
|
|
|
?>
|
|
|
|
<input name="username" placeholder="Username" class="form-control" value="<?php echo $username; ?>" style="display: none;">
|
|
|
|
<input class="form-control" value="<?php echo $username; ?>" disabled>
|
|
|
|
<?php
|
|
|
|
} else {
|
|
|
|
?>
|
|
|
|
<input name="username" placeholder="Username" class="form-control" value="<?php echo $username; ?>">
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
|
|
<b>Password:</b> <span id="msg_password" class="msg"></span>
|
|
|
|
<input name="password" type="password" placeholder="Password" class="form-control">
|
|
|
|
<b>E-Mail</b> <span id="msg_mail" class="mail"></span>
|
|
|
|
<input type="email" placeholder="E-Mail" name="mail" class="form-control">
|
2019-04-28 15:55:38 +00:00
|
|
|
<div id="captcha" style="padding-top: 10px;"></div>
|
2019-04-24 18:46:41 +00:00
|
|
|
<input type="submit" class="btn btn-success" value="Register" style="margin-top: 10px;">
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<script language="JavaScript">
|
2019-04-28 15:04:22 +00:00
|
|
|
|
|
|
|
function getCaptchaConfig() {
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
|
|
|
url: "/api/v1/user/captcha",
|
|
|
|
success: function (res) {
|
|
|
|
captchaConfig = res.data;
|
2019-04-28 15:55:38 +00:00
|
|
|
if(captchaConfig["register"]) {
|
2019-04-28 15:04:22 +00:00
|
|
|
grecaptcha.render('captcha', {
|
|
|
|
'sitekey' : captchaConfig["key"]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
$("#loginButton").removeAttr('disabled');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-04-30 12:35:12 +00:00
|
|
|
$(window).on( "load", function() {
|
|
|
|
getCaptchaConfig();
|
|
|
|
});
|
2019-04-24 18:46:41 +00:00
|
|
|
$(document).ready(function () {
|
|
|
|
console.log("READY");
|
2019-04-30 12:35:12 +00:00
|
|
|
|
2019-04-24 18:46:41 +00:00
|
|
|
$("#register").submit(function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var form = $(this);
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
2019-04-28 15:55:38 +00:00
|
|
|
url: "/api/v1/user/register",
|
2019-04-24 18:46:41 +00:00
|
|
|
data: form.serialize(), // serializes the form's elements.
|
|
|
|
success: function (data) {
|
|
|
|
window.location.href = "/gui/login";
|
|
|
|
},
|
|
|
|
error: function (data) {
|
|
|
|
$(".msg").each(function (key, e) {
|
|
|
|
console.log(e);
|
|
|
|
$(e).html("");
|
|
|
|
})
|
|
|
|
if(data.status == 422) {
|
2019-04-28 15:55:38 +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 15:55:38 +00:00
|
|
|
} else {
|
|
|
|
swal(data.responseJSON.msg, '', "error")
|
2019-04-24 18:46:41 +00:00
|
|
|
}
|
2019-04-28 15:55:38 +00:00
|
|
|
grecaptcha.reset();
|
2019-04-24 18:46:41 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
<?php include(__DIR__."/../layout/bottom.php"); ?>
|