summaryrefslogtreecommitdiffstats
path: root/lib/private/user
diff options
context:
space:
mode:
authorThomas Müller <DeepDiver1975@users.noreply.github.com>2016-05-03 15:22:41 +0200
committerThomas Müller <DeepDiver1975@users.noreply.github.com>2016-05-03 15:22:41 +0200
commit4b2544925f7f51d7e5cb1329166451f4fbd9e6bf (patch)
treece9a58e2532ec0301dc7e0c266f8256eb79826f9 /lib/private/user
parentdf2eb96cc40893f60a1b63abbe585c448e0a6d9f (diff)
parent661ab1a8c51ec251c44f76c7d58484ff14003336 (diff)
downloadnextcloud-server-4b2544925f7f51d7e5cb1329166451f4fbd9e6bf.tar.gz
nextcloud-server-4b2544925f7f51d7e5cb1329166451f4fbd9e6bf.zip
Merge pull request #23844 from owncloud/disable-user
Add occ commands to enable and disable a user + a disabled user can n…
Diffstat (limited to 'lib/private/user')
-rw-r--r--lib/private/user/session.php46
-rw-r--r--lib/private/user/user.php1
2 files changed, 25 insertions, 22 deletions
diff --git a/lib/private/user/session.php b/lib/private/user/session.php
index 5402c5cf74f..c7f8a6920de 100644
--- a/lib/private/user/session.php
+++ b/lib/private/user/session.php
@@ -32,6 +32,8 @@
namespace OC\User;
use OC\Hooks\Emitter;
+use OCP\ISession;
+use OCP\IUserManager;
use OCP\IUserSession;
/**
@@ -53,26 +55,20 @@ use OCP\IUserSession;
* @package OC\User
*/
class Session implements IUserSession, Emitter {
- /**
- * @var \OC\User\Manager $manager
- */
+ /** @var \OC\User\Manager $manager */
private $manager;
- /**
- * @var \OC\Session\Session $session
- */
+ /** @var \OC\Session\Session $session */
private $session;
- /**
- * @var \OC\User\User $activeUser
- */
+ /** @var \OC\User\User $activeUser */
protected $activeUser;
/**
- * @param \OCP\IUserManager $manager
- * @param \OCP\ISession $session
+ * @param IUserManager $manager
+ * @param ISession $session
*/
- public function __construct(\OCP\IUserManager $manager, \OCP\ISession $session) {
+ public function __construct(IUserManager $manager, ISession $session) {
$this->manager = $manager;
$this->session = $session;
}
@@ -107,7 +103,7 @@ class Session implements IUserSession, Emitter {
/**
* get the session object
*
- * @return \OCP\ISession
+ * @return ISession
*/
public function getSession() {
return $this->session;
@@ -116,10 +112,10 @@ class Session implements IUserSession, Emitter {
/**
* set the session object
*
- * @param \OCP\ISession $session
+ * @param ISession $session
*/
- public function setSession(\OCP\ISession $session) {
- if ($this->session instanceof \OCP\ISession) {
+ public function setSession(ISession $session) {
+ if ($this->session instanceof ISession) {
$this->session->close();
}
$this->session = $session;
@@ -170,7 +166,12 @@ class Session implements IUserSession, Emitter {
* @return bool if logged in
*/
public function isLoggedIn() {
- return $this->getUser() !== null;
+ $user = $this->getUser();
+ if (is_null($user)) {
+ return false;
+ }
+
+ return $user->isEnabled();
}
/**
@@ -226,15 +227,18 @@ class Session implements IUserSession, Emitter {
if ($this->isLoggedIn()) {
return true;
} else {
- throw new LoginException('Login canceled by app');
+ // injecting l10n does not work - there is a circular dependency between session and \OCP\L10N\IFactory
+ $message = \OC::$server->getL10N('lib')->t('Login canceled by app');
+ throw new LoginException($message);
}
} else {
- return false;
+ // injecting l10n does not work - there is a circular dependency between session and \OCP\L10N\IFactory
+ $message = \OC::$server->getL10N('lib')->t('User disabled');
+ throw new LoginException($message);
}
}
- } else {
- return false;
}
+ return false;
}
/**
diff --git a/lib/private/user/user.php b/lib/private/user/user.php
index 3199790dba0..36680436769 100644
--- a/lib/private/user/user.php
+++ b/lib/private/user/user.php
@@ -417,5 +417,4 @@ class User implements IUser {
$this->emitter->emit('\OC\User', 'changeUser', array($this, $feature, $value));
}
}
-
}