public function performLogin(Request $request) { $username = $request->input('username'); $password = $request->input('password'); $credentials_valid = UserHelper::checkCredentials($username, $password); if ($credentials_valid != false) { // log user in $role = $credentials_valid['role']; $request->session()->put('username', $username); $request->session()->put('role', $role); return redirect()->route('index'); } else { return redirect('login')->with('error', 'Invalid password or inactivated account. Try again.'); } }
public function changePassword(Request $request) { if (!$this->isLoggedIn()) { return abort(404); } $username = session('username'); $old_password = $request->input('current_password'); $new_password = $request->input('new_password'); if (UserHelper::checkCredentials($username, $old_password) == false) { // Invalid credentials return redirect('admin')->with('error', 'Current password invalid. Try again.'); } else { // Credentials are correct $user = UserHelper::getUserByUsername($username); $user->password = Hash::make($new_password); $user->save(); $request->session()->flash('success', "Password changed successfully."); return redirect(route('admin')); } }