本文整理匯總了PHP中models\User::setPassword方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::setPassword方法的具體用法?PHP User::setPassword怎麽用?PHP User::setPassword使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models\User
的用法示例。
在下文中一共展示了User::setPassword方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: registerUser
function registerUser($postdata)
{
$regname = htmlentities($postdata['regname']);
$regpass = htmlentities($postdata['regpass']);
$regauth = htmlentities($postdata['regauth']);
$regpass = hash('sha256', $regpass);
$user = new User();
$user->setName($regname);
$user->setPassword($regpass);
$user->setAuthlevel($regauth);
$user->save();
}
示例2: postregister
/**
* @BingingModel RegisterUserBingingModel
*/
public function postregister(RegisterUserBingingModel $userBindingModel)
{
if ($userBindingModel) {
$user = new User();
$user->setUsername($userBindingModel->getUsername());
$user->setPassword($userBindingModel->getPassword());
$user->setCash(10000);
$this->data->register($user);
}
$this->view->appendToLayout('main', 'register');
$this->view->display('layouts.default');
}
示例3: action
/**
* Function is used for registering new users.
* It checks entered data, register new user and redirects to user's twitter wall.
* User must enter security number to prevent robot attacks.
*/
public function action()
{
$main = new Main();
$main->setPageTitle("Sign up for TwitterApp");
$register = new \templates\Register();
$main->setBody($register);
echo $main;
if (post('register')) {
$firstName = htmlentities(trim(post('fname')));
$lastName = htmlentities(trim(post('lname')));
$username = htmlentities(trim(post('username')));
$password = trim(post('password'));
$hashedPassword = hash_password($password);
$confirmedPassword = trim(post('cpassword'));
$email = trim(post('email'));
$userSecurityNumber = (int) trim(post('security'));
//server-side validation
$error = false;
if (!ctype_alpha($firstName) || strlen($firstName) < 3 || strlen($firstName) > 25) {
$error = true;
}
if (!ctype_alpha($lastName) || strlen($lastName) < 3 || strlen($lastName) > 25) {
$error = true;
}
if (!ctype_alnum($username) || strlen($username) < 4 || strlen($lastName) > 25) {
$error = true;
}
if (!ctype_alnum($password) || strlen($password) < 4 || strlen($password) > 25) {
$error = true;
}
if (!ctype_alnum($confirmedPassword) || strlen($confirmedPassword) < 4 || strlen($confirmedPassword) > 25) {
$error = true;
}
if ($userSecurityNumber < 1113 || $userSecurityNumber > 1207) {
$error = true;
}
if ($password === $confirmedPassword && !$error) {
$user = new User();
$user->setFirstName($firstName);
$user->setLastName($lastName);
$user->setUsername($username);
$user->setPassword($hashedPassword);
$user->setEmail($email);
try {
UserRepository::registerUser($user);
} catch (\PDOException $e) {
$e->getMessage();
}
}
}
}
示例4: register
public function register()
{
if (!Router::active()->parent()) {
if (Tools::getValue('register')) {
$user = new User();
$user->setUsername(Tools::getValue('username'));
$user->setEmailAddress(Tools::getValue('email'));
$user->setPassword(Tools::getValue('password1'), Tools::getValue('password2'));
try {
if ($errors = $user->errors()) {
Log::addMessages(Log::ERROR, $errors);
} else {
Log::addMessages(Log::MESSAGE, array('Registration successful!'));
$user->execute()->persist();
}
} catch (Exception $e) {
Log::addMessage(Log::ERROR, array($e));
}
Router::redirect();
}
} else {
return $this->display('AuthController/register.tpl');
}
}
示例5: setPassword
public function setPassword($password)
{
$this->_load();
return parent::setPassword($password);
}
示例6: create
public function create()
{
if ($_POST['regPassword'] != $_POST['regPassword2']) {
$this->addPopup('danger', 'Hesla se neshodují.');
redirectTo("/registrace");
}
if (!User::checkRegistrationValidity()) {
redirectTo("/registrace");
}
$existing = User::checkExistingUsernameEmail();
if ($existing != NULL) {
if ($existing->getUsername() == $_POST["regUsername"]) {
$this->addPopup('danger', 'Uživatel se stejným uživatelským jménem je již zaregistrován.');
} elseif ($existing->getEmail() == $_POST["regEmail"]) {
$this->addPopup('danger', 'Uživatel se stejnou emailovou adresou je již zaregistrován.');
}
redirectTo("/registrace");
} else {
$token = token(50);
$user = new User();
$user->setIdImage(6);
$user->setUsername(strip_tags($_POST['regUsername']));
$user->setPassword(strip_tags(sha1($_POST['regPassword'])));
$user->setEmail(strip_tags($_POST['regEmail']));
$user->setUrl(strip_tags($_POST['regUsername']));
$user->setEmailConfirmToken($token);
$user->setPasswordResetToken(NULL);
$user->setPermissions(0);
$user->setSigninCount(0);
sendEmailConfirmationToken($user->getUsername(), $user->getEmailConfirmToken(), $user->getEmail());
$user->save();
$this->addPopup('success', 'Registrace proběhla úspěšně! Nyní se můžete přihlásit.');
redirectTo("/");
}
}
示例7: validateOne
protected function validateOne()
{
setContentType("json");
$user = new User();
$given = array_keys($_POST);
$response["error"] = null;
if (count($given) == 1) {
if ($given[0] == "username") {
$user->setUsername($_POST["username"]);
} else {
if ($given[0] == "password") {
$user->setPassword($_POST["password"]);
} else {
if ($given[0] == "email") {
$user->setEmail($_POST["email"]);
} else {
if ($given[0] == "name") {
$user->setName($_POST["name"]);
} else {
if ($given[0] == "surname") {
$user->setSurname($_POST["surname"]);
} else {
setHTTPStatusCode("400");
return;
}
}
}
}
}
if (!$user->validate()) {
foreach ($user->getValidationFailures() as $failure) {
if ($given[0] == $failure->getPropertyPath()) {
$response["error"] = array("name" => $failure->getPropertyPath(), "message" => $failure->getMessage());
}
}
}
$this->viewString(json_encode($response));
} else {
setHTTPStatusCode("400");
}
}