You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

166 lines
5.4 KiB

$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
}
});
$.ajaxPrefilter(function(options, originalOptions, jqXHR){
if (options.type.toLowerCase() === "post") {
if(typeof options.data === "object") {
options.data.append("csrf_token", $('meta[name="csrf_token"]').attr('content'));
} else {
// initialize `data` to empty string if it does not exist
options.data = options.data || "";
// add leading ampersand if `data` is non-empty
options.data += options.data?"&":"";
// add _token entry
options.data += "csrf_token=" + encodeURIComponent($('meta[name="csrf_token"]').attr('content'));
}
}
});
var forgotpass = (function ($, window, jQuery) {
return {
"validate" : {
"email" : function(){
var email = $('#email').val().trim();
if(email == '') {
$('#email').focus();
$('#emailerror').html('<span style="color: red">Ce champ est obligatoire</span>');
}
else
{
$.ajax({
url : authentication.get_vars().baseurl+"check_email",
type : "POST",
data : {
email : email
},
beforeSend : function(){
$('#loading').addClass('loader');
$("#email").prop('disabled', true).css("cursor", "wait");
$("#sendemail").prop('disabled', true).css("cursor", "wait");
},
success : function(result){
$('#loading').removeClass('loader');
if(result.mtype == 'error'){
$('#emailerror').html("<span style='color: red; text-indent: 10px;'>"+result.message+"</span>");
$('#loading').removeClass('loader');
$("#email").prop('disabled', false).css("cursor", "text");
$("#sendemail").prop('disabled', false).css("cursor", "pointer");
}
else {
$('#emailerror').hide();
$('div#forgotpass-content').html("").html(
'<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4 col-centered">'+
'<div class="lm-login-form-header">'+
'<h3> Message envoyé avec succè! </h3>'+
'</div>'+
'<div class="lm-login-form-body">'+
'<p> Vérifier votre adresse électronique afin de réinitialiser votre mot de passe </p>' +
'<a href="' + authentication.get_vars().baseurl + "login" + '">' + authentication.get_vars().login.back_to_homepage + '</a>' +
'</div>'+
'</div>'
);
}
}
});
}
},
"_code" : function(){
var code = $('#code').val().trim(),
email = $("#reset_code_form").data("email");
if(code == '') {
$('#codeerror').html('Inscrivez le code qui se trouve sur votre email');
}
else {
$.ajax({
url : authentication.get_vars().baseurl+"check_code",
type : "POST",
data : {
code : code,
email : email
},
success : function(result){
if(result.mdata == 1){
window.location.href = authentication.get_vars().baseurl+"reset_password_page?email="+email;
}
else if(result.mdata == 0){
alert(result.message);
}
else {
$('#codeerror').html(result.message);
}
}
});
}
}
},
"update_password" : function(){
var password = $("#password").val().trim();
var password2 = $("#confirmpass").val().trim(),
email = $("#reset_password_form").data("email");
if(password != '' && password2 != ''){
if(password != password2){
$("#error-mismatch").html("Les mots de passe ne correspondent pas");
}
else {
$.ajax({
url : authentication.get_vars().baseurl+"new_password",
type : "POST",
data : {
email : email,
password : password
},
success : function(result){
$('#reset-password').html(
'<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-centered">'+
'<div class="lm-login-form-header">'+
"<h3> Le mot de passe a été modifié! </h3>" +
'</div>'+
'<div class="lm-login-form-body">'+
"<h4> Redirection vers la page de connexion </h4>"+
'</div>'+
'</div>'
);
setTimeout(function(){
window.location.href = authentication.get_vars().baseurl+"login";
}, 5000);
}
});
}
}
}
};
// Pass in jQuery.
})(jQuery, this);
$(function() {
$('#email').focus();
// Send Email
$("#sendemail").click(function(){
// $this.disabled = true;
forgotpass.validate.email();
});
// Submit Code
$("#submitcodebtn").click(function(){
forgotpass.validate._code();
});
// Reset Password
$("#submit-newpassword").click(function(){
forgotpass.update_password();
});
});