lib/private/User/Session.php
/**
	 * perform login using the magic cookie (remember login)
	 *
	 * @param string $uid the username
	 * @param string $currentToken
	 * @param string $oldSessionId
	 * @return bool
	 */
perform login using the magic cookie (remember login)
@param string $uid the username
@param string $currentToken
@param string $oldSessionId
@return bool
perform login using the magic cookie ( remember login ) @param string $uid the username @param string $currentToken @param string $oldSessionId @return bool
public function loginWithCookie($uid, $currentToken, $oldSessionId) {
		$this->session->regenerateId();
		$this->manager->emit('\OC\User', 'preRememberedLogin', array($uid));
		$user = $this->manager->get($uid);
		if (is_null($user)) {
			return false;
		}
		$tokens = $this->config->getUserKeys($uid, 'login_token');
		if (!in_array($currentToken, $tokens, true)) {
			return false;
		}
		$this->config->deleteUserValue($uid, 'login_token', $currentToken);
		$newToken = $this->random->generate(32);
		$this->config->setUserValue($uid, 'login_token', $newToken, $this->timeFactory->getTime());
		try {
			$sessionId = $this->session->getId();
			$this->tokenProvider->renewSessionToken($oldSessionId, $sessionId);
		} catch (SessionNotAvailableException $ex) {
			return false;
		} catch (InvalidTokenException $ex) {
			\OC::$server->getLogger()->warning('Renewing session token failed', ['app' => 'core']);
			return false;
		}
		$this->setMagicInCookie($user->getUID(), $newToken);
		$token = $this->tokenProvider->getToken($sessionId);
		$this->setUser($user);
		$this->setLoginName($token->getLoginName());
		$this->setToken($token->getId());
		$this->lockdownManager->setToken($token);
		$user->updateLastLoginTimestamp();
		$password = null;
		try {
			$password = $this->tokenProvider->getPassword($token, $sessionId);
		} catch (PasswordlessTokenException $ex) {
		}
		$this->manager->emit('\OC\User', 'postRememberedLogin', [$user, $password]);
		return true;
	}
public function loginWithCookie ( $ uid , $ currentToken , $ oldSessionId ) { $ this -> session -> regenerateId ( ) ; $ this -> manager -> emit ( '\OC\User' , 'preRememberedLogin' , array ( $ uid ) ) ; $ user = $ this -> manager -> get ( $ uid ) ; if ( is_null ( $ user ) ) { return false ; } $ tokens = $ this -> config -> getUserKeys ( $ uid , 'login_token' ) ; if ( ! in_array ( $ currentToken , $ tokens , true ) ) { return false ; } $ this -> config -> deleteUserValue ( $ uid , 'login_token' , $ currentToken ) ; $ newToken = $ this -> random -> generate ( 32 ) ; $ this -> config -> setUserValue ( $ uid , 'login_token' , $ newToken , $ this -> timeFactory -> getTime ( ) ) ; try { $ sessionId = $ this -> session -> getId ( ) ; $ this -> tokenProvider -> renewSessionToken ( $ oldSessionId , $ sessionId ) ; } catch ( SessionNotAvailableException $ ex ) { return false ; } catch ( InvalidTokenException $ ex ) { \ OC :: $ server -> getLogger ( ) -> warning ( 'Renewing session token failed' , [ 'app' => 'core' ] ) ; return false ; } $ this -> setMagicInCookie ( $ user -> getUID ( ) , $ newToken ) ; $ token = $ this -> tokenProvider -> getToken ( $ sessionId ) ; $ this -> setUser ( $ user ) ; $ this -> setLoginName ( $ token -> getLoginName ( ) ) ; $ this -> setToken ( $ token -> getId ( ) ) ; $ this -> lockdownManager -> setToken ( $ token ) ; $ user -> updateLastLoginTimestamp ( ) ; $ password = null ; try { $ password = $ this -> tokenProvider -> getPassword ( $ token , $ sessionId ) ; } catch ( PasswordlessTokenException $ ex ) { } $ this -> manager -> emit ( '\OC\User' , 'postRememberedLogin' , [ $ user , $ password ] ) ; return true ; }
perform login using the magic cookie (remember login)
 @param string $uid the username
 @param string $currentToken
 @param string $oldSessionId
 @return bool
perform login using the magic cookie ( remember login ) @param string $uid the username @param string $currentToken @param string $oldSessionId @return bool
// user does not exist // get stored tokens // test cookies token against stored tokens // replace successfully used token with a new one //login // Ignore