File: D:/HostingSpaces/SBogers10/hours.komma.pro/app/Komma/Users/UserController.php
<?php
namespace App\Komma\Users;
use App\Http\Controllers\Controller;
use App\Mail\SendPasswordResetMail;
use Illuminate\Foundation\Auth\ResetsPasswords;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Session;
class UserController extends Controller
{
use ResetsPasswords;
public function __construct()
{
$this->middleware('auth');
$this->authorizeResource(User::class, 'user');
}
/**
* @param User $user
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function show(User $user)
{
return view('users.show')
->with('user', $user);
}
/**
* @param Request $request
* @param User $user
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/
public function update(Request $request, User $user)
{
$this->authorize('update', $user);
//new passwords does not match
if ($request->password != $request->password_confirmation) return back()->with('message', 'De nieuwe wachtwoorden komen niet overeen');
// If not admin, then we verify that the user know it's current password before changing it
if(!Auth::user()->isAdmin() && !Hash::check($request->currentPass, $user->password)) {
return back()->with('message', 'Het huidige wachtwoord is onjuist');
}
//update password
$this->setUserPassword($user, $request->password);
$user->save();
//return
return back()->with('message', 'Wachtwoord gewijzigd');
}
}