SHARE
TWEET

Untitled

a guest Dec 30th, 2014 161 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- ANGULAR --
  2.  
  3. function mainController($scope, $rootScope, auth, localStorageService) {
  4.         // USER AUTH CHECK
  5.         isLoggedIn();
  6. }
  7.  
  8. -- JQUERY --
  9.  
  10. var DEBUG = false;
  11.  
  12.  
  13. function loadSessionId() {
  14.  
  15.     //$.mobile.loading('show'); // showing the loader by handling the ajaxStart event doesn't work, so we trigger it manually
  16.     $.ajax({
  17.         url: SERVICE_URL + "/account/getsessionid",
  18.         type: "GET",
  19.         async: false,
  20.         cache: false,
  21.         success: function (response) {
  22.             $.cookie("ASP.NET_SessionId", response.sessionid);
  23.             $.cookie("Culture", localStorage.language);
  24.             if (DEBUG) {
  25.                 console.log("SessionId: " + response.sessionid);
  26.             }
  27.         },
  28.         error: function (xhr, status, error) {
  29.             console.log("Error on getting session id. Exception: " + error);
  30.         }
  31.     });
  32. }
  33.  
  34. $(function () {
  35.     loadSessionId();
  36. });
  37.  
  38.  
  39. function isLoggedIn(forwardPage, fallbackPage) {
  40.   getRequestCode();
  41.   var retVal = null;
  42.   var islI = "0";
  43.   //$.mobile.loading('show'); // showing the loader by handling the ajaxStart event doesn't work, so we trigger it manually
  44.   if (DEBUG) {
  45.     console.log("Start check login with url: " + SERVICE_URL + "/account/logon?rvc=" + localStorage.AppRequestCode + "&crvc=" + localStorage.UserRequestCode);
  46.   }
  47.   $.ajax({
  48.     async: false,
  49.     url: SERVICE_URL + "/account/checklogin?rvc=" + localStorage.AppRequestCode + "&crvc=" + localStorage.UserRequestCode,
  50.     type: "GET",
  51.     cache: false,
  52.     success: function (response) {
  53.       if (response.success) {
  54.         $("#homebacklink").hide();
  55.         updateSaldo();
  56.         $(".userdataSaldoImg").attr("href", "#myaccount");
  57.         if (DEBUG) {
  58.           console.log("UserCode after logon: " + localStorage.UserCode);
  59.         }
  60.         var response = {
  61.           true: 1,
  62.         };
  63.         localStorage.setItem('trueFalse', JSON.stringify(response));
  64.  
  65.         $('#login-form .error').hide();
  66.         $('.ui-user-id').text(localStorage.Username);
  67.  
  68.         if (forwardPage != null)
  69.           $.mobile.changePage("#" + forwardPage);
  70.           retVal = 1;
  71.           islI = "1";
  72.         }
  73.         else {
  74.           $("#homebacklink").show();
  75.           $(".userdataSaldoImg").attr("href", "#main");
  76.           if (fallbackPage != null)
  77.             $.mobile.changePage("#" + fallbackPage);
  78.             retVal = 0;
  79.             var response = {
  80.               true: 0,
  81.             };
  82.             localStorage.setItem('trueFalse', JSON.stringify(response));
  83.           }
  84.         },
  85.         error: function (xhr, status, error) {
  86.           console.log("Error on logon. Exception: " + error);
  87.         }
  88.       });
  89.       localStorage.islI = islI;
  90.       return retVal;
  91.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top