Update the active user (i.e. during login/logout/etc.)
@param updatedUser
@param jwt
359812
function login(updatedUser, jwt) {
        storage.set('jwt', 'Bearer ' + jwt);    // set the token in local storage
        removeUserVals();                       // remove old user values
        _.extend(user, updatedUser);            // add new user values
        eventBus.emit('user.init');             // let everyone else know there is a new user in town
    }
122117
private HeaderCacheElement updateToken() {
    HeaderCacheElement newToken;
    try {
      LOG.info("Refreshing the OAuth token");
      newToken = new HeaderCacheElement(credentials.refreshAccessToken());
    } catch (Exception e) {
      LOG.warn("Got an unexpected exception while trying to refresh google credentials.", e);
      newToken = new HeaderCacheElement(
          Status.UNAUTHENTICATED
              .withDescription("Unexpected error trying to authenticate")
              .withCause(e)
      );
    }
    synchronized (lock) {
      // Update the token only if the new token is good or the old token is bad
      if (newToken.isValid() || !headerCache.isValid()) {
        headerCache = newToken;
      } else {
        LOG.warn("Failed to refresh the access token. Falling back to existing token. "
            + "New token state: {}, status: {}", newToken.getCacheState(), newToken.getToken().status);
      }
      futureToken = null;

      return headerCache;
    }
  }
387069
public function login(JWTSubject $user)
    {
        $this->setUser($user);

        return $this->jwt->fromUser($user);
    }
1293292
def update(self, access_token=None, id_token=None, id_token_jwt=None, userinfo=None):
        

        def set_if_defined(session_key, value):
            if value:
                self._session_storage[session_key] = value

        auth_time = int(time.time())
        if id_token:
            auth_time = id_token.get('auth_time', auth_time)

        self._session_storage['last_authenticated'] = auth_time
        set_if_defined('access_token', access_token)
        set_if_defined('id_token', id_token)
        set_if_defined('id_token_jwt', id_token_jwt)
        set_if_defined('userinfo', userinfo)
273888
private static void renewCCTokenAsync(final Jwt jwt) {
        // Not expired yet, try to renew async but let requests use the old token.
        logger.trace("In renew window but token is not expired yet.");
        if(!jwt.isRenewing() || System.currentTimeMillis() > jwt.getEarlyRetryTimeout()) {
            jwt.setRenewing(true);
            jwt.setEarlyRetryTimeout(System.currentTimeMillis() + jwt.getEarlyRefreshRetryDelay());
            logger.trace("Retrieve token async is called while token is not expired yet");

            ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();

            executor.schedule(() -> {
                Result<Jwt> result = getCCTokenRemotely(jwt);
                if(result.isFailure()) {
                    // swallow the exception here as it is on a best effort basis.
                    logger.error("Async retrieve token error with status: {}", result.getError().toString());
                }
                //set renewing flag to false after response, doesn't matter if it's success or fail.
                jwt.setRenewing(false);
            }, 50, TimeUnit.MILLISECONDS);
            executor.shutdown();
        }
    }
197529
public function updateRememberToken(UserContract $user, $token)
    {
        $user->setRememberToken($token);

        $timestamps = $user->timestamps;

        $user->timestamps = false;

        $user->save();

        $user->timestamps = $timestamps;
    }
565016
private User updateUserStandard(LdapName originalId, User existingUser) {
        User savedUser = userRepo.save(existingUser);

        if(!originalId.equals(savedUser.getId())) {
            // The user has moved - we need to update group references.
            LdapName oldMemberDn = toAbsoluteDn(originalId);
            LdapName newMemberDn = toAbsoluteDn(savedUser.getId());

            Collection<Group> groups = groupRepo.findByMember(oldMemberDn);
            updateGroupReferences(groups, oldMemberDn, newMemberDn);
        }
        return savedUser;
    }
1102035
public void update( JSONObject json )
    {
        accessToken = json.getString( ACCESS_TOKEN );
        tokenType = json.getString( TOKEN_TYPE );
        expiresAt = calculateExpiresAt( json );
        if ( json.has( OAuth2.REFRESH_TOKEN ) ) {
            refreshToken = json.getString( OAuth2.REFRESH_TOKEN );
        }
    }
565342
public synchronized void refreshWithToken(String clientToken, String accessToken) throws AuthenticationException {
		authResult = authenticationService.refresh(Objects.requireNonNull(clientToken), Objects.requireNonNull(accessToken));
	}
395370
public function login(JwTSubject $user)
    {
        $this->setUser($user);

        return $this->jwT->fromUser($user);
    }
697601
public void setActiveSession(HttpSession activeSession) {
		if (log.isInfoEnabled()) {
			log.info("Setting new active session for site '" + site + "': " + activeSession);
		}
		if (activeSession == null) {
			throw new IllegalArgumentException(
					"When settting an active session, a non-null session has to be provided.");
		}

		if (this.activeSession == activeSession) {
			return;
		}

		if (this.activeSession != null) {
			this.activeSession.setActive(false);
			// If the active session was one with no tokens, delete it, as it will probably not
			// match anything from this point forward
			if (this.activeSession.getTokenValuesCount() == 0) {
				this.removeHttpSession(this.activeSession);
			} else {
				// Notify the model that the session is updated
				model.fireHttpSessionUpdated(this.activeSession);
			}
		}
		this.activeSession = activeSession;
		activeSession.setActive(true);
		// Notify the model that the session is updated
		model.fireHttpSessionUpdated(activeSession);
	}
295726
private function refreshRememberCookie(UserInterface $user, $gerenateToken = true)
    {
        $expire = is_numeric($this->expire) ? time() + 60 * $this>expire : strtotime("+" . $this->expire);
        if (!$gerenateToken) {
            $token = $_COOKIE[$this->cookieName];
        } else {
            $token = $this->randomPassword(32);
        }

        $this->rememberMeProvider->setUserRememberMeToken($user, $token);

        setcookie($this->cookieName, $token, $expire, $this->url);
    }
898293
public static void setUser(Object user)
    {
        HttpSession session = WebContextFactory.get().getSession(true);
        session.setAttribute(USER, user);
    }
570590
private synchronized void refreshAccessToken() throws ConnectionException, HTTPException {
        if (!isTokenExpired()) {
            return;
        }

        Map<String, String> params = new HashMap<>();
        params.put(Constants.PARAM_CLIENT_ID, clientId);
        params.put(Constants.PARAM_CLIENT_SECRET, clientSecret);

        if (isUserAuthFlow() && accessToken.getRefreshToken() != null) {
            // For user based authentication, refresh the token
            params.put(Constants.PARAM_GRANT_TYPE, Constants.GRANT_TYPE_REFRESH_TOKEN);
            params.put(Constants.PARAM_REFRESH_TOKEN, accessToken.getRefreshToken());

        } else {
            // For app based authentication, reload the token
            params.put(Constants.PARAM_GRANT_TYPE, Constants.GRANT_TYPE_CLIENT_CREDENTIALS);
        }

        loadAccessToken(params);
    }
961345
def update_user(resource_root, user):
  
  return call(resource_root.put,
      '%s/%s' % (USERS_PATH, user.name), ApiUser, data=user)
3338
function(user) {
        var promise;
        if (AV.User._currentUser !== user) {
          promise = AV.User.logOut();
        } else {
          promise = Promise.resolve();
        }
        return promise.then(function() {
          user._isCurrentUser = true;
          AV.User._currentUser = user;

          var json = user._toFullJSON();
          json._id = user.id;
          json._sessionToken = user._sessionToken;
          return AV.localStorage
            .setItemAsync(
              AV._getAVPath(AV.User._CURRENT_USER_KEY),
              JSON.stringify(json)
            )
            .then(function() {
              AV.User._currentUserMatchesDisk = true;
              return AV._refreshSubscriptionId();
            });
        });
      }
1190925
public ServerUpdater addRoleToUser(User user, Role role) {
        delegate.addRoleToUser(user, role);
        return this;
    }