Level 88
What have you tried so far?
Here is a tutorial you can follow to get started: https://blog.codecourse.com/setting-up-laravel-sanctum-airlock-for-spa-authentication-with-vue/
login api
public function login(Request $request)
{
$email = $request->input('email');
$password = $request->input('password');
$model = User::where('email', '=', $email)->first();
//dd($request->all());
if (!empty($model)) {
$cryptedpassword = $model->password;
if (Hash::check($password, $cryptedpassword)) {
$user = [
"name" => $model->name,
"email" => $model->email
];
$data = [
"status" => "Success",
"api_token" => Str::random(60),
"user" => $user
];
} else {
$data = [
"status" => "Password did not match.",
"user" => null
];
}
}
if (empty($model)) {
$data = [
"status" => "Email did not match.",
"user" => null
];
}
return response()->json($data);
}
api.php
Route::post('/login', [UserController::class, 'login'])->name("login");
How can I make a login form with vue js as a seperate frontend? I have created vue project with 'vue create project-frontend'. The login form will call that login api and if success, it will show username.
Please or to participate in this conversation.