Skip to content
Snippets Groups Projects
Commit 8eda6617 authored by Robin Appelman's avatar Robin Appelman
Browse files

Throw an exception when login is canceled by an app

parent 8a9acc50
No related branches found
No related tags found
No related merge requests found
......@@ -844,7 +844,9 @@ class OC {
protected static function handleLogin() {
OC_App::loadApps(array('prelogin'));
$error = array();
$messages = [];
try {
// auth possible via apache module?
if (OC::tryApacheAuth()) {
$error[] = 'apacheauthfailed';
......@@ -855,8 +857,11 @@ class OC {
elseif (OC::tryFormLogin()) {
$error[] = 'invalidpassword';
}
} catch (\OC\User\LoginException $e) {
$messages[] = $e->getMessage();
}
OC_Util::displayLoginPage(array_unique($error));
OC_Util::displayLoginPage(array_unique($error), $messages);
}
/**
......
<?php
/**
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace OC\User;
class LoginException extends \Exception {
}
......@@ -189,6 +189,7 @@ class Session implements IUserSession, Emitter {
* @param string $uid
* @param string $password
* @return boolean|null
* @throws LoginException
*/
public function login($uid, $password) {
$this->manager->emit('\OC\User', 'preLogin', array($uid, $password));
......@@ -199,7 +200,11 @@ class Session implements IUserSession, Emitter {
$this->setUser($user);
$this->setLoginName($uid);
$this->manager->emit('\OC\User', 'postLogin', array($user, $password));
return $this->isLoggedIn();
if ($this->isLoggedIn()) {
return true;
} else {
throw new LoginException('Login canceled by app');
}
} else {
return false;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment