本文整理汇总了PHP中self::setPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP self::setPassword方法的具体用法?PHP self::setPassword怎么用?PHP self::setPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类self
的用法示例。
在下文中一共展示了self::setPassword方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createWithEmail
static function createWithEmail($email, $password)
{
$sender = new self();
$sender->setEmail($email);
$sender->setPassword($password);
return $sender;
}
示例2: withPassword
/**
* Creates a new Credentials object with the AuthMode::PASSWORD authorization mode. Requires username and password.
*
* @param string $username Authorization username
* @param string $password Authorization password
* @return Credentials
*/
public static function withPassword($username, $password)
{
$instance = new self();
$instance->setMode(AuthMode::PASSWORD);
$instance->setUsername($username);
$instance->setPassword($password);
return $instance;
}
示例3: initWithArray
public static function initWithArray($array)
{
$instance = new self(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
$instance->setName($array[User::USER_NAME]);
$instance->setPassword($array[User::USER_PASSWORD]);
$instance->setEventcode($array[User::USER_EVENTCODE]);
$instance->setValidate($array[User::USER_VALIDATE]);
$instance->setRoll($array[User::USER_ROLL]);
$instance->setPage($array[User::USER_PAGE]);
$instance->setMac($array[User::USER_MAC]);
$instance->setSignup($array[User::USER_SIGNUP]);
$instance->setLastlogin($array[User::USER_LASTLOGIN]);
$instance->setTypefromCode();
return $instance;
}
示例4: fromChallenge
/**
* Read digest realm and accompanying data from HTTP response
* and construct an instance of this class.
*
* @param string $header
* @param string $user
* @param security.SecureString $pass
* @return peer.http.DigestAuthorization
*/
public static function fromChallenge($header, $user, $pass)
{
if (!preg_match_all('#(([a-z]+)=("[^"$]+)")#m', $header, $matches, PREG_SET_ORDER)) {
throw new IllegalStateException('Invalid WWW-Authenticate line');
}
$values = array('algorithm' => 'md5', 'opaque' => NULL);
foreach ($matches as $m) {
$values[$m[2]] = trim($m[3], '"');
}
if ($values['algorithm'] != 'md5') {
throw new MethodNotImplementedException('Digest auth only supported via algo "md5".', 'digest-md5');
}
$auth = new self($values['realm'], $values['qop'], $values['nonce'], $values['opaque']);
$auth->setUsername($user);
$auth->setPassword($pass);
return $auth;
}
示例5: createUserLoginDetails
public static function createUserLoginDetails($id)
{
$userObject = new self();
$query = "SELECT * FROM TUSERS U WHERE U.`User ID` = {$id}";
$user = db_select($query);
$userObject->setUserId($id);
$userObject->setEmail($user[0]['Email']);
$userObject->setRole($user[0]['Role']);
$userObject->setLocked($user[0]['Locked']);
$userObject->setLockedTime($user[0]['Locked Time']);
$userObject->setLastFailedLogin($user[0]['Last Failed Login']);
$userObject->setLoginAttempts($user[0]['Login Attempts']);
$userObject->setPassword($user[0]['Password']);
$userObject->setSalt($user[0]['Salt']);
$userObject->setValidation($user[0]['Validation']);
return $userObject;
}
示例6: factory
public static function factory($config = array())
{
// Provide a hash of default client configuration options
$default = array('base_url' => 'https://campbx.com/api');
// The following values are required when creating the client
$required = array('base_url', 'username', 'password');
// merge in default settings and validate the config
$config = Collection::fromConfig($config, $default, $required);
$client = new self($config->get('base_url'), $config);
$client->setUsername($config['username']);
$client->setPassword($config['password']);
// use description file to configure the client
$servicesDescriptionFilename = dirname(__FILE__) . '/service-description.json';
$description = ServiceDescription::factory($servicesDescriptionFilename);
$client->setDescription($description);
return $client;
}
示例7: createTemporary
public static function createTemporary($_hours)
{
$user = new self();
$user->setLogin('temp_' . config::genKey());
$user->setPassword(config::genKey(45));
$user->setRights('admin', 1);
$user->setOptions('validity_limit', date('Y-m-d H:i:s', strtotime('+' . $_hours . ' hour now')));
$user->save();
return $user;
}
示例8: getByOpenID
/**
* Return (or create, assuming no external auth backend) a user based on
* a provided openid identity
*
* @param string $identity
*
* @return \thebuggenie\core\entities\User
*/
public static function getByOpenID($identity)
{
$user = null;
if ($user_id = tables\OpenIdAccounts::getTable()->getUserIDfromIdentity($identity)) {
$user = \thebuggenie\core\entities\User::getB2DBTable()->selectById($user_id);
} elseif (!framework\Settings::isUsingExternalAuthenticationBackend() && framework\Settings::getOpenIDStatus() == 'all') {
$user = new self();
$user->setPassword(self::createPassword());
$user->setUsername(self::createPassword() . self::createPassword());
$user->setOpenIdLocked();
$user->setActivated();
$user->setEnabled();
$user->setValidated();
$user->save();
}
return $user;
}
示例9: renderStatic
/**
* Returns Data Source Name String.
* @access public
* @static
* @param string $driver Database Driver (cubrid|dblib|firebird|informix|mysql|mssql|oci|odbc|pgsql|sqlite|sybase)
* @param string $database Database Name
* @param string $host Host Name or URI
* @param int $port Host Port
* @param string $username Username
* @param string $password Password
* @return string
*/
public static function renderStatic($driver, $database, $host = NULL, $port = NULL, $username = NULL, $password = NULL)
{
$dsn = new self($driver, $database);
$dsn->setHost($host);
$dsn->setPort($port);
$dsn->setUsername($username);
$dsn->setPassword($password);
return $dsn->render();
}
示例10: create
/**
* Factory that fills the required fields of the user.
*
* @param string $username
* @param string $password
* @param string $email
*
* @return User
*/
public static function create($username, $password, $email)
{
$user = new self();
$user->setUsername($username);
$user->setPassword($password);
$user->setEmail($email);
return $user;
}
示例11: add
/**
* Adds the user to the database.
* There are bunch of required parameters required to be passed as $params array:
* - login: the arbitrary string which will be used as a login for the user. The checks defined in
* {@link setLogin} method will be performed.
* - password: user's password. The checks defined in {@link setPassword} will be performed.
* - email: required parameter to, for example, send confirmation emails. The checks defined in
* {@link setEmail} method will be performed.
*
* Optionally, the 'state' parameter may be passed, showing the status of newly created user.
* If it's omitted, the "not_confirmed" or "active" state will be chosen depending on the
* <code>config.user.registration_confirm</code> config parameter. If the value distinguish
* from the described ones, make sure that this value could be held by the DB schema of the 'state' column.
*
* If <code>config.user.registration_confirm</code> config parameter is set to non-false value,
* the one time token will be added for newly created user. This could be used for example to
* send activation email. Logic behind that should be created separately in the model/controller.
*
* Additionally, the profile entry for the new user will be created.
*
* Behavior BeforeAddNewUser is defined.
*
* @param array parameters for the new user as described above
* @return User new user object
* @throws UserException in case of errors
*/
static function add(array $params)
{
if (empty($params['login']) || empty($params['password']) || empty($params['email'])) {
throw new UserException("Login, password and email must be passed");
}
$config = Config::getInstance();
if (empty($params['state'])) {
$params['state'] = $config->user->registration_confirm ? "not_confirmed" : "active";
}
if (self::findBy('login', $params['login'])) {
throw new UserException("User with the same login already exists");
}
$new_user = new self(null);
$new_user->setLogin($params['login']);
$new_user->setPassword($params['password']);
$new_user->setState($params['state']);
$new_user->setEmail($params['email']);
$new_user->trigger("BeforeAddNewUser", array($new_user, &$params));
$new_user->save();
$one_time_token = null;
if ($config->user->registration_confirm) {
$one_time_token = OneTimeTokenAuth::generateAndAddToken($new_user->getId());
}
Profile::addUser($new_user->getId());
return $new_user;
}
示例12: fromOAuthResponse
/**
* @param UserResponseInterface $response
* @return User
* @throws \InvalidArgumentException
*/
public static function fromOAuthResponse(UserResponseInterface $response)
{
$user = new self();
$user->setPassword('whatever');
$user->setEnabled(true);
switch ($response->getResourceOwner()->getName()) {
case 'facebook':
$user->setFacebookId($response->getResponse()['id']);
$user->setUsername('fb-' . $response->getResponse()['id']);
$user->setDisplayableName($response->getResponse()['name']);
if (isset($response->getResponse()['email']) && $response->getResponse()['email']) {
$user->setEmail($response->getResponse()['email']);
} else {
$user->setEmail('fb-no-email-' . md5(rand()) . '@example.com');
}
$user->setPictureUrl($response->getResponse()['picture']['data']['url']);
break;
case 'vkontakte':
$responseInner = $response->getResponse()['response'][0];
$user->setVkontakteId($responseInner['uid']);
$user->setUsername('vk-' . $responseInner['uid']);
$user->setDisplayableName($responseInner['first_name'] . ' ' . $responseInner['last_name']);
if ($response->getResponse()['email']) {
$user->setEmail($response->getResponse()['email']);
} else {
//in VK user can hide his email, but FOS treats email as mandatory
$user->setEmail('vk-hidden-email-' . md5(rand()) . '@example.com');
}
$user->setPictureUrl($responseInner['photo_medium']);
break;
case 'twitter':
$user->setTwitterId($response->getResponse()['id']);
$user->setUsername('twitter-' . $response->getResponse()['id']);
$user->setDisplayableName($response->getResponse()['name']);
$user->setEmail('twitter-email-' . md5(rand()) . '@example.com');
$user->setPictureUrl($response->getResponse()['profile_image_url']);
break;
case 'google':
$user->setGoogleId($response->getResponse()['id']);
$user->setUsername('google-' . $response->getResponse()['id']);
$user->setDisplayableName($response->getResponse()['name']);
$user->setEmail($response->getResponse()['email']);
$user->setPictureUrl($response->getResponse()['picture']);
break;
default:
throw new \InvalidArgumentException(sprintf('Resource owner `%` is not supported', $response->getResourceOwner()->getName()));
}
return $user;
}
示例13: fromEnvironment
/**
* Builds a new URI object from server environment
*
* @param array $environment Server environment (e.g. $_SERVER)
* @return Uri
*/
public static function fromEnvironment(array $environment)
{
$uri = new self();
$uri->setScheme(isset($environment['HTTPS']) && ($environment['HTTPS'] == 'on' || $environment['HTTPS'] == 1) || isset($environment['HTTP_X_FORWARDED_PROTO']) && $environment['HTTP_X_FORWARDED_PROTO'] == 'https' ? 'https' : 'http');
$uri->setHostname($environment['HTTP_HOST']);
$uri->setPort(isset($environment['SERVER_PORT']) ? (int) $environment['SERVER_PORT'] : NULL);
$uri->setUsername(isset($environment['PHP_AUTH_USER']) ? $environment['PHP_AUTH_USER'] : NULL);
$uri->setPassword(isset($environment['PHP_AUTH_PW']) ? $environment['PHP_AUTH_PW'] : NULL);
$requestUriParts = explode('?', $environment['REQUEST_URI'], 2);
$uri->setPath($requestUriParts[0]);
if (isset($requestUriParts[1])) {
$queryParts = explode('#', $requestUriParts[1], 2);
$uri->setQuery($queryParts[0]);
$uri->setFragment(isset($queryParts[1]) ? $queryParts[1] : NULL);
}
return $uri;
}
示例14: withValues
public static function withValues($email, $password, $isDriver = false, $isDispatcher = false, $isfirstTime = false, $isAdmin = false, $firstName = null, $lastName = null)
{
// Calls private user constructor with provided arguments
$instance = new self($email, $isDriver, $isDispatcher, $isfirstTime, $isAdmin, $firstName, $lastName);
// Sets password. Returns null on error
try {
$instance->setPassword($password);
} catch (InvalidArgumentException $e) {
return null;
}
$db = DB::getInstance();
try {
$result = $db->multi_prep_execute(['INSERT INTO users (email, isAdmin, isDispatcher, isfirstTime, isDriver, firstName, lastName) VALUES (:email, :isAdmin, :isDispatcher, :isfirstTime, :isDriver, :firstName, :lastName);', 'INSERT INTO passwords (email, password) VALUES (:email, :password);'], array([':email' => $instance->getEmail(), ':isAdmin' => $instance->getIsAdmin(), ':isDriver' => $instance->getIsDriver(), ':isDispatcher' => $instance->getIsDispatcher(), ':isfirstTime' => $instance->getIsfirstTime(), ':firstName' => $instance->getFirstName(), ':lastName' => $instance->getLastName()], [':email' => $instance->getEmail(), ':password' => $instance->password]));
if ($result) {
$instance->setInDB(true);
}
} catch (PDOException $e) {
}
// Returns new user object
return $instance;
}