Reset password fini

beta
anulax1225 ago%!(EXTRA string=3 months)
parent 175183e7bd
commit afe651e639
  1. 47
      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. 19
      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;
use App\Http\Controllers\Controller;
use App\Models\User;
use Carbon\Carbon;
use DateTime;
use Illuminate\Auth\Events\PasswordReset;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Password;
use Illuminate\Support\Str;
@ -19,10 +23,12 @@ class NewPasswordController extends Controller
/**
* 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', [
'email' => $request->email,
'email' => $reset->email,
'token' => $request->route('token'),
]);
}
@ -37,33 +43,28 @@ public function store(Request $request): RedirectResponse
$request->validate([
'token' => 'required',
'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
// will update the password on an actual user model and persist it to the
// database. Otherwise we will parse the error and return the response.
$status = Password::reset(
$request->only('email', 'password', 'password_confirmation', 'token'),
function ($user) use ($request) {
$user->forceFill([
'password' => Hash::make($request->password),
'remember_token' => Str::random(60),
])->save();
$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();
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
// 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.
if ($status == Password::PASSWORD_RESET) {
return redirect()->route('login')->with('status', __($status));
}
throw ValidationException::withMessages([
'email' => [trans($status)],
]);
return redirect()->route('login')->with('status', 'Mot de passe réinisialisé succès');
}
}

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

@ -54,7 +54,7 @@ const user = usePage().props.auth.user;
<p class="mr-2">{{ user.name }}</p>
<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>
</button>
</span>

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

@ -47,7 +47,7 @@ const submit = () => {
</script>
<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">
<div v-if="imageState.url" class="max-h-72 overflow-hidden flex items-center">
<img :src="imageState.url">

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

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

@ -5,7 +5,7 @@ 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';
import { Head, Link, useForm, usePage } from '@inertiajs/vue3';
defineProps({
canResetPassword: {
@ -51,11 +51,11 @@ const submit = () => {
autocomplete="username"
/>
<InputError class="mt-2" :message="form.errors.email" />
<InputError class="mt-2" :message="form.errors.email || usePage().props.errors.email" />
</div>
<div class="mt-4">
<InputLabel for="password" value="Password" />
<InputLabel for="password" value="Mot de passe" />
<TextInput
id="password"
@ -73,7 +73,7 @@ const submit = () => {
<label class="flex items-center">
<Checkbox name="remember" v-model:checked="form.remember" />
<span class="ms-2 text-sm text-gray-600"
>Remember me</span
>Rester connecté</span
>
</label>
</div>
@ -84,7 +84,7 @@ const submit = () => {
: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"
>
Forgot your password?
Mot de passe oublié?
</Link>
<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 PrimaryButton from '@/Components/PrimaryButton.vue';
import TextInput from '@/Components/TextInput.vue';
import { Head, useForm } from '@inertiajs/vue3';
import { Head, useForm, usePage } from '@inertiajs/vue3';
const props = defineProps({
email: {
@ -36,24 +36,8 @@ const submit = () => {
<Head title="Reset Password" />
<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">
<InputLabel for="password" value="Password" />
<InputLabel for="password" value="Mot de passe" />
<TextInput
id="password"
@ -70,7 +54,7 @@ const submit = () => {
<div class="mt-4">
<InputLabel
for="password_confirmation"
value="Confirm Password"
value="Confirmer le mot de passe"
/>
<TextInput

@ -26,26 +26,22 @@ const verificationLinkSent = computed(
<Head title="Email Verification" />
<div class="mb-4 text-sm text-gray-600">
Thanks for signing up! Before getting started, could you verify your
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.
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.
</div>
<div
class="mb-4 text-sm font-medium text-green-600"
v-if="verificationLinkSent"
>
A new verification link has been sent to the email address you
provided during registration.
Un nouveau lien de vérification a été envoyé à l'adresse e-mail que vous avez fournie lors de votre inscription.
</div>
<form @submit.prevent="submit">
<div class="mt-4 flex items-center justify-between">
<PrimaryButton
:class="{ 'opacity-25': form.processing }"
:disabled="form.processing"
>
Resend Verification Email
:class="{ 'opacity-25': form.processing }"
:disabled="form.processing">
Renvoyer l'e-mail de vérification
</PrimaryButton>
<Link
@ -53,8 +49,9 @@ const verificationLinkSent = computed(
method="post"
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"
>Log Out</Link
>
>
Log Out
</Link>
</div>
</form>
</AuthLayout>

@ -66,7 +66,7 @@ const submit = async () => {
</script>
<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">
<div v-if="imageState.url" class="max-h-72 overflow-hidden flex items-center">
<img :src="imageState.url">

@ -28,7 +28,7 @@ defineProps({
<div class="py-12">
<div class="mx-auto max-w-7xl space-y-6 sm:px-6 lg:px-8">
<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
:must-verify-email="mustVerifyEmail"
@ -38,13 +38,13 @@ defineProps({
</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" />
</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" />
</div>

@ -56,12 +56,12 @@ const submit = () => {
</div>
<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">
<img :src="user.pic" class="h-32">
<img :src="user.pic" class="h-32" :class="{ 'invert': user.path === 'profiles/none.svg' }">
</div>
<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">
<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-50 hover:scale-[1.01]" >Retirer la photo</p>
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-100 hover:scale-[1.01]">Changer la photo</p>
<p class="px-3 py-2 hover:bg-gray-100 hover:scale-[1.01]" >Retirer la photo</p>
</div>
</div>
<div v-else class="flex">

Loading…
Cancel
Save