You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use Request;
use Backend\Classes\Controller;
use LukeTowers\Passport\Models\BackendUser;
class PassportController extends Controller
{
public $successStatus = 200;
public function login(){
if(BackendUser::attempt(['login' => request('login'), 'password' => request('password')])){
$user = BackendUser::user();
$success['token'] = $user->createToken('MyApp')->accessToken;
return response()->json(['success' => $success], $this->successStatus);
}
else{
return response()->json(['error'=>'Unauthorised'], 401);
}
}
}
If I change the Backend User model that you included to extend \BackendAuth instead, and change the login controller function to use BackendUser::authenticate
change $user = BackendUser::user(); to $user = BackendUser::getUser(); it will return an object but it will fail at the $user->createToken('MyApp')->accessToken step.
Any idea if this is directly related to the Passport plugin attempt or a deeper issue with the OC Auth implementation?
The text was updated successfully, but these errors were encountered:
Thanks for attempting to get Passport working with OC!
I have attempted to get this working but having an issue with working on an Auth Controller.
The
BackendUser::attempt
is not a recognised function, here is the controller which is being used with my Routes.Routes
Controller
If I change the Backend User model that you included to extend
\BackendAuth
instead, and change the login controller function to useBackendUser::authenticate
change
$user = BackendUser::user();
to$user = BackendUser::getUser();
it will return an object but it will fail at the$user->createToken('MyApp')->accessToken
step.Any idea if this is directly related to the Passport plugin attempt or a deeper issue with the OC Auth implementation?
The text was updated successfully, but these errors were encountered: