2017-04-14 9 views
-2

「jrean/laravel-user-verification」パッケージを使用します。トークンを使ってリンクをクリックすると、ホームページにリダイレクトされ、既にログに記録されます。これをどのように実装できますか? 5.4 パッケージのバージョン:4.1トークンとのリンクをクリックした後の自動ログイン

+2

public function register(VerificationRequest $request) { ... event(new Registered($user)); ... } 

Сreateリスナー:私のレジスタ機能(RegisterController)イベントに追加

<?php namespace App\Listeners; use Illuminate\Auth\AuthManager; use Jrean\UserVerification\Events\UserVerified; /** * Class UserVerifiedListener * @package App\Listeners */ class UserVerifiedListener { /** * @var AuthManager */ private $auth; /** * Create the event listener. * * @param AuthManager $auth */ public function __construct(AuthManager $auth) { $this->auth = $auth; } /** * Handle the event. * * @param UserVerified $event * @return void */ public function handle(UserVerified $event) { $this->auth->guard()->login($event->user); } } 

し、それを登録します。良い質問をする方法のガイドを読んでください:https://stackoverflow.com/help/how-to-ask –

+0

申し訳ありませんが、私はLaravel Authの箱から取り出して、 "jrean/laravel-user"のコードを書き換えません - 検証パッケージ。標準コードをコピーする意味がありません。 –

答えて

0

は、この問題を解決する)

Laravelをいただき、ありがとうございます。いくつかのコードを追加してください

app/Providers/EventServiceProvider.php 
<?php 

namespace App\Providers; 

use App\Listeners\UserVerifiedListener; 
use Illuminate\Support\Facades\Event; 
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; 
use Jrean\UserVerification\Events\UserVerified; 

class EventServiceProvider extends ServiceProvider 
{ 
    /** 
    * The event listener mappings for the application. 
    * 
    * @var array 
    */ 
    protected $listen = [ 
     UserVerified::class => [ 
      UserVerifiedListener::class 
     ], 
    ]; 

    /** 
    * Register any events for your application. 
    * 
    * @return void 
    */ 
    public function boot() 
    { 
     parent::boot(); 

     // 
    } 

    public function register() 
    { 
     $this->app->bind(UserVerifiedListener::class, function() { 
      return new UserVerifiedListener(
       $this->app->make('auth') 
      ); 
     }); 
    } 
} 
関連する問題