Skip to content

Commit

Permalink
Translate login exception messages
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDiver1975 committed Apr 8, 2016
1 parent 996fc87 commit e9d6087
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions lib/private/user/session.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
namespace OC\User;

use OC\Hooks\Emitter;
use OCP\IUser;
use OCP\ISession;
use OCP\IUserManager;
use OCP\IUserSession;

/**
Expand All @@ -54,26 +55,20 @@
* @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;
}
Expand Down Expand Up @@ -108,7 +103,7 @@ public function getManager() {
/**
* get the session object
*
* @return \OCP\ISession
* @return ISession
*/
public function getSession() {
return $this->session;
Expand All @@ -117,10 +112,10 @@ public function getSession() {
/**
* 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;
Expand Down Expand Up @@ -232,15 +227,18 @@ public function login($uid, $password) {
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 {
throw new LoginException('User disabled');
// 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;
}

/**
Expand Down

0 comments on commit e9d6087

Please sign in to comment.