Fortify login through api
Hi all,
I hope someone can point me in the right direction. I am looking into creating an api request to "login" a user through an api.
Why am do I need an api for a login?
I am creating a desktop application where a user is required to login. Once the user has logged in with their user credentials the api will return with their user information.
Alternative options
Another option I could take is to encrypt the username and password together and save that into the database on register. Then when the user logins through the application the application sends an api request with the encrypted username and password.
Any pointers and help are welcome
I would recommend to start with Sanctum. It's quite simple and straight forward.
e.g. for SPA Authentication
login() {
axios.get('/sanctum/csrf-cookie').then(response => {
axios.post('/login', {
email: this.email,
password: this.password
})
.then(response => {
if (response.status && response.status == 200) {
this.$router.push({
name: 'Dashboard'
});
}
})
.catch(errors => {
if (errors.response.data.exception) {
this.exception = errors.response.data.message;
}
this.errors = errors.response.data.errors;
})
});
}
I highly recommend to read docs.
Please or to participate in this conversation.