2017-10-02 25 views
-1

パスワードリセットボタンをクリックすると、パスワードリセットリンクがユーザーの電子メールに送信されます。Laravel 5.4のパスワードをリセットする方法

私はそれは今働いていない形に

<form action="/company/password/reset/" method="POST"> 
     {{ csrf_field() }} 
     <div class="row"> 

     <div class="input-field col s12"> 

      <input placeholder="Enter your email" id="emails" type="email" class="validate" required name="email"> 
      <label for="emails">E-mail Address</label> 
     </div> 
     </div> 
     <p><button type="submit" method="post">SUBMIT</button></p> 
    </form> 

ルート

Route::post('/password/company/reset/', '[email protected]'); 

とコントローラ

public function company($email) 
    { 
     $company = $request->email; 
    Password::sendResetLink(['email' => $company]); 
    } 

を持って、これはそれを行うための正しい方法です?

私はこのエラーを取得するlaravel 5.4

にリセットパスワードをカバーする任意のチュートリアルを見つけることができません。

User must implement CanResetPassword interface.

答えて

1

フォームのアクションはルートが

Route::post('/password/company/reset/','[email protected]'); 
のように定義する必要があり、 /company/password/reset/ある場合

フォームの入力は、次のようにコントローラで取得できます。

public function company(Request $request) { 
    $email = $request->email; 
    ... 

documentationは、明示的に述べている:

To get started, verify that your App\User model implements the Illuminate\Contracts\Auth\CanResetPassword contract. Of course, the App\User model included with the framework already implements this interface, and uses the Illuminate\Auth\Passwords\CanResetPassword trait to include the methods needed to implement the interface.

あなたはいくつかのカスタム・ユーザー・モデルを持っているので、あなたがPassword::sendResetLink

+0

はありがとうござい使用するためには、この契約を実装する必要があります。しかし、どのように私はパスワードリセットリンクを送信するのですか? – Cowgirl

+0

Password :: sendResetLink($ company-> email);どうやらこれはうまくいかない、リセットリンクを送るこのような方法があるのだろうか? – Cowgirl

+0

https://laravel.com/docs/5.4/passwordsをお読みください。動作させるには、いくつかの条件があります。ログを確認し、関連するエラーメッセージで質問を更新することをお勧めします。教育的な推測をするには可動部分が多すぎます。ユーザが存在しない可能性があります。電子メールの転送が正しく設定されていないなどのエラーが表示されます。 –

関連する問題