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


PHP Security::getPasswordResetLink方法代码示例

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


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

示例1: lostPassword

 /**
  * Method for allowing a user to reset their password
  * @param {stdClass} $data Data passed from ActionScript
  * @return {array} Returns a standard response array
  */
 public function lostPassword($data)
 {
     $response = CodeBank_ClientAPI::responseBase();
     $response['login'] = true;
     $SQL_email = Convert::raw2sql($data->user);
     $member = Member::get_one('Member', "\"Email\"='{$SQL_email}'");
     // Allow vetoing forgot password requests
     $sng = new MemberLoginForm(Controller::has_curr() ? Controller::curr() : singleton('Controller'), 'LoginForm');
     $results = $sng->extend('forgotPassword', $member);
     if ($results && is_array($results) && in_array(false, $results, true)) {
         $response['status'] = 'HELO';
         $response['message'] = _t('CodeBankAPI.PASSWORD_SENT_TEXT', "A reset link has been sent to '{email}', provided an account exists for this email address.", array('email' => $data['Email']));
     }
     if ($member) {
         $token = $member->generateAutologinTokenAndStoreHash();
         $e = Member_ForgotPasswordEmail::create();
         $e->populateTemplate($member);
         $e->populateTemplate(array('PasswordResetLink' => Security::getPasswordResetLink($member, $token)));
         $e->setTo($member->Email);
         $e->send();
         $response['status'] = 'HELO';
         $response['message'] = _t('CodeBankAPI.PASSWORD_SENT_TEXT', "A reset link has been sent to '{email}', provided an account exists for this email address.", array('email' => $data->user));
     } else {
         if (!empty($data->user)) {
             $response['status'] = 'HELO';
             $response['message'] = _t('CodeBankAPI.PASSWORD_SENT_TEXT', "A reset link has been sent to '{email}', provided an account exists for this email address.", array('email' => $data->user));
         } else {
             $response['status'] = 'EROR';
             $response['message'] = _t('Member.ENTEREMAIL', 'Please enter an email address to get a password reset link.');
         }
     }
     return $response;
 }
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-codebank,代码行数:38,代码来源:CodeBankSessionManager.php

示例2: sendResetPasswordEmail

 /**
  * Send the reset password email and return the generated link.
  *
  * @param Member $member
  *
  * @return string
  */
 protected function sendResetPasswordEmail(Member $member)
 {
     // hack ?
     global $_FILE_TO_URL_MAPPING;
     if ($_FILE_TO_URL_MAPPING[BASE_PATH]) {
         $_SERVER['REQUEST_URI'] = $_FILE_TO_URL_MAPPING[BASE_PATH];
     }
     $token = $member->generateAutologinTokenAndStoreHash();
     $link = Security::getPasswordResetLink($member, $token);
     /* @var Member_ForgotPasswordEmail $email */
     $email = Member_ForgotPasswordEmail::create();
     $email->populateTemplate($member);
     $email->populateTemplate(['PasswordResetLink' => $link]);
     $email->setTo($member->Email);
     $email->send();
     return $link;
 }
开发者ID:axyr,项目名称:silverstripe-console,代码行数:24,代码来源:ResetPasswordCommand.php

示例3: forgotPassword

 public function forgotPassword($data)
 {
     $email = isset($data['Email']) ? Convert::raw2sql($data['Email']) : null;
     try {
         if (empty($email)) {
             throw new EntityValidationException('Please enter an email address to get a password reset link.');
         }
         $member = Member::get()->filter('Email', $email)->first();
         // Allow vetoing forgot password requests
         $results = $this->extend('forgotPassword', $member);
         if ($results && is_array($results) && in_array(false, $results, true)) {
             return $this->controller->redirect('Security/lostpassword');
         }
         if ($member) {
             $token = $this->tx_manager->transaction(function () use($member) {
                 return $member->generateAutologinTokenAndStoreHash();
             });
             $e = Member_ForgotPasswordEmail::create();
             $e->populateTemplate($member);
             $e->populateTemplate(array('PasswordResetLink' => Security::getPasswordResetLink($member, $token)));
             $e->setTo($member->Email);
             $e->send();
             $this->controller->redirect('Security/passwordsent/' . urlencode($email));
         }
         // Avoid information disclosure by displaying the same status,
         // regardless wether the email address actually exists
         $this->controller->redirect('Security/passwordsent/' . urlencode($email));
     } catch (EntityValidationException $ex1) {
         $this->sessionMessage($ex1->getMessage(), 'bad');
         SS_Log::log($ex1->getMessage(), SS_Log::WARN);
         $this->controller->redirect('Security/lostpassword');
     } catch (Exception $ex) {
         $this->sessionMessage('There was an error with your request!', 'bad');
         SS_Log::log($ex->getMessage(), SS_Log::ERR);
         $this->controller->redirect('Security/lostpassword');
     }
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:37,代码来源:CustomLostPasswordForm.php

示例4: forgotPassword

 /**
  * Forgot password form handler method
  *
  * This method is called when the user clicks on "I've lost my password"
  *
  * @param array $data Submitted data
  */
 function forgotPassword($data)
 {
     $SQL_data = Convert::raw2sql($data);
     $SQL_email = $SQL_data['Email'];
     $member = DataObject::get_one('Member', "\"Email\" = '{$SQL_email}'");
     if ($member) {
         $member->generateAutologinHash();
         $member->sendInfo('forgotPassword', array('PasswordResetLink' => Security::getPasswordResetLink($member->AutoLoginHash)));
         Director::redirect('Security/passwordsent/' . urlencode($data['Email']));
     } elseif ($data['Email']) {
         // Avoid information disclosure by displaying the same status,
         // regardless wether the email address actually exists
         Director::redirect('Security/passwordsent/' . urlencode($data['Email']));
     } else {
         $this->sessionMessage(_t('Member.ENTEREMAIL', 'Please enter an email address to get a password reset link.'), 'bad');
         Director::redirect('Security/lostpassword');
     }
 }
开发者ID:Raiser,项目名称:Praktikum,代码行数:25,代码来源:MemberLoginForm.php

示例5: lostPassword

 /**
  * Sends password recovery email
  * 
  * @param  SS_HTTPRequest   $request    HTTP request containing 'email' vars
  * @return array                        'email' => false if email fails (Member doesn't exist will not be reported)
  */
 public function lostPassword(SS_HTTPRequest $request)
 {
     $email = Convert::raw2sql($request->requestVar('email'));
     $member = DataObject::get_one('Member', "\"Email\" = '{$email}'");
     $sent = true;
     if ($member) {
         $token = $member->generateAutologinTokenAndStoreHash();
         $e = Member_ForgotPasswordEmail::create();
         $e->populateTemplate($member);
         $e->populateTemplate(array('PasswordResetLink' => Security::getPasswordResetLink($member, $token)));
         $e->setTo($member->Email);
         $sent = $e->send();
     }
     return array('email' => $sent);
 }
开发者ID:8secs,项目名称:cocina,代码行数:21,代码来源:RESTfulAPI_TokenAuthenticator.php

示例6: forgotPassword

 /**
  * Forgot password form handler method.
  * Called when the user clicks on "I've lost my password".
  * Extensions can use the 'forgotPassword' method to veto executing
  * the logic, by returning FALSE. In this case, the user will be redirected back
  * to the form without further action. It is recommended to set a message
  * in the form detailing why the action was denied.
  *
  * @param array $data Submitted data
  */
 public function forgotPassword($data)
 {
     // Ensure password is given
     if (empty($data['Email'])) {
         $this->sessionMessage(_t('Member.ENTEREMAIL', 'Please enter an email address to get a password reset link.'), 'bad');
         $this->controller->redirect('Security/lostpassword');
         return;
     }
     // Find existing member
     $member = Member::get()->filter("Email", $data['Email'])->first();
     // Allow vetoing forgot password requests
     $results = $this->extend('forgotPassword', $member);
     if ($results && is_array($results) && in_array(false, $results, true)) {
         return $this->controller->redirect('Security/lostpassword');
     }
     if ($member) {
         $token = $member->generateAutologinTokenAndStoreHash();
         $e = Member_ForgotPasswordEmail::create();
         $e->populateTemplate($member);
         $e->populateTemplate(array('PasswordResetLink' => Security::getPasswordResetLink($member, $token)));
         $e->setTo($member->Email);
         $e->send();
         $this->controller->redirect('Security/passwordsent/' . urlencode($data['Email']));
     } elseif ($data['Email']) {
         // Avoid information disclosure by displaying the same status,
         // regardless wether the email address actually exists
         $this->controller->redirect('Security/passwordsent/' . rawurlencode($data['Email']));
     } else {
         $this->sessionMessage(_t('Member.ENTEREMAIL', 'Please enter an email address to get a password reset link.'), 'bad');
         $this->controller->redirect('Security/lostpassword');
     }
 }
开发者ID:assertchris,项目名称:silverstripe-framework,代码行数:42,代码来源:MemberLoginForm.php

示例7: forgotPassword

 /**
  * Forgot password form handler method
  *
  * This method is called when the user clicks on "I've lost my password"
  *
  * @param array $data Submitted data
  */
 public function forgotPassword($data)
 {
     $SQL_data = Convert::raw2sql($data);
     $SQL_email = $SQL_data['Email'];
     $member = DataObject::get_one('Member', "\"Email\" = '{$SQL_email}'");
     if ($member) {
         $token = $member->generateAutologinTokenAndStoreHash();
         $e = Member_ForgotPasswordEmail::create();
         $e->populateTemplate($member);
         $e->populateTemplate(array('PasswordResetLink' => Security::getPasswordResetLink($member, $token)));
         $e->setTo($member->Email);
         $e->send();
         $this->controller->redirect('Security/passwordsent/' . urlencode($data['Email']));
     } elseif ($data['Email']) {
         // Avoid information disclosure by displaying the same status,
         // regardless wether the email address actually exists
         $this->controller->redirect('Security/passwordsent/' . urlencode($data['Email']));
     } else {
         $this->sessionMessage(_t('Member.ENTEREMAIL', 'Please enter an email address to get a password reset link.'), 'bad');
         $this->controller->redirect('Security/lostpassword');
     }
 }
开发者ID:jareddreyer,项目名称:catalogue,代码行数:29,代码来源:MemberLoginForm.php

示例8: forgotPassword

 /**
  * Forgot password form handler method
  *
  * This method is called when the user clicks on "I've lost my password"
  *
  * @param array $data Submitted data
  */
 function forgotPassword($data)
 {
     $SQL_data = Convert::raw2sql($data);
     $SQL_email = $SQL_data['Email'];
     $member = DataObject::get_one('Member', "Email = '{$SQL_email}'");
     if ($member) {
         $member->generateAutologinHash();
         $member->sendInfo('forgotPassword', array('PasswordResetLink' => Security::getPasswordResetLink($member->AutoLoginHash)));
         Director::redirect('Security/passwordsent/' . urlencode($data['Email']));
     } elseif ($data['Email']) {
         $this->sessionMessage(_t('Member.ERRORSIGNUP', 'Sorry, but I don\'t recognise the e-mail address. Maybe you need ' . 'to sign up, or perhaps you used another e-mail address?'), 'bad');
         Director::redirectBack();
     } else {
         $this->sessionMessage(_t('Member.ENTEREMAIL', 'Please enter an email address to get a password reset link.'), 'bad');
         Director::redirect('Security/lostpassword');
     }
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:24,代码来源:MemberLoginForm.php

示例9: forgotPassword

 /**
  * Forgot password form handler method
  *
  * This method is called when the user clicks on "I've lost my password"
  *
  * @param array $data Submitted data
  */
 function forgotPassword($data)
 {
     $SQL_data = Convert::raw2sql($data);
     if ($data['Email'] && ($member = DataObject::get_one("Member", "Member.Email = '{$SQL_data['Email']}'"))) {
         $member->generateAutologinHash();
         $member->sendInfo('forgotPassword', array('PasswordResetLink' => Security::getPasswordResetLink($member->AutoLoginHash)));
         Director::redirect('Security/passwordsent/' . urlencode($data['Email']));
     } else {
         if ($data['Email']) {
             $this->sessionMessage(_t('Member.ERRORSIGNUP', "Sorry, but I don't recognise the e-mail address. Maybe you need " . "to sign up, or perhaps you used another e-mail address?"), "bad");
             Director::redirectBack();
         } else {
             Director::redirect("Security/lostpassword");
         }
     }
 }
开发者ID:ramziammar,项目名称:websites,代码行数:23,代码来源:MemberLoginForm.php


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