本文整理匯總了PHP中Model_Users::forgotPassword方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model_Users::forgotPassword方法的具體用法?PHP Model_Users::forgotPassword怎麽用?PHP Model_Users::forgotPassword使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Model_Users
的用法示例。
在下文中一共展示了Model_Users::forgotPassword方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: resetAction
public function resetAction()
{
$request = $this->getRequest();
if (!JO_Session::get('user[user_id]')) {
$this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
}
$done = $request->issetQuery('done');
if ($done) {
$this->forward('password', 'done');
}
if ($request->isPost()) {
$validate = new Helper_Validate();
$validate->_set_rules($request->getPost('email'), $this->translate('E-mail'), 'not_empty;min_length[5];max_length[100];email');
if ($validate->_valid_form()) {
$result = Model_Users::forgotPassword($request->getPost('email'));
if ($result) {
if ($result['status']) {
$new_password = Model_Users::generatePassword(8);
$key_forgot = md5($result['user_id'] . md5($new_password));
$add_new_pass = Model_Users::edit($result['user_id'], array('new_password' => $new_password, 'new_password_key' => $key_forgot));
if ($add_new_pass) {
$is_mail_smtp = JO_Registry::forceGet('config_mail_smtp');
$mail = new JO_Mail();
if ($is_mail_smtp) {
$mail->setSMTPParams(JO_Registry::forceGet('config_mail_smtp_host'), JO_Registry::forceGet('config_mail_smtp_port'), JO_Registry::forceGet('config_mail_smtp_user'), JO_Registry::forceGet('config_mail_smtp_password'));
}
$this->view->new_password = $new_password;
$this->view->user_info = $result;
$this->view->forgot_password_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login&user_id=' . $result['user_id'] . '&key=' . $key_forgot);
$this->view->header_title = JO_Registry::get('site_name');
$this->view->base_href = WM_Router::create($request->getBaseUrl());
$mail->setFrom(JO_Registry::get('noreply_mail'));
$mail->setReturnPath(JO_Registry::get('noreply_mail'));
$mail->setSubject($this->translate('Request for forgotten password') . ' ' . JO_Registry::get('site_name'));
$mail->setHTML($this->view->render('send_forgot_password_request', 'mail'));
$result_send = (int) $mail->send(array($result['email']), $is_mail_smtp ? 'smtp' : 'mail');
if ($result_send) {
$this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=password&action=reset&done='));
} else {
$this->view->error = $this->translate('There was an error. Please try again later!');
}
} else {
$this->view->error = $this->translate('There was a problem with the record. Please try again!');
}
} else {
$this->view->error = $this->translate('This profile is not active.');
}
} else {
$this->view->error = $this->translate('E-mail address was not found!');
}
} else {
$this->view->error = $validate->_get_error_messages();
}
}
$this->view->form_action = WM_Router::create($request->getBaseUrl() . '?controller=password&action=reset');
$this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
}
示例2: loginAction
public function loginAction()
{
$request = $this->getRequest();
if ($request->getQuery('verify')) {
if (Model_Users::verifyEmailCheck($request->getQuery('verify'), $request->getParam('user_id'))) {
JO_Session::set('successful', $this->translate('You verifying your email. Now you can access with the data from e-mail!'));
$this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
} else {
$this->view->error = $this->translate('There was a problem with the record. Please try again!');
}
} else {
if (JO_Session::get('user[user_id]')) {
$this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]')));
}
}
$this->view->successful = false;
if (JO_Session::get('successful')) {
$this->view->successful = JO_Session::get('successful');
JO_Session::clear('successful');
}
$this->view->error = false;
if ($request->getParam('user_id') && $request->getQuery('key')) {
if (Model_Users::forgotPasswordCheck($request->getQuery('key'), $request->getParam('user_id'))) {
JO_Session::set('successful', $this->translate('You verifying forgotten password. Now you can access with the data from e-mail!'));
$this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
} else {
$this->view->error = $this->translate('There was a problem with the record. Please try again!');
}
}
$referer = $request->getServer('HTTP_REFERER');
$this->view->next = urlencode($request->getBaseUrl());
if ($referer) {
$data = parse_url($referer);
if (isset($data['host'])) {
if (str_replace('www.', '', $data['host']) == $request->getDomain()) {
$this->view->next = urlencode($referer);
}
}
}
if ($request->issetPost('next')) {
$this->view->next = html_entity_decode($request->getPost('next'));
} elseif ($request->getQuery('popup') == 'true' && $request->issetQuery('next')) {
$this->view->next = urlencode(html_entity_decode($request->getQuery('next')));
}
$this->view->is_forgot_password = (int) $request->getPost('forgot_password');
if ($request->isPost() && $request->issetPost('login')) {
$validate = new Helper_Validate();
$validate->_set_rules($request->getPost('email'), $this->translate('Email Address'), 'not_empty;min_length[5];max_length[100];email');
if ($request->getPost('forgot_password') != 1) {
$validate->_set_rules($request->getPost('password'), $this->translate('Password'), 'not_empty;min_length[4];max_length[30]');
}
if ($validate->_valid_form()) {
if ($request->getPost('forgot_password') == 1) {
$result = Model_Users::forgotPassword($request->getPost('email'));
if ($result) {
if ($result['status']) {
$new_password = Model_Users::generatePassword(8);
$key_forgot = md5($result['user_id'] . md5($new_password));
$add_new_pass = Model_Users::edit($result['user_id'], array('new_password' => $new_password, 'new_password_key' => $key_forgot));
if ($add_new_pass) {
$this->view->new_password = $new_password;
$this->view->user_info = $result;
$this->view->forgot_password_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login&user_id=' . $result['user_id'] . '&key=' . $key_forgot);
$this->view->header_title = JO_Registry::get('site_name');
$this->view->base_href = WM_Router::create($request->getBaseUrl());
$result_send = Model_Email::send($result['email'], JO_Registry::get('noreply_mail'), $this->translate('Request for forgotten password') . ' ' . JO_Registry::get('site_name'), $this->view->render('send_forgot_password_request', 'mail'));
if ($result_send) {
JO_Session::set('successful', $this->translate('Was sent the e-mail with instructions for the new password!'));
$this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
} else {
$this->view->error = $this->translate('There was an error. Please try again later!');
}
} else {
$this->view->error = $this->translate('There was a problem with the record. Please try again!');
}
} else {
$this->view->error = $this->translate('This profile is not active.');
}
} else {
$this->view->error = $this->translate('E-mail address was not found!');
}
} else {
$result = Model_Users::checkLogin($request->getPost('email'), $request->getPost('password'));
if ($result) {
if ($result['status']) {
@setcookie('csrftoken_', md5($result['user_id'] . $request->getDomain() . $result['date_added']), time() + 86400 * 366 * 5, '/', '.' . $request->getDomain());
JO_Session::set(array('user' => $result));
$this->redirect(urldecode($this->view->next));
} else {
$this->view->error = $this->translate('This profile is not active.');
}
} else {
$this->view->error = $this->translate('E-mail address and password do not match');
}
}
} else {
$this->view->error = $validate->_get_error_messages();
}
}
$this->view->login_facebook = WM_Router::create($request->getBaseUrl() . '?controller=facebook&next=' . $this->view->next);
//.........這裏部分代碼省略.........