1 | <?php |
||||
2 | |||||
3 | namespace InnoFlash\LaraStart\Services; |
||||
4 | |||||
5 | class AuthService |
||||
6 | { |
||||
7 | public function attemptLogin(array $credentials = [], string $guard = 'api') |
||||
8 | { |
||||
9 | if (! count($credentials)) { |
||||
10 | $credentials = request(['email', 'password']); |
||||
11 | } |
||||
12 | |||||
13 | if (! $guard) { |
||||
14 | $guard = config('larastart.guard'); |
||||
15 | } |
||||
16 | |||||
17 | if (! $token = auth($guard)->attempt($credentials)) { |
||||
18 | return $this->validationFailed(); |
||||
0 ignored issues
–
show
|
|||||
19 | } |
||||
20 | |||||
21 | $class = config('larastart.resource'); |
||||
22 | |||||
23 | return [ |
||||
24 | config('larastart.wrap') => new $class(auth($guard)->user()), |
||||
25 | 'token' => [ |
||||
26 | 'access_token' => $token, |
||||
27 | 'expires_in' => auth($guard)->factory()->getTTL() * 60, |
||||
0 ignored issues
–
show
The method
factory() does not exist on Illuminate\Contracts\Auth\Guard . It seems like you code against a sub-type of said class. However, the method does not exist in Illuminate\Auth\TokenGuard or Illuminate\Contracts\Auth\StatefulGuard . Are you sure you never get one of those?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
28 | 'type' => 'bearer', |
||||
29 | ], |
||||
30 | ]; |
||||
31 | } |
||||
32 | |||||
33 | public function authenticatedUser(string $guard = 'api') |
||||
34 | { |
||||
35 | $class = config('larastart.resource'); |
||||
36 | |||||
37 | if (! $guard) { |
||||
38 | $guard = config('larastart.guard'); |
||||
39 | } |
||||
40 | |||||
41 | return new $class(auth($guard)->user()); |
||||
42 | } |
||||
43 | |||||
44 | public function validationFailed() |
||||
45 | { |
||||
46 | abort(401, 'Invalid login credentials'); |
||||
47 | } |
||||
48 | } |
||||
49 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.