PHP User::createPassword Examples

PHP User::createPassword - 8 examples found. These are the top rated real world PHP examples of User::createPassword extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
 public function run()
 {
     $user = $this->controller->loadModel();
     //判断账号是否已激活
     if ($this->controller->_active_need && $user->status == User::STATUS_AUDIT) {
         $this->controller->redirect($this->controller->createUrl('activeEmail'));
     }
     //判断账号的密码是否为空
     if ($user->validatePassword()) {
         $password_empty = true;
     } else {
         $password_empty = false;
     }
     $model = new SetPwdForm();
     $model->id = $user->uid;
     if (isset($_POST['SetPwdForm'])) {
         $model->attributes = $_POST['SetPwdForm'];
         if (!$password_empty) {
             //校验原始密码
             $model->checkPwd();
         }
         if (!$model->getErrors() && $model->validate()) {
             $user->password = User::createPassword($model->newpassword);
             if ($user->save()) {
                 Yii::app()->user->logout(false);
                 //提示信息
                 Yii::app()->user->setFlash('success', Yii::t('common', 'Update Password Success'));
             }
         }
     }
     $this->controller->_seoTitle = Yii::t('common', 'User Setting') . ' - ' . Yii::t('common', 'Setting Pwd') . ' - ' . $this->controller->_setting['site_name'];
     $this->controller->render('setting_pwd', array('model' => $model, 'user' => $user, 'password_empty' => $password_empty));
 }
Example #2
0
 public function run()
 {
     $model = $this->controller->loadModel();
     if (isset($_POST['User'])) {
         if (empty($_POST['User']['password'])) {
             $_POST['User']['password'] = $model->password;
         } else {
             $_POST['User']['password'] = User::createPassword($_POST['User']['password']);
         }
         $model->attributes = $_POST['User'];
         if ($model->save()) {
             $this->controller->message('success', Yii::t('admin', 'Update Success'), $this->controller->createUrl('index'));
         }
     }
     $this->controller->render('update', array('model' => $model));
 }
Example #3
0
 /**
  * 保存修改
  * 
  * @return bool
  */
 public function save()
 {
     if ($this->validate()) {
         $transaction = Yii::app()->db->beginTransaction();
         try {
             $user = User::model()->findByPk(Yii::app()->user->id);
             $user->password = User::createPassword($this->newpassword);
             $user->save();
             $transaction->commit();
             return true;
         } catch (CHttpException $e) {
             $transaction->rollback();
             throw new CHttpException(500, '保存失败,请稍后重试');
         }
     }
     return false;
 }
Example #4
0
 public function run()
 {
     $authcode = urldecode(Yii::app()->request->getParam('authcode'));
     //解码
     $safestr = $this->controller->_setting['safe_str'];
     //安全密匙
     $decode = Helper::authcode($authcode, 'DECODE', $safestr);
     //解密
     if ($decode) {
         $id = intval($decode);
         $user = User::model()->findByPk($id);
         if (!$user) {
             $this->controller->message('error', Yii::t('common', 'Auth Account Do Not Exist'), $this->controller->createUrl('site/index'), 0, true);
         } else {
             $model = new ResetPwdForm();
             if (isset($_POST['ResetPwdForm'])) {
                 $model->attributes = $_POST['ResetPwdForm'];
                 if ($model->validate()) {
                     $user->password = User::createPassword($model->newpassword);
                     $user->save();
                     //清除session
                     unset(Yii::app()->session[$id . '_forgetpwd']);
                     $this->controller->message('success', Yii::t('common', 'ResetPwd Success'), $this->controller->createUrl('login'), 5);
                 }
             }
             //set seo
             $this->controller->_seoTitle = Yii::t('common', 'Reset Pwd') . ' - ' . $this->controller->_setting['site_name'];
             $this->controller->_seoKeywords = Yii::t('common', 'Reset Pwd');
             $this->controller->_seoDescription = Yii::t('common', 'Reset Pwd');
             //加载css,js
             Yii::app()->clientScript->registerCssFile($this->controller->_stylePath . "/css/user.css");
             Yii::app()->clientScript->registerScriptFile($this->controller->_static_public . "/js/jquery/jquery.js");
             $this->controller->render('resetpwd', array('model' => $model));
         }
     } else {
         $this->controller->message('error', Yii::t('common', 'The link is invalid'), $this->controller->createUrl('forgetPwd'), 0, true);
     }
 }
Example #5
0
<?php

require_once 'lib/path.php';
if (isset($_POST['submit'])) {
    header('Location: lostpass.php');
}
$user = User::getUserByEmail($_POST['email']);
if ($user) {
    $pass = User::createPassword();
    $user->changePassword($pass);
    $to = $_POST['email'];
    $subject = 'IRIN - Password Reset';
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
    $headers .= "From: IRIN <DoNotReply@irin.eotir.com>" . "\r\n";
    $message = 'You have requested a new password.<br /><br /><b>Login ID:</b> ' . $user->getUsername() . '<br /><b>New Password:</b> ' . $pass;
    //mail($to, $subject, $message, $headers);
    $mail->setFrom('DoNotReply@eotir.com', 'IRIN');
    $mail->addAddress($to);
    $mail->Subject = $subject;
    $mail->Body = $message;
    if (!$mail->send()) {
        throw new MailException($mail->ErrorInfo);
    }
    echo 'true';
} else {
    echo 'false';
}
Example #6
0
 private function resetPassword()
 {
     $oMysqli = Database::getInstance();
     $oResults = $oMysqli->query("SELECT * FROM tks_users WHERE id = '" . $this->oRequest->getParam('userid', 'int') . "'");
     if ($oResults->num_rows == 0) {
         throw new Error("Aucun compte ne correspond.", 1083);
     }
     $aResult = $oResults->fetch_assoc();
     if (crypt($aResult['mail'], $this->oRequest->getParam('key', 'string')) != $this->oRequest->getParam('key', 'string')) {
         throw new Error("Clé incorrecte.", 1083);
     }
     $sPassword = User::createPassword(12);
     $sCrypted = User::cryptPassword($sPassword);
     $oResults = $oMysqli->query("UPDATE tks_users SET pass = '{$sCrypted}' WHERE id = '" . $aResult['id'] . "'");
     $sMsg = "Bonjour " . $aResult['login'] . ",\n\nVoici votre nouveau mot de passe sur " . Config::get('sitetitle') . "\n\nMot de passe : \n{$sPassword}\n\n A bientôt,\nLe staff";
     mail($aResult['mail'], "[" . Config::get('sitetitle') . "] Nouveau mot de passe", $sMsg);
     $this->oView->addAlert("Le nouveau mot de passe a été envoyé par email ...", 'success');
 }
Example #7
0
 /**
  * 用户编辑
  *
  * @param  $id
  */
 public function actionUpdate($id)
 {
     $model = User::model()->findByPk($id);
     if (isset($_POST['User'])) {
         if (empty($_POST['User']['password'])) {
             $_POST['User']['password'] = $model->password;
         } else {
             $_POST['User']['password'] = User::createPassword($_POST['User']['password']);
         }
         $model->attributes = $_POST['User'];
         if ($model->save()) {
             $this->message('success', Yii::t('admin', 'Update Success'), $this->createUrl('index'));
         }
     }
     $this->render('user_update', array('model' => $model));
 }
 public function ActionReset()
 {
     $msg = '';
     if (isset($_POST['username'])) {
         $username = $_POST['username'];
         $password = User::createPassword($_POST['password']);
         $code = $_POST['code'];
         $sess_code = Yii::app()->session['smscode'];
         //echo $code;exit;
         if ($code != $sess_code) {
             $msg = "验证码错误";
         } else {
             $count = User::model()->updateAll(array('password' => $password), 'username=:username', array(':username' => $username));
             if ($count > 0) {
                 $this->redirect($this->createUrl('user/login'));
             } else {
                 $msg = "密码修改失败";
             }
         }
     }
     $this->_seoTitle = '找回密码';
     $this->render('reset', array('model' => $model, 'msg' => $msg, 'testcode' => $testcode));
 }