Giter VIP home page Giter VIP logo

protonemedia / laravel-verify-new-email Goto Github PK

View Code? Open in Web Editor NEW
397.0 8.0 32.0 84 KB

This package adds support for verifying new email addresses: when a user updates its email address, it won't replace the old one until the new one is verified.

Home Page: https://protone.media/en/blog/an-add-on-to-laravels-built-in-email-verification-only-update-a-users-email-address-if-the-new-one-is-verified-as-well

License: MIT License

PHP 97.42% Blade 2.58%
laravel laravel-framework mail-verification email-verification

laravel-verify-new-email's Issues

Usage with Jetstream

Hi

is there anywhere a guide how to use/implement this package with laravel jetstream scaffolded app?

best regards
matthias

Email not getting verified

Hi, i did every thing just as the instruction implies but i think am missing something here.

When ever i initialise this $user->newEmail($data['email']); the email address specified receives the new email verification link but when i click on the link,

i get this Google Chrome This site can’t be reached page instead of verifying and redirecting to homepage.

Meanwhile the old email address doesn't change to the new one and the pending email is still there.

Thank you.

E-mail template is not fixed

The e-mail template for new mail is not as fixed as the typical Laravel e-mail template. The width should be fixed to 570px, but it isn't.

Laravel mail from Notifiable:
image

Verify new e-mail:
image

I've even created a new Laravel app to test it out if one of my templates isn't corrupted but it did not help.
image

Email is not sent

I implemented the package on my local machine with sail. Everything seemed fine and I was able to receive the mails after changing the email address.

Once I uploaded it on my server, nothing happened after the email is changed. In the pending_user_emails table the entry with the new email is adde, but the mail is missing. No error message and nothing in the log.

First I thought mailing is not working at all, but the laravel Breeze emails are being sent out.

On my server I have PHP 8.1.5 and Laravel is on Version 9.2.

And idea what I should/can check to find the issue?

I want to show a success message after verification !!

i used VerifyFirtsEmail , i want to show a success message after verification !!
i do this in my user model
public function sendEmailVerificationNotification() { $this->newEmail($this->getEmailForVerification()); }

Class PendingUserEmail not allowing mass assignment

Hi.

I'm getting this error when calling newEmail method with Laravel 6.9 under Valet on MacOS:
Add [user_type] to fillable property to allow mass assignment on [ProtoneMedia\LaravelVerifyNewEmail\PendingUserEmail].

Checking the PendingUserEmail class, it's doesn't have the fillable attribute indeed.

Thanks for this package and any help you could provide.

localized email templates

first email :

@component('mail::message')
    # {{ \Illuminate\Support\Facades\Lang::get('Verify Email Address') }}

    # {{ \Illuminate\Support\Facades\Lang::get('Please click the button below to verify your email address.') }}

    @component('mail::button', ['url' => $url])
        # {{ \Illuminate\Support\Facades\Lang::get('Verify Email Address') }}
    @endcomponent

    {{ \Illuminate\Support\Facades\Lang::get('If you did not create an account, no further action is required.') }}

    {{ \Illuminate\Support\Facades\Lang::get('Thanks') }},<br>
    {{ config('app.name') }}
@endcomponent

new email

@component('mail::message')
    # {{ \Illuminate\Support\Facades\Lang::get('Verify New Email Address') }}

    # {{ \Illuminate\Support\Facades\Lang::get('Please click the button below to verify your new email address.') }}

    @component('mail::button', ['url' => $url])
        # {{ \Illuminate\Support\Facades\Lang::get('Verify Email New Address') }}
    @endcomponent

    {{ \Illuminate\Support\Facades\Lang::get('If you did not update your email address, no further action is required.') }}

    {{ \Illuminate\Support\Facades\Lang::get('Thanks') }},<br>
    {{ config('app.name') }}
@endcomponent

Laravel 9

Please,
This package is great, If you could make it compatible with Laravel 9.
Coming soon...

Call to undefined method Illuminate\Foundation\Application::forUser()

Hello,

When I am using newEmail method in update profile section, like:
$user->newEmail(request('email'));
I am getting the error as below:

Call to undefined method Illuminate\Foundation\Application::forUser()

App\User::clearPendingEmail
vendor/protonemedia/laravel-verify-new-email/src/MustVerifyNewEmail.php:65
Which is:
app(config('verify-new-email.model'))->forUser($this)->get()->each->delete();

Please advise. I am using Laravel 7.12

Thank you

need email_verified_at set null first to using newEmail()?

I use livewire, when updating an email I use

   if ($this->email != $this->user->email) {
             $this->user->email_verified_at = null;
             $this->user->newEmail($this->user->email);
  }

if email_verified_at is not set to null, newEmail() will not create a new record in the pending_user_emails table

this is my edit file

class Edit extends Component {
    public User $user;

    public $roles          = [];
    public $listsForFields = [];

    public $password              = '';
    public $password_confirmation = '';

    public $email = '';

    public function mount(User $user) {
        $this->user  = $user;
        $this->email = $this->user->email;
        $this->roles = $this->user->roles()->pluck('id')->toArray();
        $this->initListsForFields();
    }

    public function render() {
        return view('livewire.user.edit');
    }

    public function submit() {
        $this->validate();
        $this->user->password = $this->password;

        if ($this->email != $this->user->email) {
            $this->user->email_verified_at = null;
            $this->user->newEmail($this->user->email);
        } else {
            $this->user->save();
        }
        $this->user->roles()->sync($this->roles);

        return redirect()->route('users.index');
    }

    protected function rules() {
        return [
            'user.name'             => ['required', 'string', 'max:255'],
            'user.email'            => ['required', 'email', 'max:255', 'unique:users,email,' . $this->user->id],
            'user.biography'        => ['nullable'],
            'roles'                 => ['required', 'array'],
            'roles.*.id'            => ['integer', 'exists:roles,id'],
            'password'              => ['string', 'min:8', 'confirmed'],
            'password_confirmation' => ['string', 'min:8'],
        ];
    }

    public function initListsForFields(): void {
        $this->listsForFields['roles'] = Role::pluck('name', 'id')->toArray();
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.