/** * Update user permissions * * @author Steve Montambeault * @link http://stevemo.ca * * @param int $userId * @return Response */ public function update($userId) { try { $permissions = Input::get('permissions', array()); $this->users->updatePermissions($userId, $permissions); return Redirect::route('cpanel.users.index')->with('success', Lang::get('cpanel::users.permissions_update_success')); } catch (UserNotFoundException $e) { return Redirect::route('cpanel.users.permissions')->with('error', $e->getMessage()); } }
/** * Update the throttle status for a given user * * @author Steve Montambeault * @link http://stevemo.ca * * @param $id * @param $action * * @return \Illuminate\Http\RedirectResponse */ public function putStatus($id, $action) { try { $this->users->updateThrottleStatus($id, $action); return Redirect::route('cpanel.users.index')->with('success', Lang::get('cpanel::throttle.success', array('action' => $action))); } catch (UserNotFoundException $e) { return Redirect::route('cpanel.users.index')->with('error', $e->getMessage()); } catch (\BadMethodCallException $e) { return Redirect::route('cpanel.users.index')->with('error', "This method is not suported [{$action}]"); } }
/** * Reset a given user password * * @author Steve Montambeault * @link http://stevemo.ca * * @param array $creds * * @return bool */ public function reset(array $creds) { try { if ($this->validator->with($creds)->passes()) { $this->users->resetPassword($creds['code'], $creds['password']); return true; } } catch (UserNotFoundException $e) { $this->validator->add('UserNotFoundException', $e->getMessage()); } return false; }
/** * Activate a user * * @author Steve Montambeault * @link http://stevemo.ca * * @param $id * * @return \Illuminate\Http\RedirectResponse */ public function putActivate($id) { try { if ($this->users->activate($id)) { // User activation passed return Redirect::route('cpanel.users.index')->with('success', Lang::get('cpanel::users.activation_success')); } else { // User activation failed return Redirect::route('cpanel.users.index')->with('error', Lang::get('cpanel::users.activation_fail')); } } catch (UserNotFoundException $e) { return Redirect::route('cpanel.users.index')->with('error', $e->getMessage()); } }
/** * Validate and log in a user * * @author Steve Montambeault * @link http://stevemo.ca * * @param array $credentials * @param bool $remember * * @return bool */ public function login(array $credentials, $remember) { try { $this->users->authenticate($credentials, $remember); return true; } catch (LoginRequiredException $e) { $this->validator->add('LoginRequiredException', $e->getMessage()); } catch (PasswordRequiredException $e) { $this->validator->add('PasswordRequiredException', $e->getMessage()); } catch (WrongPasswordException $e) { $this->validator->add('WrongPasswordException', $e->getMessage()); } catch (UserNotActivatedException $e) { $this->validator->add('UserNotActivatedException', $e->getMessage()); } catch (UserNotFoundException $e) { $this->validator->add('UserNotFoundException', $e->getMessage()); } catch (UserSuspendedException $e) { $this->validator->add('UserSuspendedException', $e->getMessage()); } catch (UserBannedException $e) { $this->validator->add('UserBannedException', $e->getMessage()); } return false; }
/** * Logs out the current user * * @author Steve Montambeault * @link http://stevemo.ca * * @return \Illuminate\Http\RedirectResponse */ public function getLogout() { $this->users->logout(); return Redirect::route('cpanel.login')->with('success', Lang::get('cpanel::users.logout')); }