Skip to content

Commit

Permalink
add remember me button
Browse files Browse the repository at this point in the history
  • Loading branch information
AmonDeShir committed Dec 15, 2024
1 parent 1c83273 commit 712ada6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/Http/Controllers/AuthenticateSessionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ class AuthenticateSessionController extends Controller
public function authenticate(AuthenticateSessionRequest $request): RedirectResponse
{
$credentials = $request->only("email", "password");
$remember = $request->input("remember", false);

if (auth()->attempt($credentials)) {
if (auth()->attempt($credentials, $remember)) {
$request->session()->regenerate();

return redirect()->route("home");
Expand Down
1 change: 1 addition & 0 deletions app/Http/Requests/Auth/AuthenticateSessionRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public function rules(): array
return [
"email" => ["required", "email", "max:255"],
"password" => ["required", "string", "min:8", "max:255"],
"remember" => ["nullable", "boolean"],
];
}
}
6 changes: 5 additions & 1 deletion resources/js/components/Common/Checkbox.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<script setup lang="ts">
defineProps<{ required?: boolean }>()
</script>

<template>
<div class="inline-flex items-center">
<label class="relative flex items-center rounded-full cursor-pointer">
<input
id="checkbox"
required
type="checkbox"
class="before:content[''] peer relative size-5 cursor-pointer appearance-none rounded-md border-2 border-primary/30 transition-all before:absolute before:top-2/4 before:left-2/4 before:block before:size-12 before:-translate-y-2/4 before:-translate-x-2/4 before:rounded-full before:bg-blue-gray-500 before:opacity-0 before:transition-opacity checked:border-primary checked:bg-primary checked:before:bg-primary hover:before:opacity-10"
:required="required"
>
<span
class="absolute text-white transition-opacity opacity-0 pointer-events-none top-2/4 left-2/4 -translate-y-2/4 -translate-x-2/4 peer-checked:opacity-100"
Expand Down
8 changes: 8 additions & 0 deletions resources/js/components/Home/LoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import CustomInput from '@/components/Common/CustomInput.vue'
import { useForm } from '@inertiajs/vue3'
import { type Errors } from '@inertiajs/core'
import Checkbox from '@/components/Common/Checkbox.vue'
const { errors } = defineProps<{ errors:Errors }>()
const form = useForm({
Expand All @@ -23,6 +24,13 @@ function submit() {
<a href="/auth/forgot-password" class="duration-200 font-semibold leading-6 text-primary hover:text-primary-dark text-sm">Nie pamiętam hasła</a>
</div>

<label class="mx-2 mt-4 flex flex-row items-center gap-4">
<Checkbox />
<p class="w-fit text-sm text-gray-500">
Zapamiętaj mnie
</p>
</label>

<div>
<button
:disabled="form.processing"
Expand Down

0 comments on commit 712ada6

Please sign in to comment.