templates/compte_client/mot_de_passe_oublier.js.twig line 1

Open in your IDE?
  1. <script type="text/javascript">
  2. $(document).ready(function(){
  3. var ConnectPlugin = $.fn.ConnectPlugin();
  4. $(document).on('click', '#tunnel-carrousel-password-forget-1', function(){
  5. var email = $.trim($('#tunnel-verification-email-input').val());
  6. if(email!==''){
  7. $('#spinner-tunnel-carrousel-password-forget-1').removeClass('d-none');
  8. var $this = $(this);
  9. $this.prop('disabled', true);
  10. var form = $("#tunnel-verification-email-compte").serialize();
  11. var url = "{{path('compte_client_verification_email_mot_de_passe_oublier')}}";
  12. $.ajax({
  13. url: url,
  14. method: 'POST',
  15. data: form,
  16. success : function(res){
  17. if(res.success){
  18. $('#email-code-confirmation').val($('#tunnel-verification-email-input').val());
  19. $('#carousel-mot-de-passe-oublier').carousel('next');
  20. }else{
  21. ConnectPlugin.elementDisplayError('#tunnel-verification-email-input', res.msg);
  22. }
  23. $this.prop('disabled', false);
  24. $('#spinner-tunnel-carrousel-password-forget-1').addClass('d-none');
  25. },
  26. error: function(){
  27. alert("Erreur lors de la verification d'email du compte");
  28. $this.prop('disabled', false);
  29. $('#spinner-tunnel-carrousel-password-forget-1').addClass('d-none');
  30. }
  31. });
  32. }else{
  33. ConnectPlugin.elementDisplayError('#tunnel-verification-email-input', 'Veuillez renseigner votre adresse email');
  34. }
  35. });
  36. $(document).on('click', '#tunnel-carrousel-password-forget-2', function(){
  37. $('#alert-message-code-confirmation').addClass('d-none');
  38. $('#message-code-confirmation').html('');
  39. var code = $.trim($('#code-confirmation').val());
  40. var pass = $.trim($('#password-new').val());
  41. var confirme = $.trim($('#password-confirme').val());
  42. var verif = true;
  43. if(code === ''){
  44. verif = false;
  45. ConnectPlugin.elementDisplayError('#code-confirmation', 'Renseigner le code de confirmation');
  46. }
  47. if(pass === ''){
  48. verif = false;
  49. ConnectPlugin.elementDisplayError('#password-new', 'Renseigner le nouveau mot de passe');
  50. }
  51. if(confirme === ''){
  52. verif = false;
  53. ConnectPlugin.elementDisplayError('#password-confirme', 'Confirmer votre mot de passe');
  54. }
  55. if(verif) {
  56. var checkPass = checkPassword(pass);
  57. if(pass !== confirme) {
  58. ConnectPlugin.elementDisplayError('#password-new', 'Les mots de passe ne sont pas identique');
  59. ConnectPlugin.elementDisplayError('#password-confirme', 'Les mots de passe ne sont pas identique');
  60. }else if(!checkPass.success){
  61. $('#message-code-confirmation').html(checkPass.msg);
  62. $('#alert-message-code-confirmation').removeClass('d-none');
  63. ConnectPlugin.elementDisplayError('#password-new', '');
  64. ConnectPlugin.elementDisplayError('#password-confirme', '');
  65. }else{
  66. var $this = $(this);
  67. $this.prop('disabled', true);
  68. $('#spinner-tunnel-carrousel-password-forget-2').removeClass('d-none');
  69. var form = $("#tunnnel-code-confirmation-compte").serialize();
  70. var url = "{{path('compte_client_code_confirmation_mot_de_passe_oublier')}}";
  71. $.ajax({
  72. url: url,
  73. method: 'POST',
  74. data: form,
  75. success : function(res){
  76. if(res.success){
  77. $('#carousel-mot-de-passe-oublier').carousel('next');
  78. }else{
  79. $('#message-code-confirmation').html(res.msg);
  80. $('#alert-message-code-confirmation').removeClass('d-none');
  81. }
  82. $this.prop('disabled', false);
  83. $('#spinner-tunnel-carrousel-password-forget-2').addClass('d-none');
  84. },
  85. error: function(){
  86. alert("Erreur lors de la verification d'email du compte");
  87. $this.prop('disabled', false);
  88. $('#spinner-tunnel-carrousel-password-forget-2').addClass('d-none');
  89. }
  90. });
  91. }
  92. }
  93. });
  94. $(document).on('click', '.tunnel-carrousel-password-forget-prev', function(){
  95. $('#carousel-mot-de-passe-oublier').carousel('prev');
  96. });
  97. $(document).on('click', '.input-view-password-forget', function(){
  98. var $this = $(this);
  99. var type = $this.attr('data-type');
  100. inputViewPassword($this, type);
  101. });
  102. function inputViewPassword($this, type){
  103. if(type == 1){
  104. $this.siblings('input').attr('type', 'text');
  105. $this.find('i').removeClass('fe-eye').addClass('fe-eye-off');
  106. $this.attr('data-type', 0);
  107. }else{
  108. $this.siblings().attr('type', 'password');
  109. $this.find('i').removeClass('fe-eye-off').addClass('fe-eye');
  110. $this.attr('data-type', 1);
  111. }
  112. }
  113. function checkPassword(pass) {
  114. var pass1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  115. var pass2 = 'abcdefghijklmnopqrstuvwxyz';
  116. var pass3 = '0123456789';
  117. var pass4 = '@/#!';
  118. var arrayPass = [pass1, pass2, pass3, pass4];
  119. // tslint:disable-next-line: max-line-length
  120. var passError = 'Le mot de passe doit contenir au minimum 8 caractères, dont 1 chiffre, 1 Majuscule, 1 minuscule et un caractère spécial @ / # !';
  121. let bOk = false;
  122. const res = {success: true, msg: ''};
  123. if (pass.length > 7) {
  124. try {
  125. arrayPass.forEach((element, index) => {
  126. bOk = checkNombreCharInPass(pass, element, 1);
  127. if (!bOk) {
  128. res.success = false;
  129. res.msg = passError;
  130. throw res;
  131. }
  132. });
  133. } catch (e) {
  134. console.log('erreur', e);
  135. }
  136. } else {
  137. res.success = false;
  138. res.msg = passError;
  139. }
  140. return res;
  141. }
  142. function checkNombreCharInPass(pass, regex, nbr) {
  143. const arrayReg = Array.from(regex);
  144. let bOk = false;
  145. let nbrChar = 0;
  146. for (const char of arrayReg) {
  147. if (pass.indexOf(char) >= 0) {
  148. nbrChar++;
  149. }
  150. }
  151. if (nbrChar >= nbr) {
  152. bOk = true;
  153. }
  154. return bOk;
  155. }
  156. });
  157. </script>