忘记API的密码功能

时间:2018-03-26 10:22:40

标签: laravel api laravel-5.6

我想在Laravel中实现API的忘记密码。我对输入密码和确认密码的URL应该感到困惑。

这是否发生在客户端?

我试过了:

Route::post('forgotpassword', 'Auth\PasswordController@get_email')->name('password.reset');
Route::get('{emailToken}', 'Auth\PasswordController@sendEmailDone')->name('newpassword');

在PasswordController中:

public function get_email(Request $request)
{
      $validator = Validator::make($request->all(), [

        'email' => 'required|email|max:100',

    ]);
    if ($validator->fails()) {
        return response()->json(['error'=>$validator->errors()], 401);            
    }else{

        $email=$request->email;

        $user=User::where('email',$email) -> first();

        Mail::to($email)->send(new forgotPassword($user));

        return response()->json(['msg'=>'email send']); 
    }
}

我不知道忘记密码功能如何适用于API。

0 个答案:

没有答案