aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/user/session.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/user/session.php')
-rw-r--r--lib/private/user/session.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/private/user/session.php b/lib/private/user/session.php
index 9c9bee3da25..c2885d00413 100644
--- a/lib/private/user/session.php
+++ b/lib/private/user/session.php
@@ -113,6 +113,38 @@ class Session implements Emitter, \OCP\IUserSession {
}
/**
+ * set the login name
+ *
+ * @param string login name for the logged in user
+ */
+ public function setLoginname($loginname) {
+ if (is_null($loginname)) {
+ $this->session->remove('loginname');
+ } else {
+ $this->session->set('loginname', $loginname);
+ }
+ }
+
+ /**
+ * get the login name of the current user
+ *
+ * @return string
+ */
+ public function getLoginname() {
+ if ($this->activeUser) {
+ return $this->session->get('loginname');
+ } else {
+ $uid = $this->session->get('user_id');
+ if ($uid) {
+ $this->activeUser = $this->manager->get($uid);
+ return $this->session->get('loginname');
+ } else {
+ return null;
+ }
+ }
+ }
+
+ /**
* try to login with the provided credentials
*
* @param string $uid
@@ -126,6 +158,7 @@ class Session implements Emitter, \OCP\IUserSession {
if (!is_null($user)) {
if ($user->isEnabled()) {
$this->setUser($user);
+ $this->setLoginname($uid);
$this->manager->emit('\OC\User', 'postLogin', array($user, $password));
return true;
} else {
@@ -143,6 +176,7 @@ class Session implements Emitter, \OCP\IUserSession {
public function logout() {
$this->manager->emit('\OC\User', 'logout');
$this->setUser(null);
+ $this->setLoginname(null);
$this->unsetMagicInCookie();
}