php Laravel:Forgot Password Controller for API

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Laravel:Forgot Password Controller for API相关的知识,希望对你有一定的参考价值。

<?php

namespace App\Http\Controllers\Api\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
use Illuminate\Support\Facades\Password;

class ForgotPasswordController extends Controller
{
	use SendsPasswordResetEmails;

	/**
	 * Create a new controller instance.
	 */
	public function __construct()
	{
		$this->middleware('guest');
	}

	public function __invoke(Request $request)
	{
		$this->validateEmail($request);

		// We will send the password reset link to this user. Once we have attempted
		// to send the link, we will examine the response then see the message we
		// need to show to the user. Finally, we'll send out a proper response.
		$response = $this->broker()->sendResetLink(
			$request->only('email')
		);

		return $response == Password::RESET_LINK_SENT
			? response()->json(['message' => 'Reset link sent to your email.', 'status' => true], 201)
			: response()->json(['message' => 'Unable to send reset link', 'status' => false], 401);
	}
}
<?php

Route::post('forgot/password', 'ForgotPasswordController')->name('forgot.password')

以上是关于php Laravel:Forgot Password Controller for API的主要内容,如果未能解决你的问题,请参考以下文章

重置密码链接Laravel 8中的动态域

攻防世界PWN题 forgot

在 Laravel 中的令牌旁边添加电子邮件忘记密码模板电子邮件链接(已解决)

bzoj3297[USACO2011 Open]forgot(dp + string)

Laravel 密码管理器解密密码

如何验证我的用户以登录 Laravel?