2015-10-06 75 views
0

我有一個簡單的CRUD應用程序中可以添加用戶,通過表單,理想的流量是重用密碼經紀人邏輯發送激活郵件

  • 管理員填充與用戶名和形式密碼
  • 一封郵件發送給用戶一個鏈接來設置密碼
  • 的用戶登錄

現在,在這一天我真正想要的是,PasswordBroker不會結束,但而不是發送emails.passsowrd視圖我想要一個不同的,其餘的邏輯可以是相同的

有沒有一種簡單的方法,因此創建一個有效的passwordBroker isntace並傳遞不同的視圖?

財產emailWiew是受保護的,所以我不能覆蓋它,我想出去的創建一個新實例的IoC

$tokens = $this->app['auth.password.tokens']; 

$users = $this->app['auth']->driver()->getProvider(); 

$view = "emails.createPassword"; 

$password = new PasswordBroker(
    $tokens, $users, $this->app['mailer'], $view 
); 
dd($users->retrieveByCredentials(["[email protected]"])); //i get null and the user email is valid 

$response = $password->sendResetLink(["[email protected]"], function (Message $message) { 
    $message->subject("Set your password"); 
}); 
dd($response); // I get "passwords.user" wich is an error 

,但是當我通過電子郵件地址,我得到一個無效的用戶錯誤

任何想法?

回答

0

問題是你沒有提供密鑰來檢索憑據,所以它試圖通過名稱「0」在用戶表中獲得一個字段。使用以下,它將工作:

$response = $password->sendResetLink(
    ["email" => "[email protected]"], 
    function (Message $message) { 
     $message->subject("Set your password"); 
}); 
+0

當然!非常感謝,我現在感到非常愚蠢! –