Completed
Push — master ( 7d04c8...2a4aa6 )
by Jan
10:55
created

AuthController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Http\Controllers\Auth;
4
5
use App\User;
6
use Illuminate\Validation\Validator;
7
use App\Http\Controllers\Controller;
8
//use Illuminate\Foundation\Auth\ThrottlesLogins;
9
//use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
10
use \Illuminate\Http\Request;
11
12
class AuthController extends Controller
13
{
14
    /*
15
    |--------------------------------------------------------------------------
16
    | Registration & Login Controller
17
    |--------------------------------------------------------------------------
18
    |
19
    | This controller handles the registration of new users, as well as the
20
    | authentication of existing users. By default, this controller uses
21
    | a simple trait to add these behaviors. Why don't you explore it?
22
    |
23
    */
24
25
    use AuthenticatesAndRegistersUsers, ThrottlesLogins;
26
    
27
    /**
28
     * Redirect after logout URL
29
     * 
30
     * @var string 
31
     */
32
    protected $redirectAfterLogout = 'admin';
33
34
    /**
35
     * Create a new authentication controller instance.
36
     *
37
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
38
     */
39
    public function __construct()
40
    {
41
        $this->redirectAfterLogout = env('APP_ADMIN_URL', 'admin');
42
        $this->middleware('guest', ['except' => 'getLogout']);
43
    }
44
45
    /**
46
     * Get a validator for an incoming registration request.
47
     *
48
     * @param  array  $data
49
     * @return \Illuminate\Contracts\Validation\Validator
50
     */
51
    protected function validator(array $data)
52
    {
53
        return Validator::make($data, [
0 ignored issues
show
Bug introduced by
The method make() does not seem to exist on object<Illuminate\Validation\Validator>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
54
            'name' => 'required|max:255',
55
            'email' => 'required|email|max:255|unique:users',
56
            'password' => 'required|confirmed|min:6',
57
        ]);
58
    }
59
60
    /**
61
     * Create a new user instance after a valid registration.
62
     *
63
     * @param  array  $data
64
     * @return User
65
     */
66 View Code Duplication
    protected function create(array $data)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
67
    {
68
        return User::create([
69
            'name' => $data['name'],
70
            'email' => $data['email'],
71
            'password' => bcrypt($data['password']),
72
        ]);
73
    }
74
    
75 View Code Duplication
    public function prePostLogin(Request $request) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
76
        
77
        /**
78
         * Add recaptcha
79
         */
80
        if(env('RECAPTCHA_ENABLED') == 1){
81
            $this->validate($request, ['g-recaptcha-response' => 'required|recaptcha']);
82
        }
83
        
84
        return $this->postLogin($request);
85
    }
86
    
87
    
88
}
89