Save user in Redis Client
@param  {!Auth} user
@param  {!String} tokenOrEmail
@param  {!Object} config
772742
function saveUserInRedis(user, tokenOrEmail, config) {
  if (config.redisClient) {
    const key = `${ns}:${tokenOrEmail}`;
    config.redisClient.set(key, JSON.stringify(user.data_), 'EX', 10);
  }
}
1237901
function buildXOAuth2Token(user = '', token) {
  let authData = [`user=${user}`, `auth=Bearer ${token}`, '', ''];
  return (0, _emailjsBase.encode)(authData.join('\x01'));
}
639400
function (model) {
              var tokenCode = 'token-' + md5(new Date().toString()) + md5(model.id + Math.random().toString());
              var redisExpire = (global._gluon_auth_expire) >>> 0; //redis using seconds not milliseconds
              return redisClient.setAsync(tokenCode, JSON.stringify(model.toJSON())).then(function () {
                return redisClient.expireAsync(tokenCode, redisExpire);
              }).then(function () {
                return {code: tokenCode, expire: new Date(Date.now() + redisExpire * 1000)};
              });
            }
528435
public function updateRememberToken(AuthenticatableContract $user, $token) {
	    if(!empty($user)) {
	    	// make sure there is a remember_token field available for
	    	// updating before trying to update; otherwise we run into
	    	// an uncatchable exception
	    	if($user->canHaveRememberToken()) {
	    		$user->remember_token = $token;
	    		$user->save();
	    	}
	    }
    }
832729
function readNotifyUser(message, tokens) {
	message.userName = protocol.decodeString(tokens[1]);
	message.userPassword = protocol.decodeString(tokens[3]);
	readNotifyUserHeaders(message, tokens.slice(4));
}
83508
function (req, res, next) {
	// console.log('req.body', req.body);
	// console.log('req.params', req.params);
  var user_token = req.params.token || req.body.token; //req.controllerData.token;
  waterfall([
    function (cb) {
      cb(null, req, res, next);
    },
    invalidateUserToken,
    resetPassword,
    saveUser,
    emailResetPasswordNotification,
  ],
		function (err, results) {
  if (periodic.app.controller.extension.reactadmin) {
    let reactadmin = periodic.app.controller.extension.reactadmin;
    if (err) {
      res.status(400).send({
        result: 'error',
        data: {
          error:err.toString(),
        },
      });
    } else {
      res.status(200).send({
        result: 'success',
        data:'Password successfully changed',
      });
    }
  } else { 
				// console.log('These are the err', err);
				// console.log('These are the results', results);
    CoreController.respondInKind({
      req: req,
      res: res,
      err: err,
      responseData: results || {},
      callback: function (req, res /*,responseData*/ ) {
						// console.log('err',err,'/auth/reset/' + user_token);
        if (err) {
							// console.log('return to reset');
          req.flash('error', err.message);
          res.redirect('/auth/reset/' + user_token);
        }						else {
							// console.log('no return to x');
          req.flash('success', 'Password Sucessfully Changed!');
          res.redirect(loginExtSettings.settings.authLoginPath);
        }
      },
    });
  }
});
}
1197111
public function setRefreshTokenForUser($adminUser, $token)
    {
        $adminUser = $adminUser->setRefreshToken($token);
        $this->userResource->save($adminUser);
    }
522890
public function save($userid, $apikey, $scope, $name, $args, $xml)
    {
        $key = $this->getKey($userid, $apikey, $scope, $name, $args);
        $timeout = $this->getTimeout($xml);

        return $this->redis->set($key, $xml, 'ex', $timeout);
    }
1048412
function(req, user){
      req.session.authenticated = true;
      req.session.user = user;
    }
1288115
function (req, res, next) {
    var prifile = req.profile;
    var filter = { or: [{ twitter: profile.user_id }, { email: profile.email }] };

    User.find({ where: filter }, function(err, users) {
      var user = users[0];

      if (user) {
        if (!user.twitter) {
          user.twitter = profile.user_id;
          user.displayName = user.displayName || profile.name;
          user.save(function() {
            req.user = user;
            next();
          });
          return;
        }

        req.user = user;
        next();
        return;
      }

      User.create({
        displayName: profile.name,
        yahoo: profile.user_id,
        email: profile.email,
        password: profile.user_id
      }, function (err, user) {
        req.user = user;
        next();
      });

    });
  }
1137484
function(token) {
        this.oauthClient.setCredentials(token);
        this.brain.set(this.TOKEN_KEY, token.access_token);
        if (token.refresh_token) {
            this.brain.set(this.REFRESH_KEY, token.refresh_token);
        }
        this.brain.set(this.EXPIRY_KEY, +token.expiry_date);
        this.brain.save();
        this.brain.resetSaveInterval(60);
    }
824851
def generate_user_token(self, user, salt=None):
        
        return self.token_serializer.dumps(str(user.id), salt=salt)
1352365
private Auth constructAuth(String authToken, String tokenSecret, String username) throws IOException {

        Auth auth = new Auth();
        auth.setToken(authToken);
        auth.setTokenSecret(tokenSecret);

        // Prompt to ask what permission is needed: read, update or delete.
        auth.setPermission(Permission.fromString("delete"));

        User user = new User();
        // Later change the following 3. Either ask user to pass on command line or read
        // from saved file.
        user.setId(nsid);
        user.setUsername((username));
        user.setRealName("");
        auth.setUser(user);
        this.authStore.store(auth);
        return auth;
    }
775798
function(userId, extraData = {}) {
    if (!this.usingApiSecret || this.apiKey == null) {
      throw new errors.FeedError(
        'In order to create user tokens you need to initialize the API client with your API Secret',
      );
    }
    return signing.JWTUserSessionToken(this.apiSecret, userId, extraData, {
      noTimestamp: !this.expireTokens,
    });
  }
1250881
def configure(obj, token):
    
    config = obj.get('config') or FileConfig(obj['profile'])
    config.auth_token = token
    config.save()
263678
function putAuthUser(req, res) {
    var query;
    var update;

    // Check if the user is actually logged in. We should try to update info
    // for an anonymous user.
    if (!(req.user && req.user.data)) {
      res.status(401).send('Not authenticated');

      return;
    }

    // For right now, we do not allow the user to change their username if it
    // has been set before.
    if (req.user.username) {
      res.status(422).send(
        'You cannot change the user name of a registered user.');
      return;
    }

    // Setup and execute an update query.
    query = {
      provider: req.user.data.provider,
      idWithProvider: req.user.data.idWithProvider
    };
    update = {
      username: req.body.username
    };

    providerAccounts.update(query, update).exec()
      .then(function () {

        // Now we need to update user's data in the session. The simplest way
        // to do that is to first get the current user's data.
        return oauth.getUserFromProfile(providerAccounts, req.user.data)
          .then(function (userRecord) {
            if (!userRecord) {
              throw new Error('Could not get user record.');
            }
            // Once we have the userRecord, we try to update the session.
            if (authConfig.maintenance === 'cookie') {
              req.login(userRecord, function (error) {
                if (error) {
                  throw error;
                } else {
                  res.status(200).send(userRecord);
                }
              });
            } else {
              // generate a new token
              var secrets = config.getConfig('secrets');
              var currentToken = req.headers.authorization.replace(
                'Bearer ', '');
              var decodedToken = jwt.decode(currentToken);

              var expiresInMinutes = 60;
              decodedToken.data.username = userRecord.data.username;
              var newToken = generateToken(decodedToken.data,
                expiresInMinutes,
                secrets.authTokenSecret);

              userRecord.meta = userRecord.meta || {};
              userRecord.meta.token = newToken;
              userRecord.meta.expires = getExpirationTime(
                expiresInMinutes);

              log.debug('getNewToken requested with: ', currentToken);
              log.debug('token decoded as :', decodedToken);


              res.status(200).send(userRecord);
            }
          });
      })
      .then(null, util.makeErrorResponder(res));
  }
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();
            });
        });
      }