© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•9mo ago•
4 replies
__Dementor

Customize registration logic

Hi, I want to change the account registration logic to provide a verification code when registering. I have the field itself added and the handling of this field done, but the problem arises when it wants to verify this code. If the user enters a code that is wrong, or the code is not assigned to his username, at that point it rejects the registration and does not make the account. Otherwise, the account should be created. I have such a code:

protected function handleRegistration(array $data): Model {
    $username = $data['username'];
    $verifyCode = $data['verify_code'];
    $password = Hash::make($data['password']);

    // Bool
    $verifyResult = $this->checkVerifyCode($verifyCode, $username);

    if ($verifyResult) {

        $user = User::query()
            ->create([
                'uuid' => $this->getUserUUID($username),
                'used_verification_code' => $verifyCode,
                'username' => $username,
                'password' => $password,
            ]);

        $verifyCode = VerifyCode::query()->where('code', $verifyCode)->first();
        $verifyCode->delete();

        return $user;

    }
}
protected function handleRegistration(array $data): Model {
    $username = $data['username'];
    $verifyCode = $data['verify_code'];
    $password = Hash::make($data['password']);

    // Bool
    $verifyResult = $this->checkVerifyCode($verifyCode, $username);

    if ($verifyResult) {

        $user = User::query()
            ->create([
                'uuid' => $this->getUserUUID($username),
                'used_verification_code' => $verifyCode,
                'username' => $username,
                'password' => $password,
            ]);

        $verifyCode = VerifyCode::query()->where('code', $verifyCode)->first();
        $verifyCode->delete();

        return $user;

    }
}

But this method requires returning the User model. What if the verification code validation fails? What should I do?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to customize filament breezy registration page?
FilamentFFilament / ❓┊help
3y ago
Registration
FilamentFFilament / ❓┊help
3y ago
Registration?
FilamentFFilament / ❓┊help
3y ago
CanAccessPanel logic causing 403 error for livewire.update on Tenant Registration Form
FilamentFFilament / ❓┊help
2y ago