This commit is contained in:
JoseluCross
2018-10-01 23:27:01 +02:00
parent 40e0291517
commit 7cb682c146
7 changed files with 53 additions and 17 deletions

View File

@@ -8,20 +8,15 @@
</div>
<div class="row">
<div class="col-sm-12">
{% if page.state == 'BAD_CREDENTIAL' %}
<p class="text-danger">Bad credentials</p>
{% elseif page.state == 'POST_ERROR' %}
<p class="text-danger">Error during sign-up, check your data</p>
{% elseif page.state == 'MAIL_IN_USE' %}
<p class="text-danger">The e-mail is currently in use</p>
{% elseif page.state == 'NICK_IN_USE' %}
<p class="text-danger">The nickname is currently in use</p>
{% endif %}
<p class="text-danger loginMessage" id="BAD_CREDENTIAL">Bad credentials</p>
<p class="text-danger loginMessage" id="POST_ERROR">Error during sign-up, check your data</p>
<p class="text-danger loginMessage" id="MAIL_IN_USE">The e-mail is currently in use</p>
<p class="text-danger loginMessage" id="NICK_IN_USE">The nickname is currently in use</p>
</div>
</div>
</div>
<div id="login">
<form class="form-horizontal" method="post">
<form class="form-horizontal" method="post" id="loginForm">
<div class="form-group">
<label class="control-label col-sm-2" for="email">Email:</label>
<div class="col-sm-10">
@@ -45,7 +40,7 @@
</form>
</div>
<div id="register" style="display:none;">
<form class="form-horizontal" method="post">
<form class="form-horizontal" method="post" id="regForm">
<div class="form-group">
<label class="control-label col-sm-2" for="emailre">Email:</label>
<div class="col-sm-10">
@@ -98,6 +93,28 @@
{% block js %}
<script>
doneFun = function(data){
console.log(data);
if (data == 'redirect'){
window.location.href = '{{path('home')}}';
}
var todos = $(".text-danger").each(function (){
$(this).css("display","none");
});
$("#"+data).css('display',"block");
}
$(document).ready(function() {
var options = {success: doneFun,
url: '{{ path("login")}}',
beforeSubmit: function(arr, $form, options){
console.log(arr);
}} ;
$("#regForm").ajaxForm(options);
$("#loginForm").ajaxForm(options);
});
function checkPassword() {
if ($('#pwdre').val() != $("#pwdre-re").val()) {
$("#pwdre-re")[0].setCustomValidity('Password do not match');