1 | <?php |
||
34 | trait AuthenticatesUsers |
||
35 | { |
||
36 | /** |
||
37 | * Handle a login request to the application. |
||
38 | * |
||
39 | * @param \Illuminate\Http\Request $request |
||
40 | * @return \Illuminate\Http\Response |
||
41 | */ |
||
42 | public function postLogin(Request $request) |
||
82 | |||
83 | /** |
||
84 | * Send the response after the user was authenticated. |
||
85 | * |
||
86 | * @param \Illuminate\Http\Request $request |
||
87 | * @param bool $throttles |
||
88 | * @param string $token |
||
89 | * @return \Illuminate\Http\Response |
||
90 | */ |
||
91 | protected function handleUserWasAuthenticated(Request $request, $throttles, $token) |
||
92 | { |
||
93 | if ($throttles) { |
||
94 | $this->clearLoginAttempts($request); |
||
95 | } |
||
96 | |||
97 | if (method_exists($this, 'authenticated')) { |
||
98 | return $this->authenticated($request, $token); |
||
99 | } |
||
100 | |||
101 | $response = new JsonResponse(['token' => $token], 200); |
||
102 | $response->header('Authorization', 'Bearer ' . $token); |
||
103 | return $response; |
||
104 | } |
||
105 | |||
106 | /** |
||
107 | * Get the needed authorization credentials from the request. |
||
108 | * |
||
109 | * @param \Illuminate\Http\Request $request |
||
110 | * @return array |
||
111 | */ |
||
112 | protected function getCredentials(Request $request) |
||
119 | |||
120 | /** |
||
121 | * Get the failed login message. |
||
122 | * |
||
123 | * @return string |
||
124 | */ |
||
125 | protected function getFailedLoginMessage() |
||
131 | |||
132 | /** |
||
133 | * Get the login username to be used by the controller. |
||
134 | * it can be an array for multiple username (for example email and phone number) |
||
135 | * |
||
136 | * @return string|array |
||
137 | */ |
||
138 | public function loginUsername() |
||
142 | |||
143 | /** |
||
144 | * Determine if the class is using the ThrottlesLogins trait. |
||
145 | * |
||
146 | * @return bool |
||
147 | */ |
||
148 | protected function isUsingThrottlesLoginsTrait() |
||
154 | |||
155 | /** |
||
156 | * Get the custom claims |
||
157 | * |
||
158 | * @return string |
||
159 | */ |
||
160 | public function customClaims() |
||
164 | } |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.