Support the ongoing development of Laravel.io →
posted 8 years ago
Eloquent
Last updated 2 years ago.
0

i don't see why you should not.

0

what type of session are you using?

0

Not using any kind of session.Using user token authentication.Its working as follows.

  1. For each login a hash formatted token will be generated and saved in the database along with user id.And sending these to Mobile User.

2.Mobile User will send the user id and the user token along with every Server API call.

3.Server API will verify the user id & token with the values saved in the Database .If it matches it will continue with other functionalities.Else it will return invalid authentication.

In this scenario is it possible to use Auth::user()?

0

in that scenario, nope.

You can do something like this:

class ApiBaseController
{
    public $user;

    public function __construct()
    {
        $this->user = $this->authenticateUser();
    }

    private function authenticateUser()
    {
        // return authenticated user
        // if authentication failed abort(403)
    }
}


class DoSomethingApiController extends ApiBaseController
{
    public function listThings()
    {
        return Things::getThingsByUser($this->user);
    }
}
Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.