Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lowercase email on registration #319

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Illuminate\Validation\Rules;

class RegisteredUserController extends Controller
Expand All @@ -20,6 +21,10 @@ class RegisteredUserController extends Controller
*/
public function store(Request $request): Response
{
$request->whenFilled('email', fn () => $request->merge(
['email' => Str::lower($request->email)]
));

$request->validate([
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:'.User::class],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Illuminate\Validation\Rules;
use Illuminate\View\View;

Expand All @@ -30,6 +31,10 @@ public function create(): View
*/
public function store(Request $request): RedirectResponse
{
$request->whenFilled('email', fn () => $request->merge(
['email' => Str::lower($request->email)]
));

$request->validate([
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:'.User::class],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Illuminate\Validation\Rules;
use Inertia\Inertia;
use Inertia\Response;
Expand All @@ -31,6 +32,10 @@ public function create(): Response
*/
public function store(Request $request): RedirectResponse
{
$request->whenFilled('email', fn () => $request->merge(
['email' => Str::lower($request->email)]
));

$request->validate([
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:'.User::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use App\Providers\RouteServiceProvider;
use Illuminate\Auth\Events\Registered;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Illuminate\Validation\Rules;
use function Livewire\Volt\layout;
use function Livewire\Volt\rules;
Expand All @@ -25,6 +26,8 @@
]);

$register = function () {
$this->email = Str::lower($this->email);

$validated = $this->validate();

$validated['password'] = Hash::make($validated['password']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
use App\Providers\RouteServiceProvider;
use Illuminate\Auth\Events\Registered;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Illuminate\Validation\Rules;
use Livewire\Attributes\Layout;
use Livewire\Volt\Component;

new #[Layout('layouts.guest')] class extends Component
{
public string $name = '';

public string $email = '';

public string $password = '';

public string $password_confirmation = '';

public function register(): void
{
$this->email = Str::lower($this->email);

$validated = $this->validate([
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:'.User::class],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
{
#[Locked]
public string $token = '';

public string $email = '';

public string $password = '';

public string $password_confirmation = '';

public function mount(string $token): void
Expand Down
Loading