Laravel Sactum and Fortify - How to use them both? - laravel

Im working with Laravel 8 Project I have installed. Jetstream, Fortify, Sanctum, etc..
Now I need to made an app in html and jquery to the user login via API
and the made some processes within from the API
But I cannot understand how to make it.
Where Can i create the user token when he logins.. or if it's good to point my html login to /login of the Fortify Package.
I didn't found anythiing about this on the net.. please if someone made use of it... I will apreciate !

Related

Which Auth is usfull in Laravel / VueJS project?

I am planning a small project and have a question about authentication. I would like to implement the site with Laravel 8. However, as soon as the user has successfully logged in, he should be directed to the user dashboard. The User Dashboard should be a pure VueJS Single Page Application.
Now my question. Which auth should I use here? Session or token for the whole site or is both possible and useful?
If I use the token auth variant, for example, then I can protect the Vue app very well but I cannot access the user information outside the Vue app. For example, the current profile picture of the user should appear in the navbar and not only in the vue app but also on the landing page, contact page etc.
How can I do this and what will be the best practice and thanks for your help!
Use token based Authentication
(Laravel Passport)
Use Token-based authentication system.
In this way, you'll be able to manage the entire application UI and role checking in the frontend only. I would rather prefer to go with JWT [https://jwt-auth.readthedocs.io/en/develop/laravel-installation/]. It's easy to use and the documentation is pretty good. It's even supported by Lumen also. If you wish to integrate any micro-service in your application future, then it's available in Lumen micro-service also.

Laravel Passport Oauth Customize page / auto redirect

Hi I would like to ask about laravel passport oauth confirmation page
This is the page when we are asked for authorization, I would like to customize this page, or even possible to skip this page to always authorize anyway since the requestor will be just an internal application
I tried to google this but no luck. Is that possible? if so please tell me how to, or any link will be greatly appreciated
If you want to change the UI you can actually export the view and edit it
https://laravel.com/docs/5.5/passport#requesting-tokens
For the auto redirection, actually it can be done using laravel passport version ^7.30
Code:
https://github.com/laravel/passport/pull/1022
Documentation:
https://github.com/laravel/docs/pull/5226
But since I was using laravel version that dont support passport ^7.30, I need to create the override
reference:
https://github.com/laravel/passport/issues/243
What I did was, I copied this snippets
https://paste.laravel.io/6LN6q
Creating a new class extending the passport AuthorizationController and overriding the authorize function only

Laravel authentication or mix of Laravel and vuejs authentication

I've a question about simplicity of a task. I'm fairly new to laravel and vue js, I'm used to php and javascript though.
I hope my question makes sense since I'm not sure if the technologies work as I think.
So I want to do a SPA project with laravel as backend, vuejs as frontend and mysql for the database. I need the site to be online and want an authentication to grant user access to different parts of the website. Let's say, you have to register yourself. If it's a normal user, he can see the "UserDashboard" and if it is an admin he can see the "AdminDashboard".
I've came across a couple of tutorials which show how to create an authentication system by using vue components to handle login/register/logout... It's pretty complicated and messy in my opinion.
Is it easier to just use laravel authentication and blade templates for authentication and then show the SPA for registered users/admins? If that's possible. Only saw the first option I mention for the moment.
Edit :
Here is a picture to illustrate last approach
Laravel authentication, then show SPA
If you use Laravel Mix, simply have one blade template that hosts your application (it's already set in Laravel). However, if you're using Laravel for API and a separate project for the front-end SPA, use Passport. Here's one of the ways to do it.
If you are using Laravel Mix, the CSRF token is already in a meta tag and is being added to Axios. All you need to do is make on blade template show your app.
You can also have separate blade views for login / registration etc and show SPA when logged in. But that's not really the best practice. Since I've figured out how to use Passport, I've always gone the separate vue project route.

Lumen Login tutorial for web app no API?

I'm using lumen to make a website. I choose it because it has been told that lumen is a stunningly fast php micro framework. I need login guide. I have created login form and received data, and validated them. Now I need to check user credinals and login user. Auth::attempt($usercredinals) is not working. Fatal error with method not found is thrown. Is there any idea to use middleware and create routes that automatically login user and make available through Auth::user() method.
Thanks in Advance.
I have not found full tutorial or documentation for authentication.

Laravel Login without auth

I am very beginner in laravel. I want to create a login registration with my own code without using the laravel auth.
Yes. This is very possible. There are many authentication packages you can reference and guides to follow for auth in PHP. I highly suggest you implement Laravel's authentication scaffolding and learn how it works in order to build your own. It's really awesome! I provided links to a poplar authentication package you can study through and a tutorial below.
https://github.com/panique/huge
https://www.tutorialrepublic.com/php-tutorial/php-mysql-login-system.php

Resources