Как использовать jsx React в качестве замены почтового шаблона блейда Laravel ⇐ Php
Как использовать jsx React в качестве замены почтового шаблона блейда Laravel
I'm doing the forgot password and recover password feature using Laravel API and React. I've done the form and now I'm stuck at the backend part.
In the forgotPassword function, it will send a link for recover password at the user's email. But this code Mail::send('email.forgetPassword', is a view file for Laravel. How to adjust this part for React? This is my first time doing auth using Laravel hehe.
Function
public function forgotPassword(Request $request){ $request->validate(['email' => ['required', 'string', 'email', 'max:255']]); $token = Str::random(64); DB::table('password_reset_tokens')->insert([ 'email' => $request->email, 'token' => $token, 'created_at' => Carbon::now() ]); Mail::send('email.forgetPassword', ['token' => $token], function($message) use ($request){ $message->to($request->email); $message->subject('Reset Password'); } ); return response()->json(['message', 'We have e-mailed your password reset link!']); } Route
Route::post('forgot-password', [UserController::class, 'forgotPassword'])->name('password.email'); Forgot Password Form
const handleSubmit = async (event) => { event.preventDefault(); setLoading(true); setStatus(null); const data = {email}; try { await API.get("/api/csrf-cookie").then(async () => { const response = await API.post('/api/forgot-password', data); setStatus(response.data.status); if (response.data.error){ console.log(response.data.error); setLoading(false); } }); } catch (error){ console.log(error); setLoading(false); } }
Источник: https://stackoverflow.com/questions/781 ... l-template
I'm doing the forgot password and recover password feature using Laravel API and React. I've done the form and now I'm stuck at the backend part.
In the forgotPassword function, it will send a link for recover password at the user's email. But this code Mail::send('email.forgetPassword', is a view file for Laravel. How to adjust this part for React? This is my first time doing auth using Laravel hehe.
Function
public function forgotPassword(Request $request){ $request->validate(['email' => ['required', 'string', 'email', 'max:255']]); $token = Str::random(64); DB::table('password_reset_tokens')->insert([ 'email' => $request->email, 'token' => $token, 'created_at' => Carbon::now() ]); Mail::send('email.forgetPassword', ['token' => $token], function($message) use ($request){ $message->to($request->email); $message->subject('Reset Password'); } ); return response()->json(['message', 'We have e-mailed your password reset link!']); } Route
Route::post('forgot-password', [UserController::class, 'forgotPassword'])->name('password.email'); Forgot Password Form
const handleSubmit = async (event) => { event.preventDefault(); setLoading(true); setStatus(null); const data = {email}; try { await API.get("/api/csrf-cookie").then(async () => { const response = await API.post('/api/forgot-password', data); setStatus(response.data.status); if (response.data.error){ console.log(response.data.error); setLoading(false); } }); } catch (error){ console.log(error); setLoading(false); } }
Источник: https://stackoverflow.com/questions/781 ... l-template
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение