1 year ago

Laravel + React Native(Mobile App) Best Way to create Authentication

Posted 1 year ago by mlazuardy

For Now i guess im already completed my Web Apps Production build with Laravel, So its time to started created REST Api for Mobile apps, im using React Native and want to create authentication too with Laravel Passport , using access_token when user create or login via Mobile like this


 public function login()
        if(Auth::attempt(['email'=> request('email'),'password'=> request('password')])){
            $user = Auth::user();
            $token = $user->createToken('HMI App')->accessToken;
            $status = 200;
            $token = 'unauthorize';
            $status = 401;
        return response()->json(['token' => $token],$status);

So the problem is web applications use session to store user data, whereas if not wrong mobile app use access token to save / detect user login, My question is how to save or track the user if the user is LoggedIn or Not ? what should column/or things i add to my Mobile apps using Laravel Passport ? sorry, and thanks if you want to answer guys. Happy Mayday

Please sign in or create an account to participate in this conversation.