One unnecessary select statement in TokenGuard

Viewed 53

I am using TokenGuard for all the database related requests through JQuery in Laravel 5.4

Once the user is logged in...I am fetching the user profile using below method.

public function ViewProfile() {
    $user = \Auth::guard("api")->user();
    $Data = [
        "FirstName"     =>  $user->FirstName,
        "LastName"      =>  $user->LastName
    ];
    return  \Response::json([
        'Status'    =>  true,
        'Data'      =>  $Data,
    ], 200);
}

Below is the POST method Url being sent to Server to fetch the data using above method

http://localhost:1234/public/api/v1/apiviewprofile?api_token=598bbba095bdd1598bbba095bf1

When I printed the select statements being issued on fetching the user details...I saw there were two select statements below.

[2017-08-10 02:37:05] local.INFO: select * from `tbluser` where `UserID` = ? limit 1  
[2017-08-10 02:37:05] local.INFO: select * from `tbluser` where `api_token` = ? limit 1  

Question

I can understand that when I send POST request using TokenGuard...it first validate token....so that time it goes to database. So second select statement is fine. But, where is Laravel 5.4 using first select statement?

1 Answers
Related