mercredi 27 mars 2019

Mutli Guard User Authentication Email Verfication not firing automatically Laravel

I have these guards and i have created the register/login workflow which works fine, but I also need each one to have an email verification being fired prior to being able to log, which does not seem to be fired or working

I checked the event service and it seems to be working as well

My objective is to create a multi auth system that also fires verification emails to the users who register under each guard, there is no other support therefore I feel like my question will set precedence for others who have the same issue

I have set my email to log and it does not show on laravel's telescope module (log viewer)

These are my routes related to Auth

Auth::routes(['verify' => true]);
/*Start Login and Register Related Events*/
Route::get('/login/lawyers', 'Auth\LoginController@showLawyerloginForm');
Route::get('/login/customers', 'Auth\LoginController@showCustomerLoginForm');
Route::get('/login/admins', 'Auth\LoginController@showAdminloginForm');
Route::get('/register/lawyers', 'Auth\RegisterController@showLawyerRegisterForm');
Route::get('/register/customers', 'Auth\RegisterController@showCustomerRegisterForm');
Route::get('/register/admins', 'Auth\RegisterController@showAdminRegisterForm');

Route::post('/login/lawyers', 'Auth\LoginController@lawyerLogin');
Route::post('/login/customers', 'Auth\LoginController@customerLogin');
Route::post('/login/admins', 'Auth\LoginController@adminLogin');
Route::post('/register/lawyers', 'Auth\RegisterController@createLawyer');
Route::post('/register/customers', 'Auth\RegisterController@createCustomer');
Route::post('/register/admins', 'Auth\RegisterController@createAdmin');
/*End Login and Register Related Events*/

This is an example of my Lawyer Model (Authenticatable)

<?php

namespace App;

use App\Events\LawyerCreated;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Database\Eloquent\SoftDeletes;

class Lawyer extends Authenticatable implements MustVerifyEmail
{
    use SoftDeletes;
    use Notifiable;
    //
    protected $dispatchesEvents  = [
        'created' => LawyerCreated::class
    ];
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'fname', 'oname', 'lname', 'address', 'email', 'password', 'nic', 'mobile',
    ];

    /**
     * The attribute name containing the email address.
     *
     * @var string
     */
    public $gravatarEmail = 'email';
    public $profile = 'profile_url';

    public function getAvatar()
    {
        if($this->attributes[$this->profile] != "-"){
            return url($this->profile);
        }else{
            $hash = md5(strtolower(trim($this->attributes[$this->gravatarEmail])));
            return "https://www.gravatar.com/avatar/".$hash;
        }
    }

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    public function firm()
    {
        # code...
        return $this->belongsToMany('App\Firm')->withTimestamps();
    }

    public function myfiles()
    {
        # code...
        return $this->hasOne('App\File', 'lawyer_id');
    }

    public function files()
    {
        # code...
        return $this->belongsToMany('App\File')->withTimestamps();
    }

    public function myfirm()
    {
        # code...
        return $this->hasOne('App\Firm', 'lawyer_id');
    }

    //
    public function mobiles()
    {
        return $this->morphMany('App\Mobile', 'hasmobile');
    }

    /**
     * The roles that belong to the lawyer.
     */
    public function roles()
    {
        return $this->belongsToMany('App\Role')->withPivot('id');;
    }

    /**
     * Get the comments for the blog post.
     */
    public function notifications()
    {
        return $this->hasMany('App\LawyerNotification');
    }

    public function cases()
    {
        # code...
        return $this->hasMany('App\CourtCase');
    }

    public function clients()
    {
        # code...
        return $this->hasMany('App\Customer');
    }

    public function tasks()
    {
        return $this->hasMany('App\Task');
    }

    public function communications()
    {
        # code...
        return $this->hasMany('App\Communication', 'lawyer_id');
    }

    public function expenses()
    {
        # code...
        return $this->hasMany('App\Expense', 'lawyer_id');
    }

    public function invoices()
    {
        # code...
        return $this->hasMany('App\Invoice', 'lawyer_id');
    }

    public function activities()
    {
        # code...
        return $this->hasMany('App\Activity', 'lawyer_id');
    }

    public function billings()
    {
        # code...
        return $this->hasMany('App\Billing', 'lawyer_id');
    }

    public function billingpayments()
    {
        # code...
        return $this->hasMany('App\BillingPayment', 'lawyer_id');
    }
}

These are from Auth.php

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Authentication Defaults
    |--------------------------------------------------------------------------
    |
    | This option controls the default authentication "guard" and password
    | reset options for your application. You may change these defaults
    | as required, but they're a perfect start for most applications.
    |
    */

    'defaults' => [
        'guard' => 'lawyers',
        'passwords' => 'users',
    ],

    /*
    |--------------------------------------------------------------------------
    | Authentication Guards
    |--------------------------------------------------------------------------
    |
    | Next, you may define every authentication guard for your application.
    | Of course, a great default configuration has been defined for you
    | here which uses session storage and the Eloquent user provider.
    |
    | All authentication drivers have a user provider. This defines how the
    | users are actually retrieved out of your database or other storage
    | mechanisms used by this application to persist your user's data.
    |
    | Supported: "session", "token"
    |
    */

    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],
        'lawyers' => [
            'driver' => 'session',
            'provider' => 'lawyers',
        ],
        'customers' => [
            'driver' => 'session',
            'provider' => 'customers',
        ],
        'admins' => [
            'driver' => 'session',
            'provider' => 'admins',
        ],
        'api' => [
            'driver' => 'token',
            'provider' => 'users',
        ],
    ],



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2JJ8YSw
via IFTTT

Aucun commentaire:

Enregistrer un commentaire