Пример #1
0
 public function postValidate()
 {
     $validator = $this->validator->make($this->input->all(), array('recaptcha_response_field' => 'required|recaptcha'));
     if ($validator->fails()) {
         return $this->response->json(array('result' => 'failed'));
     }
     $this->session->put('captcha.passed.time', $this->mockably->microtime());
     return $this->response->json(array('result' => 'success'));
 }
Пример #2
0
 /**
  * Unsuspend the user and give him a new password
  *
  * @param User $user
  * @param string $reset_code The password reset code
  * @throws PasswordResetFailedException
  * @return string Returns the new password on success
  */
 protected function unsuspendUserAndResetPassword($user, $reset_code)
 {
     $throttle = $this->sentry->findThrottlerByUserId($user->getId());
     $throttle->unsuspend();
     $new_password = $this->mockably->str_random(16);
     if ($user->attemptResetPassword($reset_code, $new_password)) {
         return $new_password;
     } else {
         throw new PasswordResetFailedException();
     }
 }
Пример #3
0
 /**
  * Get the time difference of a time record compared to the present
  *
  * @param float $time_record A record of microtime(true) in the past
  * @param string $unit Can be either 'ms', 's' or 'm' (milliseconds, seconds, minutes)
  * @return int Returns the time difference in the given unit
  * @throws BadMethodCallException
  */
 public function getCurrentTimeDifference($time_record, $unit = 'm')
 {
     $current_time = $this->mockably->microtime();
     switch ($unit) {
         case 'ms':
             $difference = round(($current_time - $time_record) * 1000);
             break;
         case 's':
             $difference = round($current_time - $time_record);
             break;
         case 'm':
             $difference = floor(round($current_time - $time_record) / 60);
             break;
         default:
             throw new BadMethodCallException();
     }
     return (int) $difference;
 }
Пример #4
0
 /**
  * Shares the required data for the reCAPTCHA
  *
  * @return void
  */
 public function shareDataToViews()
 {
     $this->view->share('captcha_validation_url', $this->mockably->route('larapress.api.captcha.validate.post'));
 }