Add IDs to logs to identify the user concerned by the logged event

This commit is contained in:
Bubka 2023-02-21 14:09:36 +01:00
parent 5c83e17752
commit ed3a17a4fb
6 changed files with 9 additions and 8 deletions

View File

@ -30,7 +30,7 @@ public function update(UserPatchPwdRequest $request)
$request->user()->update([
'password' => bcrypt($validated['password']),
]);
Log::info('User password updated');
Log::info(sprintf('Password of user id #%s updated', $request->user()->id));
}
return response()->json(['message' => __('auth.forms.password_successfully_changed')]);

View File

@ -36,7 +36,7 @@ public function register(UserStoreRequest $request)
{
$validated = $request->validated();
event(new Registered($user = $this->create($validated)));
Log::info('User created');
Log::info(sprintf('User id #%s created', $user->id));
$this->guard()->login($user);

View File

@ -37,7 +37,7 @@ public function update(UserUpdateRequest $request)
'email' => $validated['email'],
]);
}
Log::info('User account updated');
Log::info(sprintf('Account of user id #%s updated', $user->id));
return new UserResource($user);
}
@ -50,9 +50,10 @@ public function update(UserUpdateRequest $request)
*/
public function delete(UserDeleteRequest $request)
{
Log::info('User deletion requested');
$validated = $request->validated();
Log::info(sprintf('Deletion of user id #%s requested', $validated['user_id']));
if (! Hash::check($validated['password'], Auth::user()->password)) {
return response()->json(['message' => __('errors.wrong_current_password')], 400);
}
@ -83,7 +84,7 @@ public function delete(UserDeleteRequest $request)
return response()->json(['message' => __('errors.user_deletion_failed')], 400);
}
// @codeCoverageIgnoreEnd
Log::info('User deleted');
Log::info(sprintf('User id #%s deleted', $validated['user_id']));
return response()->json(null, 204);
}

View File

@ -41,7 +41,7 @@ public function handle($request, Closure $next, ...$guards)
$user->last_seen_at = $now->format('Y-m-d H:i:s');
$user->save();
Log::info('Inactive user detected, authentication rejected');
Log::info(sprintf('User id #%s detected as inactive, authentication rejected', $user->id));
if (method_exists('Illuminate\Support\Facades\Auth', 'logout')) {
Auth::logout();
}

View File

@ -17,7 +17,7 @@ class RejectIfReverseProxy
public function handle($request, Closure $next)
{
if (config('auth.defaults.guard') === 'reverse-proxy-guard') {
Log::info('Cannot request this action in Demo mode');
Log::info('Cannot request this action in reverse proxy mode');
return response()->json([
'message' => __('errors.unsupported_with_reverseproxy'),

View File

@ -56,7 +56,7 @@ public function sendPasswordResetNotification($token)
{
$this->notify(new ResetPassword($token));
Log::info('Password reset token sent');
Log::info(sprintf('Password reset token sent to user id "%s', $this->id));
}
/**