/** * Authenticates the password. * This is the 'authenticate' validator as declared in rules(). */ public function reset() { $external = true; $user = ExternalUser::model()->findByAttributes(array('name_usr' => $this->username)); if ($user === NULL) { // check internal $user = InternalUser::model()->findByAttributes(array('email_uin' => $this->username)); if ($user === NULL) { // no user found } $external = false; } if ($external) { $user->email_code_usr = md5(date('Y-m-d H:i:s') . self::SALT); $user->save(); ExternalUserHistory::addLog('Requested password reset!', $user->id_usr); $md5 = $user->id_usr . 'e;' . $user->email_code_usr; $name = $user->name_usr; $email = $user->email_usr; } else { $md5 = $user->id_uin . 'i;' . md5($user->fname_uin . $user->password_uin); $name = $user->fname_uin; $email = $user->email_uin; } ResetpasswordForm::send_first_email($md5, $name, $email, $external); }
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id) { if (Yii::app()->request->isPostRequest) { // we only allow deletion via POST request $this->loadModel($id)->delete(); ExternalUserHistory::addLog('Account deleted by ' . Yii::app()->user->name . '!', $id); Yii::app()->user->setFlash('_success', "User account has been deleted!"); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if (!isset($_GET['ajax'])) { $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); } } else { throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } }
public function actionResendactivation() { if (isset($_POST['resend_activation'])) { $model = ExternalUser::model()->findAllByAttributes(array('email_usr' => $_POST['email'])); if ($model) { $model = $model[0]; if ($model->status_usr != 0) { $model = false; Yii::app()->user->setFlash('_error', "Your email address has been already validated!"); } } else { Yii::app()->user->setFlash('_error', "Invalid email address!"); } if ($model) { $model->sendActivationLink(); ExternalUserHistory::addLog('Account created!', $model->id_usr); Yii::app()->user->setFlash('_success', "Your activation link has been sent! Check your email address to continue!"); $this->redirect(array('site/login')); header("Location: " . Yii::app()->getBaseUrl()); die; } } $this->render('resendactivation'); }