Reset password fini

beta
anulax1225 ago%!(EXTRA string=4 months)
parent 175183e7bd
commit afe651e639
  1. 45
      app/Http/Controllers/Auth/NewPasswordController.php
  2. 2
      app/Http/Controllers/UserController.php
  3. 2
      resources/js/Layouts/Layout.vue
  4. 2
      resources/js/Pages/Admin/User/Create.vue
  5. 2
      resources/js/Pages/Album/Partials/Create.vue
  6. 7
      resources/js/Pages/Auth/ConfirmPassword.vue
  7. 2
      resources/js/Pages/Auth/ForgotPassword.vue
  8. 10
      resources/js/Pages/Auth/Login.vue
  9. 112
      resources/js/Pages/Auth/Register.vue
  10. 22
      resources/js/Pages/Auth/ResetPassword.vue
  11. 15
      resources/js/Pages/Auth/VerifyEmail.vue
  12. 2
      resources/js/Pages/Photo/Partials/Create.vue
  13. 6
      resources/js/Pages/Profile/Edit.vue
  14. 8
      resources/js/Pages/Profile/Partials/UpdateProfileInformationForm.vue

@ -3,9 +3,13 @@
namespace App\Http\Controllers\Auth; namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\User;
use Carbon\Carbon;
use DateTime;
use Illuminate\Auth\Events\PasswordReset; use Illuminate\Auth\Events\PasswordReset;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Password; use Illuminate\Support\Facades\Password;
use Illuminate\Support\Str; use Illuminate\Support\Str;
@ -19,10 +23,12 @@ class NewPasswordController extends Controller
/** /**
* Display the password reset view. * Display the password reset view.
*/ */
public function create(Request $request): Response public function create(Request $request)
{ {
$reset = DB::table("password_reset_tokens")->where("token", $request->token)->whereDate("created_at", '>=', (new DateTime())->modify('-1 day')->format("Y-m-d H:i:s"))->first();
if(!$reset || !$reset->email) return redirect(route("login"))->withErrors(["email" => "Le lien de réinitialisation n'est plus valide ou a été corrompu."]);
return Inertia::render('Auth/ResetPassword', [ return Inertia::render('Auth/ResetPassword', [
'email' => $request->email, 'email' => $reset->email,
'token' => $request->route('token'), 'token' => $request->route('token'),
]); ]);
} }
@ -37,33 +43,28 @@ public function store(Request $request): RedirectResponse
$request->validate([ $request->validate([
'token' => 'required', 'token' => 'required',
'email' => 'required|email', 'email' => 'required|email',
'password' => ['required', 'confirmed', Rules\Password::defaults()], 'password' => 'required|confirmed',
]); ]);
// Here we will attempt to reset the user's password. If it is successful we $reset = DB::table("password_reset_tokens")
// will update the password on an actual user model and persist it to the ->where("token", $request->token)
// database. Otherwise we will parse the error and return the response. ->whereDate("created_at", '>=', (new DateTime())->modify('-1 day')
$status = Password::reset( ->format("Y-m-d H:i:s"))->first();
$request->only('email', 'password', 'password_confirmation', 'token'),
function ($user) use ($request) {
$user->forceFill([
'password' => Hash::make($request->password),
'remember_token' => Str::random(60),
])->save();
event(new PasswordReset($user)); if(!$reset || !$reset->email)
} return redirect(route("login"))->withErrors(["email" => "Le lien de réinitialisation n'est plus valide ou a été corrompu."]);
);
User::where("email", $reset->email)->update([
'password' => bcrypt($request->password),
'remember_token' => Str::random(60),
]);
DB::table("password_reset_tokens")
->where("token", $request->token)->delete();
// If the password was successfully reset, we will redirect the user back to // If the password was successfully reset, we will redirect the user back to
// the application's home authenticated view. If there is an error we can // the application's home authenticated view. If there is an error we can
// redirect them back to where they came from with their error message. // redirect them back to where they came from with their error message.
if ($status == Password::PASSWORD_RESET) {
return redirect()->route('login')->with('status', __($status));
}
throw ValidationException::withMessages([ return redirect()->route('login')->with('status', 'Mot de passe réinisialisé succès');
'email' => [trans($status)],
]);
} }
} }

@ -5,6 +5,7 @@
use App\Models\User; use App\Models\User;
use App\Utils\Mail; use App\Utils\Mail;
use App\Utils\Token; use App\Utils\Token;
use Carbon\Carbon;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str; use Illuminate\Support\Str;
@ -45,6 +46,7 @@ public function store(Request $request)
"email" => $request->email, "email" => $request->email,
"name" => $request->name, "name" => $request->name,
"totem" => $request->totem, "totem" => $request->totem,
"email_verified_at" => Carbon::now(),
]); ]);
$token = Token::create($user->email); $token = Token::create($user->email);

@ -54,7 +54,7 @@ const user = usePage().props.auth.user;
<p class="mr-2">{{ user.name }}</p> <p class="mr-2">{{ user.name }}</p>
<div class="w-10 overflow-hidden rounded-full bg-black/80 flex justify-center items-center"> <div class="w-10 overflow-hidden rounded-full bg-black/80 flex justify-center items-center">
<img :src="pic" class="h-10"> <img :src="pic" class="h-10" :class="{ 'invert': user.path === 'profiles/none.svg' }">
</div> </div>
</button> </button>
</span> </span>

@ -40,7 +40,7 @@ const submit = () => {
<div class="w-full bg-white shadow rounded-lg px-8 py-8 mt-10"> <div class="w-full bg-white shadow rounded-lg px-8 py-8 mt-10">
<form @submit.prevent="submit" class="max-w-2xl"> <form @submit.prevent="submit" class="max-w-2xl">
<div class=""> <div class="">
<InputLabel for="name" value="Nom *" /> <InputLabel for="name" value="Nom et prénom *" />
<TextInput <TextInput
id="name" id="name"
type="text" type="text"

@ -47,7 +47,7 @@ const submit = () => {
</script> </script>
<template> <template>
<div class="text-left text-black w-[30rem] shadow-lg shadow-gray-400 rounded-lg bg-gray-50 overflow-hidden <div class="text-left text-black w-[30rem] shadow-xl rounded-lg bg-gray-50 overflow-hidden
border border-gray-300"> border border-gray-300">
<div v-if="imageState.url" class="max-h-72 overflow-hidden flex items-center"> <div v-if="imageState.url" class="max-h-72 overflow-hidden flex items-center">
<img :src="imageState.url"> <img :src="imageState.url">

@ -22,13 +22,12 @@ const submit = () => {
<Head title="Confirm Password" /> <Head title="Confirm Password" />
<div class="mb-4 text-sm text-gray-600"> <div class="mb-4 text-sm text-gray-600">
This is a secure area of the application. Please confirm your Il s'agit d'une zone sécurisée de l'application. Veuillez confirmer votre mot de passe avant de continuer.
password before continuing.
</div> </div>
<form @submit.prevent="submit"> <form @submit.prevent="submit">
<div> <div>
<InputLabel for="password" value="Password" /> <InputLabel for="password" value="Mot de passe" />
<TextInput <TextInput
id="password" id="password"
type="password" type="password"
@ -47,7 +46,7 @@ const submit = () => {
:class="{ 'opacity-25': form.processing }" :class="{ 'opacity-25': form.processing }"
:disabled="form.processing" :disabled="form.processing"
> >
Confirm Confirmer
</PrimaryButton> </PrimaryButton>
</div> </div>
</form> </form>

@ -60,7 +60,7 @@ const submit = () => {
:class="{ 'opacity-25': form.processing }" :class="{ 'opacity-25': form.processing }"
:disabled="form.processing" :disabled="form.processing"
> >
Email Password Reset Link Envoyer un mail
</PrimaryButton> </PrimaryButton>
</div> </div>
</form> </form>

@ -5,7 +5,7 @@ import InputError from '@/Components/InputError.vue';
import InputLabel from '@/Components/InputLabel.vue'; import InputLabel from '@/Components/InputLabel.vue';
import PrimaryButton from '@/Components/PrimaryButton.vue'; import PrimaryButton from '@/Components/PrimaryButton.vue';
import TextInput from '@/Components/TextInput.vue'; import TextInput from '@/Components/TextInput.vue';
import { Head, Link, useForm } from '@inertiajs/vue3'; import { Head, Link, useForm, usePage } from '@inertiajs/vue3';
defineProps({ defineProps({
canResetPassword: { canResetPassword: {
@ -51,11 +51,11 @@ const submit = () => {
autocomplete="username" autocomplete="username"
/> />
<InputError class="mt-2" :message="form.errors.email" /> <InputError class="mt-2" :message="form.errors.email || usePage().props.errors.email" />
</div> </div>
<div class="mt-4"> <div class="mt-4">
<InputLabel for="password" value="Password" /> <InputLabel for="password" value="Mot de passe" />
<TextInput <TextInput
id="password" id="password"
@ -73,7 +73,7 @@ const submit = () => {
<label class="flex items-center"> <label class="flex items-center">
<Checkbox name="remember" v-model:checked="form.remember" /> <Checkbox name="remember" v-model:checked="form.remember" />
<span class="ms-2 text-sm text-gray-600" <span class="ms-2 text-sm text-gray-600"
>Remember me</span >Rester connecté</span
> >
</label> </label>
</div> </div>
@ -84,7 +84,7 @@ const submit = () => {
:href="route('password.request')" :href="route('password.request')"
class="rounded-md text-sm text-gray-600 underline hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2" class="rounded-md text-sm text-gray-600 underline hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
> >
Forgot your password? Mot de passe oublié?
</Link> </Link>
<PrimaryButton <PrimaryButton

@ -1,112 +0,0 @@
<script setup>
import AuthLayout from '@/Layouts/AuthLayout.vue';
import InputError from '@/Components/InputError.vue';
import InputLabel from '@/Components/InputLabel.vue';
import PrimaryButton from '@/Components/PrimaryButton.vue';
import TextInput from '@/Components/TextInput.vue';
import { Head, Link, useForm } from '@inertiajs/vue3';
const form = useForm({
name: '',
email: '',
password: '',
password_confirmation: '',
});
const submit = () => {
form.post(route('register'), {
onFinish: () => form.reset('password', 'password_confirmation'),
});
};
</script>
<template>
<AuthLayout>
<Head title="Register" />
<form @submit.prevent="submit">
<div>
<InputLabel for="name" value="Name" />
<TextInput
id="name"
type="text"
class="mt-1 block w-full"
v-model="form.name"
required
autofocus
autocomplete="name"
/>
<InputError class="mt-2" :message="form.errors.name" />
</div>
<div class="mt-4">
<InputLabel for="email" value="Email" />
<TextInput
id="email"
type="email"
class="mt-1 block w-full"
v-model="form.email"
required
autocomplete="username"
/>
<InputError class="mt-2" :message="form.errors.email" />
</div>
<div class="mt-4">
<InputLabel for="password" value="Password" />
<TextInput
id="password"
type="password"
class="mt-1 block w-full"
v-model="form.password"
required
autocomplete="new-password"
/>
<InputError class="mt-2" :message="form.errors.password" />
</div>
<div class="mt-4">
<InputLabel
for="password_confirmation"
value="Confirm Password"
/>
<TextInput
id="password_confirmation"
type="password"
class="mt-1 block w-full"
v-model="form.password_confirmation"
required
autocomplete="new-password"
/>
<InputError
class="mt-2"
:message="form.errors.password_confirmation"
/>
</div>
<div class="mt-4 flex items-center justify-end">
<Link
:href="route('login')"
class="rounded-md text-sm text-gray-600 underline hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
>
Already registered?
</Link>
<PrimaryButton
class="ms-4"
:class="{ 'opacity-25': form.processing }"
:disabled="form.processing"
>
Register
</PrimaryButton>
</div>
</form>
</AuthLayout>
</template>

@ -4,7 +4,7 @@ import InputError from '@/Components/InputError.vue';
import InputLabel from '@/Components/InputLabel.vue'; import InputLabel from '@/Components/InputLabel.vue';
import PrimaryButton from '@/Components/PrimaryButton.vue'; import PrimaryButton from '@/Components/PrimaryButton.vue';
import TextInput from '@/Components/TextInput.vue'; import TextInput from '@/Components/TextInput.vue';
import { Head, useForm } from '@inertiajs/vue3'; import { Head, useForm, usePage } from '@inertiajs/vue3';
const props = defineProps({ const props = defineProps({
email: { email: {
@ -36,24 +36,8 @@ const submit = () => {
<Head title="Reset Password" /> <Head title="Reset Password" />
<form @submit.prevent="submit"> <form @submit.prevent="submit">
<div>
<InputLabel for="email" value="Email" />
<TextInput
id="email"
type="email"
class="mt-1 block w-full"
v-model="form.email"
required
autofocus
autocomplete="username"
/>
<InputError class="mt-2" :message="form.errors.email" />
</div>
<div class="mt-4"> <div class="mt-4">
<InputLabel for="password" value="Password" /> <InputLabel for="password" value="Mot de passe" />
<TextInput <TextInput
id="password" id="password"
@ -70,7 +54,7 @@ const submit = () => {
<div class="mt-4"> <div class="mt-4">
<InputLabel <InputLabel
for="password_confirmation" for="password_confirmation"
value="Confirm Password" value="Confirmer le mot de passe"
/> />
<TextInput <TextInput

@ -26,26 +26,22 @@ const verificationLinkSent = computed(
<Head title="Email Verification" /> <Head title="Email Verification" />
<div class="mb-4 text-sm text-gray-600"> <div class="mb-4 text-sm text-gray-600">
Thanks for signing up! Before getting started, could you verify your Merci de vous être inscrit! Avant de commencer, pouvez-vous vérifier votre adresse e-mail en cliquant sur le lien que nous venons de vous envoyer par e-mail ? Si vous n'avez pas reçu l'e-mail, nous serons heureux de vous en envoyer un autre.
email address by clicking on the link we just emailed to you? If you
didn't receive the email, we will gladly send you another.
</div> </div>
<div <div
class="mb-4 text-sm font-medium text-green-600" class="mb-4 text-sm font-medium text-green-600"
v-if="verificationLinkSent" v-if="verificationLinkSent"
> >
A new verification link has been sent to the email address you Un nouveau lien de vérification a été envoyé à l'adresse e-mail que vous avez fournie lors de votre inscription.
provided during registration.
</div> </div>
<form @submit.prevent="submit"> <form @submit.prevent="submit">
<div class="mt-4 flex items-center justify-between"> <div class="mt-4 flex items-center justify-between">
<PrimaryButton <PrimaryButton
:class="{ 'opacity-25': form.processing }" :class="{ 'opacity-25': form.processing }"
:disabled="form.processing" :disabled="form.processing">
> Renvoyer l'e-mail de vérification
Resend Verification Email
</PrimaryButton> </PrimaryButton>
<Link <Link
@ -53,8 +49,9 @@ const verificationLinkSent = computed(
method="post" method="post"
as="button" as="button"
class="rounded-md text-sm text-gray-600 underline hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2" class="rounded-md text-sm text-gray-600 underline hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
>Log Out</Link
> >
Log Out
</Link>
</div> </div>
</form> </form>
</AuthLayout> </AuthLayout>

@ -66,7 +66,7 @@ const submit = async () => {
</script> </script>
<template> <template>
<div class="text-left text-black w-[30rem] shadow-lg shadow-gray-400 rounded-lg bg-gray-50 overflow-hidden <div class="text-left text-black w-[30rem] shadow-2xl rounded-lg bg-gray-50 overflow-hidden
border border-gray-300"> border border-gray-300">
<div v-if="imageState.url" class="max-h-72 overflow-hidden flex items-center"> <div v-if="imageState.url" class="max-h-72 overflow-hidden flex items-center">
<img :src="imageState.url"> <img :src="imageState.url">

@ -28,7 +28,7 @@ defineProps({
<div class="py-12"> <div class="py-12">
<div class="mx-auto max-w-7xl space-y-6 sm:px-6 lg:px-8"> <div class="mx-auto max-w-7xl space-y-6 sm:px-6 lg:px-8">
<div <div
class="bg-white p-4 shadow sm:rounded-lg sm:p-8" class="bg-gray-50 p-4 shadow sm:rounded-lg sm:p-8"
> >
<UpdateProfileInformationForm <UpdateProfileInformationForm
:must-verify-email="mustVerifyEmail" :must-verify-email="mustVerifyEmail"
@ -38,13 +38,13 @@ defineProps({
</div> </div>
<div <div
class="bg-white p-4 shadow sm:rounded-lg sm:p-8" class="bg-gray-50 p-4 shadow sm:rounded-lg sm:p-8"
> >
<UpdatePasswordForm class="pr-64" /> <UpdatePasswordForm class="pr-64" />
</div> </div>
<div <div
class="bg-white p-4 shadow sm:rounded-lg sm:p-8" class="bg-gray-50 p-4 shadow sm:rounded-lg sm:p-8"
> >
<DeleteUserForm class="pr-64" /> <DeleteUserForm class="pr-64" />
</div> </div>

@ -56,12 +56,12 @@ const submit = () => {
</div> </div>
<div v-if="!pic.edit" @click="pic.active = !pic.active" class="relative"> <div v-if="!pic.edit" @click="pic.active = !pic.active" class="relative">
<div class="w-32 overflow-hidden flex justify-center rounded-full bg-black/80"> <div class="w-32 overflow-hidden flex justify-center rounded-full bg-black/80">
<img :src="user.pic" class="h-32"> <img :src="user.pic" class="h-32" :class="{ 'invert': user.path === 'profiles/none.svg' }">
</div> </div>
<div @click="(e) => { Utils.Prevent(e); pic.edit = true; }" :class="{ 'hidden': !pic.active }" <div @click="(e) => { Utils.Prevent(e); pic.edit = true; }" :class="{ 'hidden': !pic.active }"
class="absolute top-full right-0 w-40 mt-1 bg-gray-100 text-sm text-black/80 rounded-md shadow-lg overflow-hidden"> class="absolute top-full right-0 w-40 mt-1 bg-white text-sm text-black/80 rounded-md shadow-xl overflow-hidden">
<p class="px-3 py-2 hover:bg-gray-50 hover:scale-[1.01]">Changer la photo</p> <p class="px-3 py-2 hover:bg-gray-100 hover:scale-[1.01]">Changer la photo</p>
<p class="px-3 py-2 hover:bg-gray-50 hover:scale-[1.01]" >Retirer la photo</p> <p class="px-3 py-2 hover:bg-gray-100 hover:scale-[1.01]" >Retirer la photo</p>
</div> </div>
</div> </div>
<div v-else class="flex"> <div v-else class="flex">

Loading…
Cancel
Save