1 | <?php |
||||||
2 | |||||||
3 | namespace Imanghafoori\TokenizedLogin\Http\Controllers; |
||||||
4 | |||||||
5 | use Illuminate\Routing\Controller; |
||||||
6 | use Illuminate\Support\Facades\Validator; |
||||||
7 | use Imanghafoori\TokenizedLogin\Facades\AuthFacade; |
||||||
8 | use Imanghafoori\TokenizedLogin\Facades\TokenGeneratorFacade; |
||||||
9 | use Imanghafoori\TokenizedLogin\Facades\TokenSenderFacade; |
||||||
10 | use Imanghafoori\TokenizedLogin\Facades\TokenStoreFacade; |
||||||
11 | use Imanghafoori\TokenizedLogin\Facades\UserProviderFacade; |
||||||
12 | use Imanghafoori\TokenizedLogin\Http\ResponderFacade; |
||||||
13 | |||||||
14 | class TokenSenderController extends Controller |
||||||
15 | { |
||||||
16 | public function loginWithToken() |
||||||
17 | { |
||||||
18 | $token = request('token'); |
||||||
19 | $uid = TokenStoreFacade::getUidByToken($token)->getOrSend( |
||||||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
20 | [ResponderFacade::class, 'tokenNotFound'] |
||||||
21 | ); |
||||||
22 | |||||||
23 | AuthFacade::loginById($uid); |
||||||
0 ignored issues
–
show
The method
loginById() does not exist on Imanghafoori\TokenizedLogin\Facades\AuthFacade . Since you implemented __callStatic , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
24 | |||||||
25 | return ResponderFacade::loggedIn(); |
||||||
0 ignored issues
–
show
The method
loggedIn() does not exist on Imanghafoori\TokenizedLogin\Http\ResponderFacade . Since you implemented __callStatic , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
26 | } |
||||||
27 | |||||||
28 | public function issueToken() |
||||||
29 | { |
||||||
30 | $email = request('email'); |
||||||
31 | |||||||
32 | $this->validateEmailIsValid(); |
||||||
33 | $this->checkUserIsGuest(); |
||||||
34 | // throttle the route |
||||||
35 | |||||||
36 | // find user row in DB or Fail |
||||||
37 | $user = UserProviderFacade::getUserByEmail($email)->getOrSend( |
||||||
0 ignored issues
–
show
The method
getUserByEmail() does not exist on Imanghafoori\TokenizedLo...ades\UserProviderFacade . Since you implemented __callStatic , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
38 | [ResponderFacade::class, 'userNotFound'] |
||||||
39 | ); |
||||||
40 | |||||||
41 | // 1. stop block users |
||||||
42 | if (UserProviderFacade::isBanned($user->id)) { |
||||||
0 ignored issues
–
show
The method
isBanned() does not exist on Imanghafoori\TokenizedLo...ades\UserProviderFacade . Since you implemented __callStatic , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
43 | return ResponderFacade::blockedUser(); |
||||||
0 ignored issues
–
show
The method
blockedUser() does not exist on Imanghafoori\TokenizedLogin\Http\ResponderFacade . Since you implemented __callStatic , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
44 | } |
||||||
45 | |||||||
46 | // 2. generate token |
||||||
47 | $token = TokenGeneratorFacade::generateToken(); |
||||||
0 ignored issues
–
show
The method
generateToken() does not exist on Imanghafoori\TokenizedLo...es\TokenGeneratorFacade . Since you implemented __callStatic , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
48 | // 3. save token |
||||||
49 | TokenStoreFacade::saveToken($token, $user->id); |
||||||
0 ignored issues
–
show
The method
saveToken() does not exist on Imanghafoori\TokenizedLo...acades\TokenStoreFacade . Since you implemented __callStatic , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
50 | // 4. send token |
||||||
51 | TokenSenderFacade::send($token, $user); |
||||||
0 ignored issues
–
show
The method
send() does not exist on Imanghafoori\TokenizedLo...cades\TokenSenderFacade . Since you implemented __callStatic , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
52 | // 5. send Response |
||||||
53 | return ResponderFacade::tokenSent(); |
||||||
0 ignored issues
–
show
The method
tokenSent() does not exist on Imanghafoori\TokenizedLogin\Http\ResponderFacade . Since you implemented __callStatic , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
54 | } |
||||||
55 | |||||||
56 | private function validateEmailIsValid() |
||||||
57 | { |
||||||
58 | $v = Validator::make(request()->all(), ['email' => 'email|required']); |
||||||
59 | if ($v->fails()) { |
||||||
60 | ResponderFacade::emailNotValid()->throwResponse(); |
||||||
0 ignored issues
–
show
The method
emailNotValid() does not exist on Imanghafoori\TokenizedLogin\Http\ResponderFacade . Since you implemented __callStatic , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
61 | } |
||||||
62 | } |
||||||
63 | |||||||
64 | private function checkUserIsGuest() |
||||||
65 | { |
||||||
66 | if (AuthFacade::check()) { |
||||||
0 ignored issues
–
show
The method
check() does not exist on Imanghafoori\TokenizedLogin\Facades\AuthFacade . Since you implemented __callStatic , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
67 | ResponderFacade::youShouldBeGuest()->throwResponse(); |
||||||
0 ignored issues
–
show
The method
youShouldBeGuest() does not exist on Imanghafoori\TokenizedLogin\Http\ResponderFacade . Since you implemented __callStatic , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
68 | } |
||||||
69 | } |
||||||
70 | } |
||||||
71 |