• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

orchestral / workbench / 12007277607

25 Nov 2024 09:42AM UTC coverage: 91.471% (-0.5%) from 91.979%
12007277607

push

github

web-flow
[7.x] Default authentication & dashboard using Laravel Breeze (#45)

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* Update TestCase.php

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@g... (continued)

142 of 156 new or added lines in 16 files covered. (91.03%)

311 of 340 relevant lines covered (91.47%)

9.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.22
/src/Http/Requests/Auth/LoginRequest.php
1
<?php
2

3
namespace Orchestra\Workbench\Http\Requests\Auth;
4

5
use Illuminate\Auth\Events\Lockout;
6
use Illuminate\Foundation\Http\FormRequest;
7
use Illuminate\Support\Facades\Auth;
8
use Illuminate\Support\Facades\RateLimiter;
9
use Illuminate\Support\Str;
10
use Illuminate\Validation\ValidationException;
11

12
class LoginRequest extends FormRequest
13
{
14
    /**
15
     * Determine if the user is authorized to make this request.
16
     */
17
    public function authorize(): bool
18
    {
19
        return true;
2✔
20
    }
21

22
    /**
23
     * Get the validation rules that apply to the request.
24
     *
25
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
26
     */
27
    public function rules(): array
28
    {
29
        return [
2✔
30
            'email' => ['required', 'string', 'email'],
2✔
31
            'password' => ['required', 'string'],
2✔
32
        ];
2✔
33
    }
34

35
    /**
36
     * Attempt to authenticate the request's credentials.
37
     *
38
     * @throws \Illuminate\Validation\ValidationException
39
     */
40
    public function authenticate(): void
41
    {
42
        $this->ensureIsNotRateLimited();
2✔
43

44
        if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
2✔
45
            RateLimiter::hit($this->throttleKey());
1✔
46

47
            throw ValidationException::withMessages([
1✔
48
                'email' => trans('auth.failed'),
1✔
49
            ]);
1✔
50
        }
51

52
        RateLimiter::clear($this->throttleKey());
1✔
53
    }
54

55
    /**
56
     * Ensure the login request is not rate limited.
57
     *
58
     * @throws \Illuminate\Validation\ValidationException
59
     */
60
    public function ensureIsNotRateLimited(): void
61
    {
62
        if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
2✔
63
            return;
2✔
64
        }
65

NEW
66
        event(new Lockout($this));
×
67

NEW
68
        $seconds = RateLimiter::availableIn($this->throttleKey());
×
69

NEW
70
        throw ValidationException::withMessages([
×
NEW
71
            'email' => trans('auth.throttle', [
×
NEW
72
                'seconds' => $seconds,
×
NEW
73
                'minutes' => ceil($seconds / 60),
×
NEW
74
            ]),
×
NEW
75
        ]);
×
76
    }
77

78
    /**
79
     * Get the rate limiting throttle key for the request.
80
     */
81
    public function throttleKey(): string
82
    {
83
        return Str::transliterate(Str::lower($this->string('email')).'|'.$this->ip());
2✔
84
    }
85
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc