summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-04-07 15:39:34 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2016-05-02 09:31:22 +0200
commit9c9fec36dd469494738b57c691338cbe71926c10 (patch)
treed02f7bfec8ced060c1df1740e1dfadb3b7f10a37 /lib
parenta323111bd1285f74aa405c240be86b5de5d0c502 (diff)
downloadnextcloud-server-9c9fec36dd469494738b57c691338cbe71926c10.tar.gz
nextcloud-server-9c9fec36dd469494738b57c691338cbe71926c10.zip
Add occ commands to enable and disable a user + a disabled user can no longer login - fixes #23838
Diffstat (limited to 'lib')
-rw-r--r--lib/private/legacy/user.php14
-rw-r--r--lib/private/user/session.php46
-rw-r--r--lib/private/user/user.php1
-rw-r--r--lib/public/iuser.php1
4 files changed, 32 insertions, 30 deletions
diff --git a/lib/private/legacy/user.php b/lib/private/legacy/user.php
index 11c35daa0de..34ce68e989f 100644
--- a/lib/private/legacy/user.php
+++ b/lib/private/legacy/user.php
@@ -63,8 +63,6 @@ class OC_User {
return OC::$server->getUserSession();
}
- private static $_backends = array();
-
private static $_usedBackends = array();
private static $_setupedBackends = array();
@@ -105,7 +103,7 @@ class OC_User {
break;
default:
\OCP\Util::writeLog('core', 'Adding default user backend ' . $backend . '.', \OCP\Util::DEBUG);
- $className = 'OC_USER_' . strToUpper($backend);
+ $className = 'OC_USER_' . strtoupper($backend);
self::$_usedBackends[$backend] = new $className();
\OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]);
break;
@@ -175,6 +173,7 @@ class OC_User {
/**
* Try to login a user using the magic cookie (remember login)
*
+ * @deprecated use \OCP\IUserSession::loginWithCookie()
* @param string $uid The username of the user to log in
* @param string $token
* @return bool
@@ -241,6 +240,8 @@ class OC_User {
/**
* Sets user id for session and triggers emit
+ *
+ * @param string $uid
*/
public static function setUserId($uid) {
$userSession = \OC::$server->getUserSession();
@@ -296,14 +297,11 @@ class OC_User {
/**
* Check if the user is logged in, considers also the HTTP basic credentials
*
+ * @deprecated use \OC::$server->getUserSession()->isLoggedIn()
* @return bool
*/
public static function isLoggedIn() {
- if (\OC::$server->getSession()->get('user_id') !== null && self::$incognitoMode === false) {
- return self::userExists(\OC::$server->getSession()->get('user_id'));
- }
-
- return false;
+ return \OC::$server->getUserSession()->isLoggedIn();
}
/**
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));
}
}
-
}
diff --git a/lib/public/iuser.php b/lib/public/iuser.php
index b0dd8dc35b2..16617a2f2f6 100644
--- a/lib/public/iuser.php
+++ b/lib/public/iuser.php
@@ -32,6 +32,7 @@ namespace OCP;
* @since 8.0.0
*/
interface IUser {
+
/**
* get the user id
*