F
Filamentβ€’2y ago
Yasser

Reverify Email when changed

Hello everyone, I am quite new to filament, I am trying to add a page where my Admin users can manage their account. Since I don't want users without a verified email to be able to make changes I want to unverify the email when they change it from the page. Tough I am not sure if this is the way to do it (the breeze controller for example does it quite different) Any input would be appreciated!
public $user;//Storing User here

public function mount()
{
$this->user = auth()->user(); //Getting my user from the available auth
$this->updateProfileForm->fill($this->user->toArray());//I saw this in someone elses code ? is this safe?
}
public function updateProfile(): void
{
//!! This is what I am worried about, is this right ?
if ($this->updateProfileForm->getState()['email'] !== $this->user->email) {
$this->user->email_verified_at = null;
}
$this->user->update($this->updateProfileForm->getState());
$this->notify('success', 'Your information has been updated');
}
public $user;//Storing User here

public function mount()
{
$this->user = auth()->user(); //Getting my user from the available auth
$this->updateProfileForm->fill($this->user->toArray());//I saw this in someone elses code ? is this safe?
}
public function updateProfile(): void
{
//!! This is what I am worried about, is this right ?
if ($this->updateProfileForm->getState()['email'] !== $this->user->email) {
$this->user->email_verified_at = null;
}
$this->user->update($this->updateProfileForm->getState());
$this->notify('success', 'Your information has been updated');
}
Thanks a lot in advance!
7 Replies
Yasser
YasserOPβ€’2y ago
Also the notify does not seem to be working...
Dennis Koch
Dennis Kochβ€’2y ago
Yeah, I think that's okay. For the notifications: Did you start from the page view? Or create your own? I think the notifications component must be included on pages
Yasser
YasserOPβ€’2y ago
Oh hello Dennis, thank you for your reply! I just installed the notifications on top of filament, and poof my console is blood red now Since I did start from a Page ->
class Account extends Page implements HasForms{
///Code
}
class Account extends Page implements HasForms{
///Code
}
In short this is the error I get when I would 'trigger' a notification now :
Alpine: Cannot reference "$wire" outside a Livewire component.
Alpine: Cannot reference "$wire" outside a Livewire component.
Dennis Koch
Dennis Kochβ€’2y ago
No need to install anything inside the admin panel. It works out of the box.
Yasser
YasserOPβ€’2y ago
Yeah, I noticed. Its going to hurt getting this back to where it was. But thats okay πŸ˜„ Unfortunately it is not working now , nor if I use
php
Notification::make()->title('Hello')->send();
php
Notification::make()->title('Hello')->send();
Since I am getting above Error on alpine Thanks, I;ll try reverting breaking everything now XD Can I mark this issue as resolved somehow ? I rather Put the notification issue in a different thread somehow, it does not seem to be working on the page
Dennis Koch
Dennis Kochβ€’2y ago
I can close it
Yasser
YasserOPβ€’2y ago
Thank you!
Want results from more Discord servers?
Add your server