Perform logic in ACS

Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
This commit is contained in:
Lukas Reschke 2017-08-04 16:55:01 +02:00
parent bc98b466bd
commit 5a4d327c0a
No known key found for this signature in database
GPG key ID: B9F6980CF6E759B1
3 changed files with 10 additions and 7 deletions

View file

@ -31,6 +31,7 @@ use OCP\ILogger;
use OCP\IRequest;
use OCP\ISession;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
@ -212,6 +213,15 @@ class SAMLController extends Controller {
return new Http\RedirectResponse($this->urlGenerator->linkToRouteAbsolute('user_saml.SAML.notProvisioned'));
}
try {
$user = $this->userManager->get($this->userBackend->getCurrentUserId());
if(!($user instanceof IUser)) {
throw new \InvalidArgumentException('User is not valid');
}
$user->updateLastLoginTimestamp();
} catch (\Exception $e) {
return new Http\RedirectResponse($this->urlGenerator->linkToRouteAbsolute('user_saml.SAML.notProvisioned'));
}
$this->session->set('user_saml.samlUserData', $auth->getAttributes());
$this->session->set('user_saml.samlNameId', $auth->getNameId());
$this->session->set('user_saml.samlSessionIndex', $auth->getSessionIndex());

View file

@ -447,7 +447,6 @@ class UserBackend implements IApacheBackend, UserInterface, IUserBackend {
}
if ($user !== null) {
$user->updateLastLoginTimestamp();
$currentEmail = (string)$user->getEMailAddress();
if ($newEmail !== null
&& $currentEmail !== $newEmail) {

View file

@ -93,9 +93,6 @@ class UserBackendTest extends TestCase {
->method('get')
->with('ExistingUser')
->willReturn($user);
$user
->expects($this->once())
->method('updateLastLoginTimestamp');
$user
->expects($this->once())
->method('getEMailAddress')
@ -143,9 +140,6 @@ class UserBackendTest extends TestCase {
->method('get')
->with('ExistingUser')
->willReturn($user);
$user
->expects($this->once())
->method('updateLastLoginTimestamp');
$user
->expects($this->once())
->method('getEMailAddress')