Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel basic login

    public function login(LoginRequest $request)
    {
        $user = User::username($request->username)->first();

        if (!$user?->isPwdConfirmed($request->password)) {
            abort(Response::HTTP_UNAUTHORIZED, __('The provided credentials were incorrect.'));
        }

        return $this->authService->issueAccessToken($user);
    }

    public function logout(Request $request)
    {
        $request->user()->currentAccessToken()->delete();
        return ['message' => 'Successfully logout.'];
    }
 
PREVIOUS NEXT
Tagged: #laravel #basic #login
ADD COMMENT
Topic
Name
2+6 =