Compare commits
10
Commits
1f42a5392b
...
fed6b7c92f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fed6b7c92f | ||
|
|
9ae484d584 | ||
|
|
615c084995 | ||
|
|
afbffe99a8 | ||
|
|
0c0af0fd00 | ||
|
|
d9ccd7ff5f | ||
|
|
741dabd720 | ||
|
|
f4caf50f40 | ||
|
|
8e110244bb | ||
|
|
567bc306e1 |
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+42
@@ -13,6 +13,7 @@ use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
|
||||
class EventsController extends Controller
|
||||
@@ -136,6 +137,7 @@ class EventsController extends Controller
|
||||
"created_at" => $event->created_at,
|
||||
"updated_at" => $event->updated_at,
|
||||
"tasks" => $event->tasks,
|
||||
"event_photo_path" =>$event->event_photo_path,
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
@@ -164,4 +166,44 @@ class EventsController extends Controller
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function show(int $id)
|
||||
{
|
||||
$event = Event::findOrFail($id);
|
||||
|
||||
return response()->json([
|
||||
'event_photo_path' => $event->event_photo_path
|
||||
]);
|
||||
}
|
||||
|
||||
public function updatePhoto(Request $request, int $id)
|
||||
{
|
||||
$request->validate([
|
||||
'photo' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048',
|
||||
]);
|
||||
$event = Event::findOrFail($id);
|
||||
$path = $request->file('photo')->store('event-photos', 'public');
|
||||
if ($event->event_photo_path) {
|
||||
Storage::disk('public')->delete($event->event_photo_path);
|
||||
}
|
||||
$event->update([
|
||||
'event_photo_path' => $path
|
||||
]);
|
||||
return response()->json([
|
||||
'event_photo_path' => $path
|
||||
]);
|
||||
}
|
||||
public function destroy(int $id)
|
||||
{
|
||||
$event = Event::findOrFail($id);
|
||||
if ($event->event_photo_path) {
|
||||
Storage::disk('public')->delete($event->event_photo_path);
|
||||
$event->update([
|
||||
'event_photo_path' => null
|
||||
]);
|
||||
}
|
||||
return response()->json([
|
||||
'message' => 'Photo supprimée'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Regular → Executable
Regular → Executable
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class ProfilePhotoController extends Controller
|
||||
{
|
||||
public function show(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
return response()->json(['profile_photo_path' => $user->profile_photo_path]);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'photo' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048',
|
||||
]);
|
||||
|
||||
$user = $request->user();
|
||||
$path = $request->file('photo')->store('profile-photos', 'public');
|
||||
|
||||
// Supprimer l'ancienne photo si elle existe
|
||||
if ($user->profile_photo_path) {
|
||||
Storage::disk('public')->delete($user->profile_photo_path);
|
||||
}
|
||||
|
||||
$user->update(['profile_photo_path' => $path]);
|
||||
|
||||
return response()->json(['profile_photo_path' => $path]);
|
||||
}
|
||||
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
if ($user->profile_photo_path) {
|
||||
Storage::disk('public')->delete($user->profile_photo_path);
|
||||
$user->update(['profile_photo_path' => null]);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Photo supprimée']);
|
||||
}
|
||||
}
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
+109
@@ -2,7 +2,10 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Mail\EmailChangeConfirmedMail;
|
||||
use App\Mail\NotifyEmailChangeMail;
|
||||
use App\Mail\RegisterMail;
|
||||
use App\Mail\RequestEmailChangeMail;
|
||||
use App\Mail\UpdatePasswordMail;
|
||||
use App\Mail\UpdateRoleMail;
|
||||
use App\Notifications\VolunteerRoleUpdated;
|
||||
@@ -22,6 +25,7 @@ use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Services\UserService;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Pest\Support\Str;
|
||||
use Propaganistas\LaravelPhone\PhoneNumber;
|
||||
|
||||
@@ -383,4 +387,109 @@ class UserController extends Controller
|
||||
return response()->json(['message' => 'Server error'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function requestEmailChange(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$request->validate([
|
||||
'email' => ['required', 'email:strict,rfc', 'unique:users,email'],
|
||||
]);
|
||||
|
||||
$user = $request->user();
|
||||
|
||||
$token = \Str::random(64);
|
||||
|
||||
$user->pending_email = $request['email'];
|
||||
$user->email_change_token = hash('sha256', $token);
|
||||
$user->email_change_token_expires_at = now()->addHour();
|
||||
$user->save();
|
||||
|
||||
$data = [
|
||||
'name' => $user->name,
|
||||
'lastname' => $user->lastname,
|
||||
'token' => $token
|
||||
];
|
||||
Mail::to($user->email)->send(new NotifyEmailChangeMail($data));
|
||||
Mail::to($request['email'])->send(new RequestEmailChangeMail($data));
|
||||
|
||||
return response()->json(['message' => 'Un email de confirmation a été envoyé à votre nouvelle adresse.']);
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
return response()->json(['message' => 'Server error'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function confirmEmailChange(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$request->validate([
|
||||
'token' => ['required', 'string'],
|
||||
]);
|
||||
|
||||
$user = User::where('email_change_token', hash('sha256', $request['token']))
|
||||
->where('email_change_token_expires_at', '>', now())
|
||||
->firstOrFail();
|
||||
|
||||
$newEmail = $user->pending_email;
|
||||
$oldEmail = $user->email;
|
||||
|
||||
$user->email = $newEmail;
|
||||
$user->pending_email = null;
|
||||
$user->email_change_token = null;
|
||||
$user->email_change_token_expires_at = null;
|
||||
$user->save();
|
||||
|
||||
$data = [
|
||||
'name' => $user->name,
|
||||
'lastname' => $user->lastname,
|
||||
'newEmail' => $newEmail
|
||||
];
|
||||
Mail::to($newEmail)->send(new EmailChangeConfirmedMail($data));
|
||||
Mail::to($oldEmail)->send(new EmailChangeConfirmedMail($data));
|
||||
|
||||
return response()->json(['message' => 'Email mis à jour avec succès']);
|
||||
} catch (ModelNotFoundException $e) {
|
||||
return response()->json(['message' => 'Token invalide ou expiré'], 400);
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
return response()->json(['message' => 'Server error'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function show(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
return response()->json(['profile_photo_path' => $user->profile_photo_path]);
|
||||
}
|
||||
|
||||
public function updatePhoto(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'photo' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048',
|
||||
]);
|
||||
|
||||
$user = $request->user();
|
||||
$path = $request->file('photo')->store('profile-photos', 'public');
|
||||
|
||||
// Supprimer l'ancienne photo si elle existe
|
||||
if ($user->profile_photo_path) {
|
||||
Storage::disk('public')->delete($user->profile_photo_path);
|
||||
}
|
||||
|
||||
$user->update(['profile_photo_path' => $path]);
|
||||
|
||||
return response()->json(['profile_photo_path' => $path]);
|
||||
}
|
||||
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
if ($user->profile_photo_path) {
|
||||
Storage::disk('public')->delete($user->profile_photo_path);
|
||||
$user->update(['profile_photo_path' => null]);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Photo supprimée']);
|
||||
}
|
||||
}
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+1
@@ -11,6 +11,7 @@ class Event extends Model
|
||||
protected $fillable = [
|
||||
"name",
|
||||
"description",
|
||||
"event_photo_path",
|
||||
'start',
|
||||
'end',
|
||||
];
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+2
@@ -134,4 +134,6 @@ return [
|
||||
'admin_password' => env('ADMIN_PASSWORD') ?: 'admin',
|
||||
'admin_phone' => env('ADMIN_PHONE_NUMBER') ?: '0102030405',
|
||||
|
||||
'vite_api_url' => env('VITE_API_URL') ?: 'http://localhost:80',
|
||||
|
||||
];
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+1
@@ -15,6 +15,7 @@ return new class extends Migration
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('description');
|
||||
$table->string('event_photo_path', 2048)->nullable();
|
||||
$table->dateTime('start')->nullable();
|
||||
$table->dateTime('end')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+1
-1
@@ -11,7 +11,7 @@
|
||||
|
||||
<p>Vous avez demandé à changer votre adresse email. Cliquez sur le bouton ci-dessous pour confirmer ce changement.</p>
|
||||
<p style="text-align: center; margin: 30px 0;">
|
||||
<a href="{{ config('app.frontend_url') }}/confirm-email-change?token={{ $token }}"
|
||||
<a href="{{ config('vite_api_url') }}/confirm/email/change?token={{ $token }}"
|
||||
style="background-color: #f39c12; color: white; padding: 12px 20px; text-decoration: none; border-radius: 5px;">
|
||||
Confirmer le changement d'email
|
||||
</a>
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user