mercredi 19 décembre 2018

How to create own login method in laravel?

I am using passport package in my project. Everything is working fine. I need custom functionality in which I can login through provider_id instead of email and password.

The below code is working absolutely fine

$credentials = request(['email', 'password']);
        if(!Auth::attempt($credentials))
            return response()->json([
                'status' => 'fail',
                'message' => 'The given data was invalid.'
            ], 401);
        $user = $request->user();
        $tokenResult = $user->createToken('Personal Access Token');
        $token = $tokenResult->token;

        if ($request->remember_me)
            $token->expires_at = Carbon::now()->addWeeks(1);
            $token->save();

I want to have same functionality as like below

Auth::attempt($credentials)

But through provider_id, and I can use these input for login which are in same `users

name
provider
provider_id

can someone kindly guide me about that I would appreciate. Thank you.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire