当前位置: 首页>>代码示例>>PHP>>正文


PHP UserModule::encrypting方法代码示例

本文整理汇总了PHP中UserModule::encrypting方法的典型用法代码示例。如果您正苦于以下问题:PHP UserModule::encrypting方法的具体用法?PHP UserModule::encrypting怎么用?PHP UserModule::encrypting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserModule的用法示例。


在下文中一共展示了UserModule::encrypting方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionRegistration

	/**
	 * Registration user
	 */
	public function actionRegistration() 
	{
        
        if(Y::module()->isRegistrationClose) $this->redirect('close');
		$model = new RegistrationForm;
        $profile=new Profile;
        $profile->regMode = true;
            
		// ajax validator
		if(isset($_POST['ajax']) && $_POST['ajax']==='registration-form')
			Y::end(UActiveForm::validate(array($model,$profile)));
		
		if (Y::userId()) {
			$this->redirect(Y::module()->cabinetUrl);
		} else {
			if(isset($_POST['RegistrationForm'])) {
				$model->attributes=$_POST['RegistrationForm'];
				$profile->attributes= isset($_POST['Profile'])?$_POST['Profile']:array();
				if($model->validate()&&$profile->validate())
				{
					$soucePassword = $model->password;
					$model->activkey=UserModule::encrypting(microtime().$soucePassword);
					$model->password=UserModule::encrypting($soucePassword);
					$model->verifyPassword=UserModule::encrypting($model->verifyPassword);
					$model->createtime=time();
					$model->lastvisit=((Y::module()->loginNotActiv||(Y::module()->activeAfterRegister&&Y::module()->sendActivationMail==false))&&Y::module()->autoLogin)?time():0;
					$model->superuser=0;
					$model->status=((Y::module()->activeAfterRegister)?User::STATUS_ACTIVE:User::STATUS_NOACTIVE);
						
					if ($model->save()) {
						$profile->user_id=$model->id;
						$profile->save();
						if (Y::module()->sendActivationMail) {
							$activation_url = $this->createAbsoluteUrl('/user/activation',array("activkey" => $model->activkey, "email" => $model->email));
							UserModule::sendMail($model->email,Users::t("You registered from {site_name}",array('{site_name}'=>Yii::app()->name)),Users::t("Please activate you account go to {activation_url}",array('{activation_url}'=>$activation_url)));
						}
							
						if ((Y::module()->loginNotActiv||(Y::module()->activeAfterRegister&&Y::module()->sendActivationMail==false))&&Y::module()->autoLogin) {
							$identity=new UserIdentity($model->username,$soucePassword);
								$identity->authenticate();
								Y::user()->login($identity,0);
								$this->redirect(Y::module()->returnUrl);
						} else {
							if (!Y::module()->activeAfterRegister&&!Y::module()->sendActivationMail) {
								Y::flash('/user/registration',Users::t("Thank you for your registration. Contact Admin to activate your account."));
							} elseif(Y::module()->activeAfterRegister&&Y::module()->sendActivationMail==false) {
								Y::flash('/user/registration',Users::t("Thank you for your registration. Please {{login}}.",array('{{login}}'=>CHtml::link(Users::t('Login'),Y::module()->loginUrl))));
							} elseif(Y::module()->loginNotActiv) {
								Y::flash('/user/registration',Users::t("Thank you for your registration. Please check your email or login."));
							} else {
								Y::flash('/user/registration',Users::t("Thank you for your registration. Please check your email."));
							}
							$this->refresh();
						}
					}
				} else $profile->validate();
			}
		    $this->render('/user/registration',array('model'=>$model,'profile'=>$profile,'lang'=>Yii::app()->language));
	    }
	}
开发者ID:nizsheanez,项目名称:PolymorphCMS,代码行数:63,代码来源:RegistrationController.php

示例2: actionActivation

 /**
  * Activation d'un compte utilisateur. En principe on arrive ici avec une url d'activation
  * qui a été fournie par mail à l'utilisateur
  */
 public function actionActivation()
 {
     $email = trim($_GET['email']);
     $activkey = trim($_GET['activkey']);
     if ($email && $activkey) {
         /** @var User $user */
         $user = User::model()->findByAttributes(array('email' => $email));
         if (isset($user) && $user->status) {
             // compte déjà activé
             $this->render('/user/message', array('title' => Yii::t("UserModule.user", "User activation"), 'content' => Yii::t("UserModule.msg", "Your account is already active")));
         } elseif (isset($user) && isset($user->activkey) && $user->activkey == $activkey) {
             // on enregistre une nouvelle clé d'activation pour éviter une activation parasite sur ce compte par la suite
             $user->activkey = UserModule::encrypting(microtime());
             // activation du compte
             $user->status = 1;
             if (!$user->save()) {
                 $this->render('/user/message', array('title' => Yii::t("UserModule.user", "User activation"), 'content' => Yii::t("UserModule.msg", "The activation has failed. Please contact the administrator")));
             } else {
                 $this->render('/user/message', array('title' => Yii::t("UserModule.user", "User activation"), 'content' => Yii::t("UserModule.msg", "Your account has been successfully activated")));
             }
         } else {
             // erreur : utilisateur inconnu, clé d'activation incorrecte...
             $this->render('/user/message', array('title' => Yii::t("UserModule.user", "User activation"), 'content' => Yii::t("UserModule.msg", "Incorrect activation URL")));
         }
     } else {
         // erreur sur les paramètres du $_GET
         $this->render('/user/message', array('title' => Yii::t("UserModule.user", "User activation"), 'content' => Yii::t("UserModule.msg", "Incorrect activation URL")));
     }
 }
开发者ID:ChristopheBrun,项目名称:hLib,代码行数:33,代码来源:ActivationController.php

示例3: actionActivation

	/**
	 * Activation user account
	 */
	public function actionActivation () {
		$email = $_GET['email'];
		$activkey = $_GET['activkey'];
		if ($email&&$activkey) {
			$find = User::model()->notsafe()->findByAttributes(array('email'=>$email));
			if (isset($find)&&$find->status) {
			    $this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("You account is active.")));
			} elseif(isset($find->activkey) && ($find->activkey==$activkey)) {
				$find->activkey = UserModule::encrypting(microtime());
				$find->status = 1;
				$find->save();
                if (!Yii::app()->controller->module->autoLogin) {
                    $this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("You account is activated.")));
                } else {
                    $identity=new UserIdentity($find->username, '');
                    $identity->authenticate(true);
                    Yii::app()->user->login($identity,0);
                    Yii::app()->user->setFlash('userActivationSuccess', UserModule::t("You account is activated."));
                    $this->redirect(Yii::app()->controller->module->returnUrl);
                }
			} else {
			    $this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("Incorrect activation URL.")));
			}
		} else {
			$this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("Incorrect activation URL.")));
		}
	}
开发者ID:rallin,项目名称:yii-user,代码行数:30,代码来源:ActivationController.php

示例4: authenticate

 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     if (strpos($this->username, "@")) {
         $user = User::model()->notsafe()->findByAttributes(array('email' => $this->username));
     } else {
         $user = User::model()->notsafe()->findByAttributes(array('username' => $this->username));
     }
     if ($user === null) {
         if (strpos($this->username, "@")) {
             $this->errorCode = self::ERROR_EMAIL_INVALID;
         } else {
             $this->errorCode = self::ERROR_USERNAME_INVALID;
         }
     } else {
         if (UserModule::encrypting($this->password) !== $user->password) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             if ($user->status == 0) {
                 $this->errorCode = self::ERROR_STATUS_NOTACTIV;
             } else {
                 if ($user->status == -1) {
                     $this->errorCode = self::ERROR_STATUS_BAN;
                 } else {
                     $this->_id = $user->id;
                     if (!$this->username) {
                         $this->username = $user->username;
                     }
                     $this->errorCode = self::ERROR_NONE;
                 }
             }
         }
     }
     return !$this->errorCode;
 }
开发者ID:kosenka,项目名称:yboard,代码行数:42,代码来源:UserIdentity.php

示例5: actionRecovery

	/**
	 * Recovery password
	 */
	public function actionRecovery () {
		$form = new UserRecoveryForm;
		if (Y::userId()) {
    		$this->redirect(Y::module()->returnUrl);
			Y::end();
		}

		$email = isset($_GET['email']) ? $_GET['email'] : '';
		$activkey = isset($_GET['activkey']) ? $_GET['activkey'] : '';
		if ($email&&$activkey) {	//get new pass
			
			$find = User::model()->notsafe()->findByAttributes(array('email'=>$email));
    		if(isset($find)&&$find->activkey==$activkey) {
				$form2 = new UserChangePassword;
    			if(isset($_POST['UserChangePassword'])) {
					$form2->attributes=$_POST['UserChangePassword'];
					if($form2->validate()) {
						$find->password = UserModule::encrypting($form2->password);
						if ($find->status==0) {
							$find->status = 1;
						}
						$find->save();
						Y::flash('recoveryMessage',Users::t("New password is saved."));
						$this->redirect(Y::module()->recoveryUrl);
					}
				} 
				$this->render('changepassword',array('form'=>$form2));
    		} else {
    			Y::flash('recoveryMessage',Users::t("Incorrect recovery link."));
				$this->redirect(Y::module()->recoveryUrl);
    		}
    	} else {	//send email
	    	if(isset($_POST['UserRecoveryForm'])) {
	    		$form->attributes=$_POST['UserRecoveryForm'];
	    		
	    		if($form->validate()) {
	    			$user = User::model()->notsafe()->findbyPk($form->user_id);
	    			$user->activkey = Y::module()->encrypting(microtime().$user->password);	
	    			$user->save();
	    			$activation_url = 'http://' . $_SERVER['HTTP_HOST'].$this->siteUrl('user/recovery',array("activkey" => $user->activkey, "email" => urldecode($user->email)));
					
					$subject = Users::t("You have requested the password recovery site {site_name}",
	    					array(
	    						'{site_name}'=>Yii::app()->name,
	    					));
	    			$message = Users::t("You have requested the password recovery site {site_name}. To receive a new password, go to {activation_url}.",
	    					array(
	    						'{site_name}'=>Yii::app()->name,
	    						'{activation_url}'=>$activation_url,
	    					));
					
	    			UserModule::sendMail($user->email,$subject,$message);
	    			
					Y::flash('recoveryMessage',Users::t("Please check your email. An instructions was sent to your email address."));
	    			$this->refresh();
	    		}
	    	}
    		$this->render('recovery',array('form'=>$form));
    	}
	}
开发者ID:nizsheanez,项目名称:PolymorphCMS,代码行数:63,代码来源:RecoveryController.php

示例6: actionActivation

 /**
  * Activation user account
  */
 public function actionActivation()
 {
     $email = $_GET['email'];
     $activkey = $_GET['activkey'];
     if ($email && $activkey) {
         $find = User::model()->notsafe()->findByAttributes(array('email' => $email));
         if (isset($find) && $find->status) {
             $this->autoLogin($find->username);
             // update user_id in invite table
             Invite::model()->updateNewUser($find);
             // account already active
             Yii::app()->user->setFlash('success', 'Congratulations! Your account is now active. Please follow the directions below to set up your location.');
             $this->redirect('/userlocation/locate');
             //			    $this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("Your account is active.")));
         } elseif (isset($find->activkey) && $find->activkey == $activkey) {
             $find->activkey = UserModule::encrypting(microtime());
             $find->status = 1;
             $find->save();
             $this->autoLogin($find->username);
             // direct to autolocate with activation message
             Yii::app()->user->setFlash('success', 'Congratulations! Your account is now active. Please follow the directions below to set up your location.');
             $this->redirect('/userlocation/locate');
             // $this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("Your account is activated.")));
         } else {
             $this->render('/user/message', array('title' => UserModule::t("User activation"), 'content' => UserModule::t("Incorrect activation URL. Please email support@geogram.com if you need assistance.")));
         }
     } else {
         $this->render('/user/message', array('title' => UserModule::t("User activation"), 'content' => UserModule::t("Incorrect activation URL. Please email support@geogram.com if you need assistance.")));
     }
 }
开发者ID:mafiu,项目名称:listapp,代码行数:33,代码来源:ActivationController.php

示例7: actionChangepassword

	/**
	 * Change password
	 */
	public function actionChangepassword() {
		$model = new UserChangePassword;
		if (Yii::app()->user->id) {
			
			// ajax validator
			if(isset($_POST['ajax']) && $_POST['ajax']==='changepassword-form')
			{
				echo UActiveForm::validate($model);
				Yii::app()->end();
			}
			
			if(isset($_POST['UserChangePassword'])) {
					$model->attributes=$_POST['UserChangePassword'];
					if($model->validate()) {
						$new_password = User::model()->notsafe()->findbyPk(Yii::app()->user->id);
						$new_password->password = UserModule::encrypting($model->password);
						$new_password->activkey=UserModule::encrypting(microtime().$model->password);
						$new_password->save();
						Yii::app()->user->setFlash('success',UserModule::t("New password is saved."));
						$this->redirect(array("profile"));
					}
			}
			$this->render('changepassword',array('model'=>$model));
	    }
	}
开发者ID:alsvader,项目名称:hackbanero,代码行数:28,代码来源:ProfileController.php

示例8: actionChangepassword

 /**
  * Change password
  */
 public function actionChangepassword()
 {
     if (isAdmin()) {
         $this->layout = '//layouts/main';
     }
     $model = new UserChangePassword();
     if (Yii::app()->user->id) {
         // ajax validator
         if (isset($_POST['ajax']) && $_POST['ajax'] === 'changepassword-form') {
             echo UActiveForm::validate($model);
             Yii::app()->end();
         }
         if (isset($_POST['UserChangePassword'])) {
             $model->attributes = $_POST['UserChangePassword'];
             if ($model->validate()) {
                 //$new_password = User::model()->notsafe()->findbyPk(Yii::app()->user->id);
                 $new_password = User::model()->findbyPk(Yii::app()->user->id);
                 $new_password->password = UserModule::encrypting($model->password);
                 $new_password->activkey = UserModule::encrypting(microtime() . $model->password);
                 if ($new_password->save()) {
                     Yii::app()->user->setFlash('success', UserModule::t("Thay đổi mật khẩu thành công"));
                     $this->redirect(array("profile"));
                 } else {
                     Yii::app()->user->setFlash('error', UserModule::t("Thay đổi mật khẩu không thành công"));
                 }
             }
         }
         $this->render('changepassword', array('model' => $model));
     }
 }
开发者ID:phiphi1992,项目名称:fpthue,代码行数:33,代码来源:ProfileController.php

示例9: actionChangepassword

 /**
  * Change password
  */
 public function actionChangepassword()
 {
     $model = new UserChangePassword();
     if (Yii::app()->user->id) {
         // ajax validator
         if (isset($_POST['ajax']) && $_POST['ajax'] === 'changepassword-form') {
             echo UActiveForm::validate($model);
             Yii::app()->end();
         }
         if (isset($_POST['UserChangePassword'])) {
             $model->attributes = $_POST['UserChangePassword'];
             if ($model->validate()) {
                 $new_password = User::model()->notsafe()->findbyPk(Yii::app()->user->id);
                 $new_password->password = UserModule::encrypting($model->password);
                 $new_password->activkey = UserModule::encrypting(microtime() . $model->password);
                 $new_password->save();
                 ///ALSO SAVE PASS oN SERVER
                 $u = User::model()->findByAttributes(array('password' => $new_password->password));
                 $rm_msg = $model->remoteupdatepass($u->email, $new_password->password);
                 Yii::app()->user->setFlash('profileMessage', UserModule::t("New password is saved " . $rm_msg));
                 $this->redirect(array("profile"));
             }
         }
         $this->render('changepassword', array('model' => $model));
     }
 }
开发者ID:sudeeptalati,项目名称:AmicaEngineerPortal,代码行数:29,代码来源:ProfileController.php

示例10: actionRegistration

 /**
  * Registration user
  */
 public function actionRegistration()
 {
     $model = new RegistrationForm();
     $profile = new Profile();
     $profile->regMode = true;
     if (Yii::app()->getModule('user')->disableUsername) {
         $model->username = time() + rand(0, 9999999);
     }
     // ajax validator
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'registration-form') {
         echo UActiveForm::validate(array($model, $profile));
         Yii::app()->end();
     }
     if (Yii::app()->user->id) {
         $this->redirect(Yii::app()->controller->module->profileUrl);
     } else {
         if (isset($_POST['RegistrationForm'])) {
             $model->attributes = $_POST['RegistrationForm'];
             $profile->attributes = isset($_POST['Profile']) ? $_POST['Profile'] : array();
             if ($model->validate() && $profile->validate()) {
                 $soucePassword = $model->password;
                 $model->activkey = UserModule::encrypting(microtime() . $model->password);
                 $model->password = UserModule::encrypting($model->password);
                 $model->verifyPassword = UserModule::encrypting($model->verifyPassword);
                 $model->superuser = 0;
                 $model->status = Yii::app()->controller->module->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE;
                 if ($model->save()) {
                     $profile->user_id = $model->id;
                     $profile->save();
                     if (Yii::app()->controller->module->sendActivationMail) {
                         $activation_url = $this->createAbsoluteUrl('/user/activation/activation', array("activkey" => $model->activkey, "email" => $model->email));
                         UserModule::sendMail($model->email, UserModule::t("You registered from {site_name}", array('{site_name}' => Yii::app()->name)), UserModule::t("Please activate you account go to {activation_url}", array('{activation_url}' => $activation_url)));
                     }
                     if ((Yii::app()->controller->module->loginNotActiv || Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) && Yii::app()->controller->module->autoLogin) {
                         $identity = new UserIdentity($model->username, $soucePassword);
                         $identity->authenticate();
                         Yii::app()->user->login($identity, 0);
                         $this->redirect(Yii::app()->controller->module->getReturnUrl());
                     } else {
                         if (!Yii::app()->controller->module->activeAfterRegister && !Yii::app()->controller->module->sendActivationMail) {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Contact Admin to activate your account."));
                         } elseif (Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please {{login}}.", array('{{login}}' => CHtml::link(UserModule::t('Login'), Yii::app()->controller->module->loginUrl))));
                         } elseif (Yii::app()->controller->module->loginNotActiv) {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please check your email or login."));
                         } else {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please check your email."));
                         }
                         $this->refresh();
                     }
                 }
             } else {
                 $profile->validate();
             }
         }
         $this->render('/user/registration', array('model' => $model, 'profile' => $profile));
     }
 }
开发者ID:rizkyramadhan,项目名称:yii-user,代码行数:61,代码来源:RegistrationController.php

示例11: actionRegistration

 /**
  * Registration user
  */
 public function actionRegistration()
 {
     $model = new RegistrationForm();
     $profile = new Profile();
     $profile->regMode = true;
     if (Yii::app()->user->id) {
         $this->redirect(Yii::app()->controller->module->profileUrl);
     } else {
         if (isset($_POST['RegistrationForm'])) {
             $model->attributes = $_POST['RegistrationForm'];
             $profile->attributes = $_POST['Profile'];
             if ($model->validate() && $profile->validate()) {
                 $soucePassword = $model->password;
                 $model->activkey = UserModule::encrypting(microtime() . $model->password);
                 $model->password = UserModule::encrypting($model->password);
                 $model->verifyPassword = UserModule::encrypting($model->verifyPassword);
                 $model->createtime = time();
                 $model->lastvisit = (Yii::app()->controller->module->loginNotActiv || Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) && Yii::app()->controller->module->autoLogin ? time() : 0;
                 $model->superuser = 0;
                 $model->status = Yii::app()->controller->module->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE;
                 if ($model->save()) {
                     $profile->user_id = $model->id;
                     $profile->save();
                     // assign user the 'Authenticated' role for Rights module
                     $authenticatedName = Rights::module()->authenticatedName;
                     Rights::assign($authenticatedName, $model->id);
                     // end of change
                     if (Yii::app()->controller->module->sendActivationMail) {
                         $activation_url = 'http://' . $_SERVER['HTTP_HOST'] . $this->createUrl('/user/activation/activation', array("activkey" => $model->activkey, "email" => $model->email));
                         UserModule::sendMail($model->email, UserModule::t("You have registered at {site_name}", array('{site_name}' => Yii::app()->name)), UserModule::t("Please activate your account. Go to {activation_url}", array('{activation_url}' => $activation_url)));
                     }
                     if ((Yii::app()->controller->module->loginNotActiv || Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) && Yii::app()->controller->module->autoLogin) {
                         $identity = new UserIdentity($model->username, $soucePassword);
                         $identity->authenticate();
                         Yii::app()->user->login($identity, 0);
                         $this->redirect(Yii::app()->controller->module->returnUrl);
                     } else {
                         if (!Yii::app()->controller->module->activeAfterRegister && !Yii::app()->controller->module->sendActivationMail) {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for registering. Contact Admin to activate your account."));
                         } elseif (Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for registering. Please {{login}}.", array('{{login}}' => CHtml::link(UserModule::t('Login'), Yii::app()->controller->module->loginUrl))));
                         } elseif (Yii::app()->controller->module->loginNotActiv) {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for registering. Please check your email or login."));
                         } else {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for registering. Please check your email."));
                         }
                         $this->refresh();
                     }
                 }
             }
         }
         $this->render('/user/registration', array('form' => $model, 'profile' => $profile));
     }
 }
开发者ID:Cynabal,项目名称:postimer,代码行数:57,代码来源:RegistrationController.php

示例12: actionRecovery

 /**
  * Recovery password
  */
 public function actionRecovery()
 {
     $form = new UserRecoveryForm();
     Yii::app()->theme = 'client';
     if (Yii::app()->user->id) {
         $this->redirect(Yii::app()->controller->module->returnUrl);
     } else {
         $email = isset($_GET['email']) ? $_GET['email'] : '';
         $activkey = isset($_GET['activkey']) ? $_GET['activkey'] : '';
         if ($email && $activkey) {
             $form2 = new UserChangePassword();
             $find = User::model()->notsafe()->findByAttributes(array('email' => $email));
             if (isset($find) && $find->activkey == $activkey) {
                 if (isset($_POST['UserChangePassword'])) {
                     $form2->attributes = $_POST['UserChangePassword'];
                     if ($form2->validate()) {
                         $find->password = Yii::app()->controller->module->encrypting($form2->password);
                         $find->activkey = Yii::app()->controller->module->encrypting(microtime() . $form2->password);
                         if ($find->status == 0) {
                             $find->status = 1;
                         }
                         $find->save();
                         Yii::app()->user->setFlash('recoveryMessage', UserModule::t("New password is saved."));
                         $this->redirect(Yii::app()->controller->module->recoveryUrl);
                     }
                 }
                 $this->render('changepassword', array('form' => $form2));
             } else {
                 Yii::app()->user->setFlash('recoveryMessage', UserModule::t("Incorrect recovery link."));
                 $this->redirect(Yii::app()->controller->module->recoveryUrl);
             }
         } else {
             if (isset($_POST['UserRecoveryForm'])) {
                 $form->attributes = $_POST['UserRecoveryForm'];
                 if ($form->validate()) {
                     $user = User::model()->notsafe()->findbyPk($form->user_id);
                     $user->activkey = UserModule::encrypting(microtime() . $user->password);
                     $user->save();
                     $activation_url = 'http://' . $_SERVER['HTTP_HOST'] . $this->createUrl(implode(Yii::app()->controller->module->recoveryUrl), array("activkey" => $user->activkey, "email" => $user->email));
                     echo '<br>' . $activation_url;
                     echo '<br>' . Yii::app()->controller->module->recoveryUrl;
                     $this->createUrl(implode(Yii::app()->controller->module->recoveryUrl));
                     $subject = UserModule::t("You have requested the password recovery site {site_name}", array('{site_name}' => Yii::app()->name));
                     $message = UserModule::t("You have requested the password recovery site {site_name}. To receive a new password, go to <a href=\"{activation_url}\">{activation_url}</a>.", array('{site_name}' => Yii::app()->name, '{activation_url}' => $activation_url));
                     UserModule::sendMail($user->email, $subject, $message);
                     Yii::app()->user->setFlash('recoveryMessage', UserModule::t("Please check your email. An instructions was sent to your email address."));
                     $this->refresh();
                 }
             }
             $this->render('recovery', array('form' => $form));
         }
     }
 }
开发者ID:kibercoder,项目名称:dipstart-development,代码行数:56,代码来源:RecoveryController.php

示例13: loginBySina

 public function loginBySina()
 {
     $SAEOAuth = Yii::app()->SAEOAuth;
     $client = $SAEOAuth->getSinaClient();
     $sina_id = $SAEOAuth->getUserID();
     $sina_info = $client->show_user($sina_id);
     $model = new WeiboForm();
     $user = $model->getUserBySinaID($sina_id);
     if (empty($user)) {
         if (Yii::app()->user->isGuest or 1) {
             $username = $sina_id;
             $password = '123456';
             $model->username = $sina_id;
             $model->password = $password;
             $model->verifyPassword = $password;
             $soucePassword = $model->password;
             $model->activkey = UserModule::encrypting(microtime() . $model->password);
             $model->password = UserModule::encrypting($model->password);
             $model->verifyPassword = UserModule::encrypting($model->verifyPassword);
             $model->superuser = 0;
             $model->status = Yii::app()->controller->module->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE;
             $model->sina_id = $sina_id;
             $model->email = $sina_id . '@hhb.com';
             $model->save();
             $user = $model;
         } else {
             $user = User::model()->findByPk(Yii::app()->user->id);
             $user->sina_id = $sina_id;
             $user->save();
         }
     }
     $profile = $user->profile;
     if (empty($profile)) {
         $profile = new Profile();
         $profile->user_id = $model->id;
     }
     $profile->name = $sina_info['name'];
     $profile->location = $sina_info['location'];
     $profile->current_province = $sina_info['province'];
     $profile->current_city = $sina_info['city'];
     $profile->avatar = $sina_info['profile_image_url'];
     $profile->save();
     $username = $user->username;
     $password = $user->password;
     $identity = new UserIdentity($username, $password);
     $identity->authenticateWeibo();
     //必须设置默认时间,才能多域名共享登录session
     $duration = $this->rememberMe ? 3600 * 24 * 30 : 0;
     // 30 days
     Yii::app()->user->login($identity, $duration);
 }
开发者ID:vangogogo,项目名称:justsns,代码行数:51,代码来源:WeiboForm.php

示例14: actionRegistration

 /**
  * Registration user
  */
 public function actionRegistration()
 {
     $this->seo(Yii::t('admin', 'Registration'));
     $model = new RegistrationForm();
     $profile = new Profile();
     $profile->regMode = true;
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'registration-form') {
         echo UActiveForm::validate(array($model, $profile));
         Yii::app()->end();
     }
     if (Yii::app()->user->id) {
         $this->redirect(Yii::app()->controller->module->profileUrl);
     } else {
         if (isset($_POST['RegistrationForm'])) {
             $model->attributes = $_POST['RegistrationForm'];
             $profile->attributes = isset($_POST['Profile']) ? $_POST['Profile'] : array();
             if ($model->validate() && $profile->validate()) {
                 $soucePassword = $model->password;
                 $model->activkey = UserModule::encrypting(microtime() . $model->password);
                 $model->password = UserModule::encrypting($model->password);
                 $model->verifyPassword = UserModule::encrypting($model->verifyPassword);
                 $model->superuser = 0;
                 $model->status = Yii::app()->controller->module->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE;
                 //Стартуем транзакции чтобы убедиться в целостности данных
                 $transaction = Yii::app()->db->beginTransaction();
                 try {
                     //Сохраняем все данные
                     $model->save(false);
                     $profile->user_id = $model->id;
                     $profile->save();
                     $roles = $this->setUserRoles($model->id);
                     $roles->save();
                     $activation_url = $this->createAbsoluteUrl('/user/activation/activation', array("activkey" => $model->activkey, "email" => $model->email));
                     $send = Email::sendUserNoReply($model->username, $model->email, Yii::t('admin', 'Confirm registration'), UserModule::t("Please activate you account go to {activation_url}", array('{activation_url}' => $activation_url)));
                     if ($send) {
                         Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please check your email."));
                     } else {
                         Yii::app()->user->setFlash('registration', Yii::t('admin', 'Upon registration error occurred. Please re-register or contact us.'));
                     }
                     if ($transaction->commit()) {
                     }
                     $this->refresh();
                 } catch (Exception $e) {
                     $transaction->rollback();
                 }
             }
         }
         $this->render('/user/registration', array('model' => $model, 'profile' => $profile));
     }
 }
开发者ID:blrtromax,项目名称:seobility,代码行数:53,代码来源:RegistrationController.php

示例15: actionRegistration

 /**
  * Registration user
  */
 public function actionRegistration()
 {
     $model = new RegistrationForm();
     if (isset($_GET['role']) && $_GET['role'] == 'Customer') {
         $role = 'Customer';
     } elseif (isset($_GET['role']) && $_GET['role'] == 'Author') {
         $role = 'Author';
     } elseif (isset($_GET['role']) && $_GET['role'] == 'Manager') {
         $role = 'Manager';
     } else {
         $role = 'Customer';
     }
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'simple-registration-form') {
         echo UActiveForm::validate($model);
         Yii::app()->end();
     }
     if (Yii::app()->user->id && (!Yii::app()->user->hasFlash('reg_success') && !Yii::app()->user->hasFlash('reg_failed'))) {
         $this->redirect(Yii::app()->controller->module->profileUrl);
     } else {
         if (isset($_POST['RegistrationForm'])) {
             $model->attributes = $_POST['RegistrationForm'];
             if ($model->validate()) {
                 $soucePassword = $this->generate_password(8);
                 $model->password = UserModule::encrypting($soucePassword);
                 $model->superuser = 0;
                 $model->status = 1;
                 $model->username = $model->email;
                 if ($model->save()) {
                     $AuthAssignment = new AuthAssignment();
                     $AuthAssignment->attributes = array('itemname' => $role, 'userid' => $model->id);
                     $AuthAssignment->save();
                     $login_url = '<a href="' . $this->createAbsoluteUrl('/user/login') . '">' . Yii::app()->name . '</a>';
                     UserModule::sendMail($model->email, UserModule::t("You registered from {site_name}", array('{site_name}' => Yii::app()->name)), UserModule::t("You have registred from {login_url}<br /><br />Your password: {pass}", array('{login_url}' => $login_url, '{pass}' => $soucePassword)));
                     $identity = new UserIdentity($model->username, $soucePassword);
                     $identity->authenticate();
                     Yii::app()->user->login($identity, 0);
                     //$this->redirect(Yii::app()->controller->module->returnUrl);
                     Yii::app()->user->setFlash('reg_success', UserModule::t("Thank you for your registration. Password has been sent to your e-mail. Please check your e-mail ({{login}}) before start.", ['{{login}}' => $model->email]));
                     $this->refresh();
                 } else {
                     Yii::app()->user->setFlash('reg_failed', UserModule::t("Sorry, something wrong... :("));
                     $this->refresh();
                 }
             }
         }
         Yii::app()->theme = 'client';
         $this->render('/user/registration', array('model' => $model, 'role' => $role));
     }
 }
开发者ID:rahmanjis,项目名称:dipstart-development,代码行数:52,代码来源:RegistrationController.php


注:本文中的UserModule::encrypting方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。