If its only about the Api's you dont need the web middleware, which is required if you want to login the user with session and cookies ...
public function login() {
if(Auth::guard('web')->attempt(['email' => $email, 'password' => $password], false, false)) {
// user credentials are correct. Issue a token and use it in next requests
// Notice false, false => no login is performed
} else {
// invalid credentials, act accordingly
}
}
public function login() {
if(Auth::guard('web')->attempt(['email' => $email, 'password' => $password], false, false)) {
$user = Auth::guard('web')->getLastAttempted(); // get hold of the user
// user credentials are correct. Issue a token and use it in next requests
// Notice false, false => no login is performed
} else {
// invalid credentials, act accordingly
}
}
What is the ideal way to authenticate user using password and return token on successful authentication?
Should I edit the TokenGuard, to add attempt() method?