/** * Constructor. * * @param string $email An optional string of the user's email address. It * defaults to the current user's email address. * @param string $federated_identity The federated identity of user. It * defaults to the current user's federated identity. * @param string $federated_provider The federated provider url of user. * * @throws \InvalidArgumentException Thrown if both email and federated * identity are empty. */ public function __construct($email = null, $federated_identity = null, $federated_provider = null, $user_id = null) { $auth_domain = UserServiceUtil::getUserEnvironmentVariable('AUTH_DOMAIN'); assert($auth_domain !== false); if ($email === null and $federated_identity === null) { throw new \InvalidArgumentException('One of $email or $federated_identity must be set.'); } $this->email = $email; $this->federated_identity = $federated_identity; $this->federated_provider = $federated_provider; $this->auth_domain = $auth_domain; $this->user_id = $user_id; }
/** * Return true if the user making this request is an admin for this * application, false otherwise. * * We specifically make this a separate function, and not a member function * of the User class, because admin status is not persisted in the * datastore. It only exists for the user making this request right now. * * @return boolean Whether the current user is an administrator of the * application. */ public static function isCurrentUserAdmin() { return UserServiceUtil::getUserEnvironmentVariable('USER_IS_ADMIN') == '1'; }