GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( e086c7...fa3f58 )
by Pascal
02:56
created

VerifiesPendingEmails   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A verify() 0 16 2
A authenticated() 0 4 1
1
<?php
2
3
namespace ProtoneMedia\LaravelVerifyNewEmail\Http;
4
5
use Illuminate\Foundation\Auth\AuthenticatesUsers;
6
7
trait VerifiesPendingEmails
8
{
9
    use AuthenticatesUsers;
10
11
    /**
12
     * Mark the user's new email address as verified.
13
     *
14
     * @param  string $token
15
     *
16
     * @throws \ProtoneMedia\LaravelVerifyNewEmail\Http\InvalidVerificationLinkException
17
     */
18
    public function verify(string $token)
19
    {
20
        $user = app(config('verify-new-email.model'))->whereToken($token)->firstOr(['*'], function () {
21
            throw new InvalidVerificationLinkException(
22
                __('The verification link is not valid anymore.')
23
            );
24
        })->tap(function ($pendingUserEmail) {
25
            $pendingUserEmail->activate();
26
        })->user;
27
28
        if (config('verify-new-email.login_after_verification')) {
29
            return $this->guard()->login($user, config('verify-new-email.login_remember'));
30
        }
31
32
        return $this->authenticated();
33
    }
34
35
    protected function authenticated()
36
    {
37
        return redirect(config('verify-new-email.redirect_to'))->with('verified', true);
38
    }
39
}
40