#getUserSession ()  Returns user session from android if it exists, or else an empty object. if window.Platform doesn't exist, returns test data e.g. { user: {id: 1, username: 'foo', ...}, token: 'validToken' }
187083
function () {
    var session = {};

    if (this.android) {
      session = parseJSON(this.android.getUserSession());
    } else {
      // For testing
      session =  {
        user: {
          id: 1,
          username: 'jonatmozilla',
          avatar: 'https://secure.gravatar.com/avatar/c1b6f037ee7e440940d3c0c6ebeb8ba2?d=https%3A%2F%2Fstuff.webmaker.org%2Favatars%2Fwebmaker-avatar-200x200.png',
          prefLocale: 'en-US'
        },
        token: 'validToken'
      };
    }

    return session;
  }
929502
public Object getUserFromSession(HttpServletRequest request) {
    Debug.logVerbose("[JdonFramework]--> enter getUserFromSession", module);
    HttpSession session = request.getSession();
    Object model = session.getAttribute(USERMODEL);
    return model;
  }
441713
public function getUserSessionToken()
    {
        if (($u = $this->getUserLoggedIn()) == null) {
            return null;
        }

        return isset($_SESSION['model-user-library-session-token']) ? $_SESSION['model-user-library-session-token'] : $_SESSION['model-user-library-session-token'] = $u->getUserToken();
    }
1075365
protected String getToken() {
        return dataMgr.getSessionDAO().session() != null ? dataMgr.getSessionDAO().session().getAccessToken() : null;
    }
970508
function makeSession(session) {
  return {
    authenticated: !!session.token,
    token: session.token,
    scope: session.scope,
    error: session.error,
    errorDescription: session.errorDescription
  };
}
71276
def API_GET(self):  # pylint: disable=arguments-differ
        
        if self.user_manager.session_logged_in():
            return 200, {"authenticated": True, "username": self.user_manager.session_username()}
        else:
            return 200, {"authenticated": False}
307021
@Deprecated
    public final Session getSession() {
        while (true) {
            String cachedToken = null;
            Session oldSession = null;

            synchronized (this.lock) {
                if (userSetSession != null) {
                    return userSetSession;
                }
                if ((session != null) || !sessionInvalidated) {
                    return session;
                }

                cachedToken = accessToken;
                oldSession = session;
            }

            if (cachedToken == null) {
                return null;
            }

            // At this point we do not have a valid session, but mAccessToken is
            // non-null.
            // So we can try building a session based on that.
            List<String> permissions;
            if (oldSession != null) {
                permissions = oldSession.getPermissions();
            } else if (pendingAuthorizationPermissions != null) {
                permissions = Arrays.asList(pendingAuthorizationPermissions);
            } else {
                permissions = Collections.<String>emptyList();
            }

            Session newSession = new Session.Builder(pendingAuthorizationActivity).
                    setApplicationId(mAppId).
                    setTokenCachingStrategy(getTokenCache()).
                    build();
            if (newSession.getState() != SessionState.CREATED_TOKEN_LOADED) {
                return null;
            }
            Session.OpenRequest openRequest =
                    new Session.OpenRequest(pendingAuthorizationActivity).setPermissions(permissions);
            openSession(newSession, openRequest, !permissions.isEmpty());

            Session invalidatedSession = null;
            Session returnSession = null;

            synchronized (this.lock) {
                if (sessionInvalidated || (session == null)) {
                    invalidatedSession = session;
                    returnSession = session = newSession;
                    sessionInvalidated = false;
                }
            }

            if (invalidatedSession != null) {
                invalidatedSession.close();
            }

            if (returnSession != null) {
                return returnSession;
            }
            // Else token state changed between the synchronized blocks, so
            // retry..
        }
    }
72229
public function getSession() {
        if ($this->debug) { $start = microtime(true); }
        if (!$this->sessionLoaded) {
            $session = null;
            $write_cookie = true;

            $parsed_url = parse_url($this->redirect_uri);
            $parsed_path = '/';
            if (!empty($parsed_url['path'])) {
                $parsed_path = ($parsed_url['path'] != '/')?rtrim($parsed_url['path'], '/'):'/';
            }
            $request_uri = $this->_getServerParam('REQUEST_URI');
            $code = $this->_getRequestParam('code');
            if (!$session && stristr($request_uri,$parsed_path) && $code) {
                $ret = $this->getAccessToken($code);
                if (is_array($ret) && isset($ret['access_token'])) {
                    $session = $this->signSession($ret); // Signs session for security
                }
            }
            // try loading session from signed_request in $_REQUEST
            $signedRequest = $this->getSignedRequest();
            if ($signedRequest) {
                // sig is good, use the signedRequest
                $session = $this->createSessionFromSignedRequest($signedRequest);
            }
            // try loading session from $_REQUEST
            $session_param = $this->_getRequestParam('session');
            if (!$session && $session_param) {
                $session = json_decode(get_magic_quotes_gpc() ? stripslashes($session_param) : $session_param, true);
                $session = $this->validateSessionObject($session);
            }
            // try loading session from cookie if necessary
            if (!$session && $this->useCookieSupport()) {
                $cookieName = $this->getSessionCookieName();
                if (isset($_COOKIE[$cookieName])) {
                    $session = array();
                    parse_str(trim(get_magic_quotes_gpc() ? stripslashes($_COOKIE[$cookieName]) : $_COOKIE[$cookieName], '"'), $session);
                    $session = $this->validateSessionObject($session);
                    // write only if we need to delete a invalid session cookie
                    $write_cookie = empty($session);
                }
            }
            $this->setSession($session, $write_cookie);
        }
        if ($this->debug) { $this->timer[__FUNCTION__]['elapsed'][] = microtime(true)-$start; }
        return $this->session;
    }
536750
public function getUser()
    {
        if (null === $tokenStorage = $this->tokenStorage) {
            throw new \RuntimeException('The "app.user" variable is not available.');
        }

        if (!$token = $tokenStorage->getToken()) {
            return;
        }

        $user = $token->getUser();
        if (\is_object($user)) {
            return $user;
        }
    }
803573
public synchronized Session getSession()
	{
		if (session == null)
		{
			if (authenticator != null)
			{
				session = Session.getInstance(properties, authenticator);
			}
			else
			{
				session = Session.getInstance(properties);
			}
		}
		return session;
	}
219671
private SessionData loadSession() {

        synchronized (sharedLock) {
            SharedPreferences sharedPreferences = getSharedPreferences();
            String id = sharedPreferences.getString(KEY_PROFILE_ID, null);
            if (!TextUtils.isEmpty(id)) {
                sharedLock.notifyAll();
                return new SessionData()
                        .setProfileId(id)
                        .setSessionId(sharedPreferences.getString(KEY_SESSION_ID, null))
                        .setAccessToken(sharedPreferences.getString(KEY_ACCESS_TOKEN, null))
                        .setExpiresOn(sharedPreferences.getLong(KEY_EXPIRES_ON, 0));
            }
            sharedLock.notifyAll();
        }

        return null;
    }
1175710
function getUserData(data, checks) {
  if (Array.isArray(data) ? data.length === 0 : data.total === 0) {
    throw new errors.BadRequest('User not found.', { errors: { $className: 'badParams' } });
  }
  
  const users = Array.isArray(data) ? data : data.data;
  const user = users[0];
  
  if (users.length !== 1) {
    throw new errors.BadRequest('More than 1 user selected.',
      { errors: { $className: 'badParams' } });
  }

  if (checks.indexOf('isNotVerified') !== -1 && user.isVerified) {
    throw new errors.BadRequest('User is already verified.',
      { errors: { $className: 'isNotVerified' } });
  }

  if (checks.indexOf('isVerified') !== -1 && !user.isVerified) {
    throw new errors.BadRequest('User is not verified.',
      { errors: { $className: 'isVerified' } });
  }
  
  if (checks.indexOf('verifyNotExpired') !== -1 && user.verifyExpires < Date.now()) {
    throw new errors.BadRequest('Verification token has expired.',
      { errors: { $className: 'verifyExpired' } });
  }

  if (checks.indexOf('resetNotExpired') !== -1 && user.resetExpires < Date.now()) {
    throw new errors.BadRequest('Password reset token has expired.',
      { errors: { $className: 'resetExpired' } });
  }

  return user;
}
1072881
function getSession(apiKey) {
  var session = Sessions.get(apiKey)

  if (session) return session

  session = new Session()
  Sessions.set(apiKey, session)

  return session
}
258880
function() {
      if (Parse.User._currentUser) {
        return Parse.User._currentUser;
      }

      if (Parse.User._currentUserMatchesDisk) {
        
        return Parse.User._currentUser;
      }

      // Load the user from local storage.
      Parse.User._currentUserMatchesDisk = true;

      var userData = Parse.localStorage.getItem(Parse._getParsePath(
          Parse.User._CURRENT_USER_KEY));
      if (!userData) {
        
        return null;
      }
      Parse.User._currentUser = Parse.Object._create("_User");
      Parse.User._currentUser._isCurrentUser = true;

      var json = JSON.parse(userData);
      Parse.User._currentUser.id = json._id;
      delete json._id;
      Parse.User._currentUser._sessionToken = json._sessionToken;
      delete json._sessionToken;
      Parse.User._currentUser._finishFetch(json);

      Parse.User._currentUser._synchronizeAllAuthData();
      Parse.User._currentUser._refreshCache();
      Parse.User._currentUser._opSetQueue = [{}];
      return Parse.User._currentUser;
    }
449048
@Override
  public IGxSessionData getAppSessionData(Class<? extends AppSession> clazz, String sessionId) {
    if (clazz.equals(ClientGxSession.class)) {
      ClientGxSessionDataLocalImpl data = new ClientGxSessionDataLocalImpl();
      data.setSessionId(sessionId);
      return data;
    }
    else if (clazz.equals(ServerGxSession.class)) {
      ServerGxSessionDataLocalImpl data = new ServerGxSessionDataLocalImpl();
      data.setSessionId(sessionId);
      return data;
    }
    throw new IllegalArgumentException(clazz.toString());
  }
518657
@Override
  public IAccSessionData getAppSessionData(Class<? extends AppSession> clazz, String sessionId) {
    if (clazz.equals(ClientAccSession.class)) {
      ClientAccSessionDataLocalImpl data = new ClientAccSessionDataLocalImpl();
      data.setSessionId(sessionId);
      return data;
    }
    else if (clazz.equals(ServerAccSession.class)) {
      ServerAccSessionDataLocalImpl data = new ServerAccSessionDataLocalImpl();
      data.setSessionId(sessionId);
      return data;
    }
    throw new IllegalArgumentException(clazz.toString());
  }
65146
function() {
        var user = userStore.getUser();
        if (user) {
          $rootScope.user = user;
          authLogger.log('AuthService.withUser()', user);
          return $q.when(user);
        } else {
          authLogger.log('AuthService.withUser(), calling startLogin()');
          return this.startLogin();
        }
      }