“Zmień funkcję hasła w Laravel” Kod odpowiedzi

Zmień funkcję hasła w Laravel

<?php
   
namespace App\Http\Controllers;
   
use Illuminate\Http\Request;
use App\Rules\MatchOldPassword;
use Illuminate\Support\Facades\Hash;
use App\User;
  
class ChangePasswordController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }
   
    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function index()
    {
        return view('changePassword');
    } 
   
    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function store(Request $request)
    {
        $request->validate([
            'current_password' => ['required', new MatchOldPassword],
            'new_password' => ['required'],
            'new_confirm_password' => ['same:new_password'],
        ]);
   
        User::find(auth()->user()->id)->update(['password'=> Hash::make($request->new_password)]);
   
        dd('Password change successfully.');
    }
}
Rich Ray

Laravel Logout po zmianie hasła

<?php
//$user->passwordChangeMagicHere()

Auth::login($user);
//And the user is logged in again!
Aashiq Hasnat

Odpowiedzi podobne do “Zmień funkcję hasła w Laravel”

Pytania podobne do “Zmień funkcję hasła w Laravel”

Więcej pokrewnych odpowiedzi na “Zmień funkcję hasła w Laravel” w PHP

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu