Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $("#login_btn_mobile").on('click', function(){
- var back_link = function(){
- $("form[name='login_form']").show();
- $('#content_login').html("");
- $('#content_login_mobile').html("");
- $("#email").select();
- $("#password").val("");
- $("#email_mobile").select();
- $("#password_mobile").val("");
- }
- console.log("######")
- $("#error_msg_mobile").hide();
- $("input").prop("disabled", true);
- $.ajax({
- url: '/logmein',
- method: 'post',
- cache: false,
- data: {"email": $("#email_mobile").val(), "passwd": $("#password_mobile").val()},
- success: function(data, textStatus, request){
- $("input").prop("disabled", false);
- if(data.totp){
- window.location = "/";
- } else {
- if(data.enroll){
- // TOTP Enroll
- $("#enroll_error").hide();
- $.ajax({
- url: "/enroll",
- type: "GET",
- success: function(response) {
- $("form[name='login_form']").hide();
- $('#content_login').html(response);
- $('#content_login_mobile').html(response);
- $("#back_link").on('click', back_link);
- $("#content_login").find(".mdl-textfield, .mdl-button").each(function(){
- componentHandler.upgradeElement(this);
- });
- $("#content_login_mobile").find(".mdl-textfield, .mdl-button").each(function(){
- componentHandler.upgradeElement(this);
- });
- var success = function(response){
- window.location = "/";
- }
- var error = function(error){
- jQuery("#enroll_error").css('visibility', 'visible');
- }
- var change = function() {
- jQuery("#enroll_error").css('visibility', 'hidden');
- }
- multipleFields("#multiple_fields", /[0-9]/g, {url: '/enroll_ajax', method: 'post', success, error}, change, error);
- }
- });
- } else {
- // TOTP Checkpoint
- $.ajax({
- url: "/totp",
- type: "GET",
- success: function(response) {
- $("form[name='login_form']").hide();
- $('#content_login').html(response);
- $('#content_login_mobile').html(response);
- $("#back_link").on('click', back_link);
- multipleFields("#multiple_fields", /[0-9]/g, {url: "/totp_check", method: "post", success, error}, change, error);
- }
- });
- }
- }
- },
- error: function(data){
- $("#error_msg_mobile").show();
- $("#error_msg_mobile").css("visibility","visible")
- $("input").prop("disabled", false);
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement