Example #1
0
 public function make($captcha)
 {
     $block = new SuccessBlock();
     if (!Auth::check()) {
         if ($block->success) {
             $rules = ['captcha' => 'required|captcha'];
             $data = ['captcha' => $captcha];
             $validate = Validator::make($data, $rules);
             if ($validate->fails()) {
                 $block->success = false;
                 foreach ($validate->messages()->all() as $v) {
                     $block->errors[] = $v;
                 }
             }
         }
         if ($block->success) {
             $username = $this->generate_name();
             $user = new User();
             $user->create_anon($username);
             if (!Auth::attempt(['username' => $username, 'password' => ''])) {
                 $block->success = false;
                 Log::error("anonymous {$username} failed login attempt on comment post @ " . time());
                 $block->errors[] = "A general error has occurred with logging in, try <a href='/login'>instead</a> sorry!";
             }
         }
     }
     return $block;
 }