diff options
author | Lukas Reschke <lukas@owncloud.com> | 2016-04-18 12:14:07 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2016-04-18 21:21:52 +0200 |
commit | 8222ad515706d62cceb14428c959b83a69ccbc8b (patch) | |
tree | 1fb2a2a86d2eaebca7e48366a7b3e50d3f3dbe7f /core/Controller | |
parent | 51975d360a93daba3b2681136a77b8d7078719e9 (diff) | |
download | nextcloud-server-8222ad515706d62cceb14428c959b83a69ccbc8b.tar.gz nextcloud-server-8222ad515706d62cceb14428c959b83a69ccbc8b.zip |
Move logout to controller
Testable code. Yay.
Diffstat (limited to 'core/Controller')
-rw-r--r-- | core/Controller/LoginController.php | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/core/Controller/LoginController.php b/core/Controller/LoginController.php index faed7e291ea..796706d364a 100644 --- a/core/Controller/LoginController.php +++ b/core/Controller/LoginController.php @@ -28,6 +28,7 @@ use OCP\AppFramework\Http\TemplateResponse; use OCP\IConfig; use OCP\IRequest; use OCP\ISession; +use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; use OCP\IUserSession; @@ -41,6 +42,8 @@ class LoginController extends Controller { private $session; /** @var IUserSession */ private $userSession; + /** @var IURLGenerator */ + private $urlGenerator; /** * @param string $appName @@ -49,18 +52,37 @@ class LoginController extends Controller { * @param IConfig $config * @param ISession $session * @param IUserSession $userSession + * @param IURLGenerator $urlGenerator */ function __construct($appName, IRequest $request, IUserManager $userManager, IConfig $config, ISession $session, - IUserSession $userSession) { + IUserSession $userSession, + IURLGenerator $urlGenerator) { parent::__construct($appName, $request); $this->userManager = $userManager; $this->config = $config; $this->session = $session; $this->userSession = $userSession; + $this->urlGenerator = $urlGenerator; + } + + /** + * @NoAdminRequired + * @UseSession + * + * @return RedirectResponse + */ + public function logout() { + $loginToken = $this->request->getCookie('oc_token'); + if (!is_null($loginToken)) { + $this->config->deleteUserValue($this->userSession->getUser()->getUID(), 'login_token', $loginToken); + } + $this->userSession->logout(); + + return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm')); } /** |