Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. $("#login_btn_mobile").on('click', function(){
  2.  
  3. var back_link = function(){
  4. $("form[name='login_form']").show();
  5. $('#content_login').html("");
  6. $('#content_login_mobile').html("");
  7.  
  8. $("#email").select();
  9. $("#password").val("");
  10.  
  11. $("#email_mobile").select();
  12. $("#password_mobile").val("");
  13. }
  14. console.log("######")
  15.  
  16. $("#error_msg_mobile").hide();
  17. $("input").prop("disabled", true);
  18. $.ajax({
  19. url: '/logmein',
  20. method: 'post',
  21. cache: false,
  22. data: {"email": $("#email_mobile").val(), "passwd": $("#password_mobile").val()},
  23. success: function(data, textStatus, request){
  24. $("input").prop("disabled", false);
  25.  
  26. if(data.totp){
  27. window.location = "/";
  28. } else {
  29. if(data.enroll){
  30.  
  31. // TOTP Enroll
  32.  
  33. $("#enroll_error").hide();
  34. $.ajax({
  35. url: "/enroll",
  36. type: "GET",
  37. success: function(response) {
  38. $("form[name='login_form']").hide();
  39. $('#content_login').html(response);
  40. $('#content_login_mobile').html(response);
  41.  
  42. $("#back_link").on('click', back_link);
  43.  
  44. $("#content_login").find(".mdl-textfield, .mdl-button").each(function(){
  45. componentHandler.upgradeElement(this);
  46. });
  47.  
  48. $("#content_login_mobile").find(".mdl-textfield, .mdl-button").each(function(){
  49. componentHandler.upgradeElement(this);
  50. });
  51.  
  52. var success = function(response){
  53. window.location = "/";
  54. }
  55.  
  56. var error = function(error){
  57. jQuery("#enroll_error").css('visibility', 'visible');
  58. }
  59.  
  60. var change = function() {
  61. jQuery("#enroll_error").css('visibility', 'hidden');
  62. }
  63.  
  64. multipleFields("#multiple_fields", /[0-9]/g, {url: '/enroll_ajax', method: 'post', success, error}, change, error);
  65. }
  66. });
  67. } else {
  68.  
  69. // TOTP Checkpoint
  70.  
  71. $.ajax({
  72. url: "/totp",
  73. type: "GET",
  74. success: function(response) {
  75. $("form[name='login_form']").hide();
  76. $('#content_login').html(response);
  77. $('#content_login_mobile').html(response);
  78.  
  79. $("#back_link").on('click', back_link);
  80.  
  81. multipleFields("#multiple_fields", /[0-9]/g, {url: "/totp_check", method: "post", success, error}, change, error);
  82. }
  83. });
  84. }
  85. }
  86. },
  87. error: function(data){
  88. $("#error_msg_mobile").show();
  89. $("#error_msg_mobile").css("visibility","visible")
  90. $("input").prop("disabled", false);
  91. }
  92. });
  93. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement