Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions resources/views/components/layouts/public.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,31 @@ class="w-10 h-10 rounded-full bg-primary text-primary-content flex items-center
</div>
</header>

<!-- Password Breach Warning Alert -->
<div
x-data="{ show: true }"
x-show="show"
x-init="setTimeout(() => show = false, 20000)"
class="bg-warning/20 border-l-4 border-warning text-warning-content dark:text-warning-content-light rounded shadow-md mb-4 transition-all duration-500"
role="alert"
>
<div class="container mx-auto px-4 sm:px-6 lg:px-8 py-3 flex items-center justify-between">
<div class="flex items-center">
<x-mary-icon name="o-exclamation-triangle" class="h-5 w-5 mr-3 text-warning" />
<span class="text-sm font-medium text-black dark:text-warning-content">
{{ session('password_breach_warning') }}
</span>
</div>
<button
@click="show = false"
class="text-warning hover:text-warning-focus font-bold focus:outline-none"
>
</button>
</div>
</div>


<!-- Main Content -->
<main class="min-h-screen">
{{ $slot }}
Expand Down
51 changes: 46 additions & 5 deletions resources/views/livewire/auth/login.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Illuminate\Auth\Events\Lockout;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Session;
Expand Down Expand Up @@ -40,6 +41,11 @@ public function login(): void
RateLimiter::clear($this->throttleKey());
Session::regenerate();

if ($this->isPasswordPwned($this->password)) {
// Flash a warning message after successful login
session()->flash('password_breach_warning', '⚠️ Your password has appeared in a data breach. For your safety, please change it soon.');
}

$this->redirectIntended(default: route('home', absolute: false), navigate: true);
}

Expand Down Expand Up @@ -71,6 +77,39 @@ protected function throttleKey(): string
{
return Str::transliterate(Str::lower($this->email).'|'.request()->ip());
}




Comment on lines +81 to +83
Copy link
Preview

Copilot AI Sep 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the excessive blank lines (lines 80-83) before the isPasswordPwned method to maintain consistent code formatting.

Suggested change

Copilot uses AI. Check for mistakes.

protected function isPasswordPwned(string $password): bool
{
$sha1 = strtoupper(sha1($password));
$prefix = substr($sha1, 0, 5);
$suffix = substr($sha1, 5);

$response = Http::get("https://api.pwnedpasswords.com/range/{$prefix}");
if ($response->failed()) {
return false; // fail-safe
}

foreach (explode("\n", $response->body()) as $line) {
[$hashSuffix, $count] = explode(':', $line);
if ($suffix === trim($hashSuffix)) {
return true;
}
}
Copy link
Preview

Copilot AI Sep 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code doesn't handle empty lines or malformed responses from the API. Add validation to ensure $line contains a colon before using explode(':', $line) to prevent potential errors.

Copilot uses AI. Check for mistakes.


return false;
}









Comment on lines +113 to +121
Copy link
Preview

Copilot AI Sep 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the excessive blank lines (lines 104-112) at the end of the class to maintain consistent code formatting.

Suggested change

Copilot uses AI. Check for mistakes.

Comment on lines +114 to +121
Copy link
Preview

Copilot AI Sep 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excessive blank lines after the method. Remove unnecessary empty lines to maintain consistent code formatting.

Suggested change

Copilot uses AI. Check for mistakes.

Comment on lines +114 to +121
Copy link
Preview

Copilot AI Sep 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the excessive blank lines at the end of the function. Use consistent spacing with at most one blank line.

Suggested change

Copilot uses AI. Check for mistakes.

}; ?>

<div class="flex flex-col gap-6">
Expand All @@ -79,11 +118,13 @@ protected function throttleKey(): string
<p class="mt-1 text-sm text-base-content/70">{{ __('Enter your email and password below to log in') }}</p>
</div>

@if (session('status'))
<x-mary-alert color="info" class="text-center">
{{ session('status') }}
</x-mary-alert>
@endif
@if (session('status'))
<x-mary-alert color="warning" class="text-center">
{{ session('status') }}
</x-mary-alert>
@endif



Comment on lines +136 to 137
Copy link
Preview

Copilot AI Sep 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the trailing whitespace on line 127 and the unnecessary blank line 128 to maintain clean formatting.

Suggested change

Copilot uses AI. Check for mistakes.

<form method="POST" wire:submit="login" class="flex flex-col gap-6">
<x-mary-input
Expand Down