clarkeash / doorman

Limit access to your Laravel applications by using invite codes
https://packagist.org/packages/clarkeash/doorman
MIT License
1.02k stars 45 forks source link

disallow code for email if email already exists #29

Closed vesper8 closed 6 years ago

vesper8 commented 6 years ago

I just noticed that there is nothing to prevent creating two codes for the same email

$invite = \Doorman::generate()->for("someemail@email.com")->make();
$invite = \Doorman::generate()->for("someemail@email.com")->make();

generates two rows and two codes

Would be nice if this instead threw an exception "code for email already exists"

vesper8 commented 6 years ago

This is easily remedied with

        if(!$invite = Invite::where("for", $user->email)->first()) {
            $invite = \Doorman::generate()->for($user->email)->make();
        }

        ddd($invite);

Just thought it would be nice to have it built-in

clarkeash commented 6 years ago

Hey, this is fixed. Sorry it took so long I havent had much time to work on open source lately. I should be tagging 2.0 later today with this fix in (will require laravel 5.6 and php 7.1)