| Code Coverage
| Classes and Traits | Functions and Methods | Lines
Total | 0.00% covered (danger) | 0.00% | 0 / 1 | 0.00% covered (danger) | 0.00% | 0 / 3 | CRAP | 0.00% covered (danger) | 0.00% | 0 / 14
LoginController | 0.00% covered (danger) | 0.00% | 0 / 1 | 0.00% covered (danger) | 0.00% | 0 / 3 | 42.00 | 0.00% covered (danger) | 0.00% | 0 / 14
__construct | 0.00% covered (danger) | 0.00% | 0 / 1 | 2.00 | 0.00% covered (danger) | 0.00% | 0 / 2
username | 0.00% covered (danger) | 0.00% | 0 / 1 | 2.00 | 0.00% covered (danger) | 0.00% | 0 / 1
login | 0.00% covered (danger) | 0.00% | 0 / 1 | 20.00 | 0.00% covered (danger) | 0.00% | 0 / 11

1 | <?php
2 |
3 | namespace App\Http\Controllers\Auth;
4 |
5 | use App\Http\Controllers\Controller;
6 | use Illuminate\Foundation\Auth\AuthenticatesUsers;
7 | use Illuminate\Http\JsonResponse;
8 | use Illuminate\Http\RedirectResponse;
9 | use Illuminate\Http\Request;
10 | use Illuminate\Http\Response;
11 | use Illuminate\Support\Facades\Auth;
12 | use Illuminate\Validation\ValidationException;
13 |
14 | class LoginController extends Controller
15 | {
16 | /*
17 | |--------------------------------------------------------------------------
18 | | Login Controller
19 | |--------------------------------------------------------------------------
20 | |
21 | | This controller handles authenticating users for the application and
22 | | redirecting them to your home screen. The controller uses a trait
23 | | to conveniently provide its functionality to your applications.
24 | |
25 | */
26 |
27 | use AuthenticatesUsers;
28 |
29 | /**
30 | * Where to redirect users after login.
31 | *
32 | * @var string
33 | */
34 | protected $redirectTo = '/rejected';
35 |
36 | /**
37 | * Create a new controller instance.
38 | *
39 | * @return void
40 | */
41 | public function __construct()
42 | {
43 | $this->middleware('guest')->except('logout');
44 | }
45 | public function username()
46 | {
47 | return 'name';
48 | }
49 |
50 | /**
51 | * Handle a login request to the application.
52 | *
53 | * @param Request $request
54 | * @return void
55 | *
56 | * @throws ValidationException
57 | */
58 | public function login(Request $request)
59 | {
60 | $this->validateLogin($request);
61 |
62 | if (method_exists($this, 'hasTooManyLoginAttempts') &&
63 | $this->hasTooManyLoginAttempts($request)) {
64 | $this->fireLockoutEvent($request);
65 |
66 | return $this->sendLockoutResponse($request);
67 | }
68 |
69 | if ($this->attemptLogin($request)) {
70 | $this->log(__METHOD__,__FUNCTION__,'',Auth::user()['id']);
71 | return $this->sendLoginResponse($request);
72 | }
73 |
74 | $this->incrementLoginAttempts($request);
75 | $this->log(__METHOD__,__FUNCTION__,'',Auth::user()['id']);
76 | return $this->sendFailedLoginResponse($request);
77 | }
78 | }