Merge pull request #1479 from nextcloud/stable10-backport-1188
[stable10] redirect to default app after solving the 2FA challenge
This commit is contained in:
commit
3102afacd2
|
@ -24,6 +24,8 @@
|
|||
namespace OC\Core\Controller;
|
||||
|
||||
use OC\Authentication\TwoFactorAuth\Manager;
|
||||
use OC_User;
|
||||
use OC_Util;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\RedirectResponse;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
|
@ -67,7 +69,7 @@ class TwoFactorChallengeController extends Controller {
|
|||
* @return string
|
||||
*/
|
||||
protected function getLogoutAttribute() {
|
||||
return \OC_User::getLogoutAttribute();
|
||||
return OC_User::getLogoutAttribute();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -143,7 +145,7 @@ class TwoFactorChallengeController extends Controller {
|
|||
if (!is_null($redirect_url)) {
|
||||
return new RedirectResponse($this->urlGenerator->getAbsoluteURL(urldecode($redirect_url)));
|
||||
}
|
||||
return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index'));
|
||||
return new RedirectResponse(OC_Util::getDefaultPageUrl());
|
||||
}
|
||||
|
||||
$this->session->set('two_factor_auth_error', true);
|
||||
|
|
|
@ -39,13 +39,13 @@ class TwoFactorChallengeControllerTest extends TestCase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->request = $this->getMock('\OCP\IRequest');
|
||||
$this->request = $this->getMockBuilder('\OCP\IRequest')->getMock();
|
||||
$this->twoFactorManager = $this->getMockBuilder('\OC\Authentication\TwoFactorAuth\Manager')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->userSession = $this->getMock('\OCP\IUserSession');
|
||||
$this->session = $this->getMock('\OCP\ISession');
|
||||
$this->urlGenerator = $this->getMock('\OCP\IURLGenerator');
|
||||
$this->userSession = $this->getMockBuilder('\OCP\IUserSession')->getMock();
|
||||
$this->session = $this->getMockBuilder('\OCP\ISession')->getMock();
|
||||
$this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')->getMock();
|
||||
|
||||
$this->controller = $this->getMockBuilder('OC\Core\Controller\TwoFactorChallengeController')
|
||||
->setConstructorArgs([
|
||||
|
@ -64,7 +64,7 @@ class TwoFactorChallengeControllerTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testSelectChallenge() {
|
||||
$user = $this->getMock('\OCP\IUser');
|
||||
$user = $this->getMockBuilder('\OCP\IUser')->getMock();
|
||||
$providers = [
|
||||
'prov1',
|
||||
'prov2',
|
||||
|
@ -88,7 +88,7 @@ class TwoFactorChallengeControllerTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testShowChallenge() {
|
||||
$user = $this->getMock('\OCP\IUser');
|
||||
$user = $this->getMockBuilder('\OCP\IUser')->getMock();
|
||||
$provider = $this->getMockBuilder('\OCP\Authentication\TwoFactorAuth\IProvider')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
@ -130,7 +130,7 @@ class TwoFactorChallengeControllerTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testShowInvalidChallenge() {
|
||||
$user = $this->getMock('\OCP\IUser');
|
||||
$user = $this->getMockBuilder('\OCP\IUser')->getMock();
|
||||
|
||||
$this->userSession->expects($this->once())
|
||||
->method('getUser')
|
||||
|
@ -150,7 +150,7 @@ class TwoFactorChallengeControllerTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testSolveChallenge() {
|
||||
$user = $this->getMock('\OCP\IUser');
|
||||
$user = $this->getMockBuilder('\OCP\IUser')->getMock();
|
||||
$provider = $this->getMockBuilder('\OCP\Authentication\TwoFactorAuth\IProvider')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
@ -167,17 +167,13 @@ class TwoFactorChallengeControllerTest extends TestCase {
|
|||
->method('verifyChallenge')
|
||||
->with('myprovider', $user, 'token')
|
||||
->will($this->returnValue(true));
|
||||
$this->urlGenerator->expects($this->once())
|
||||
->method('linkToRoute')
|
||||
->with('files.view.index')
|
||||
->will($this->returnValue('files/index/url'));
|
||||
|
||||
$expected = new \OCP\AppFramework\Http\RedirectResponse('files/index/url');
|
||||
$expected = new \OCP\AppFramework\Http\RedirectResponse(\OC_Util::getDefaultPageUrl());
|
||||
$this->assertEquals($expected, $this->controller->solveChallenge('myprovider', 'token'));
|
||||
}
|
||||
|
||||
public function testSolveChallengeInvalidProvider() {
|
||||
$user = $this->getMock('\OCP\IUser');
|
||||
$user = $this->getMockBuilder('\OCP\IUser')->getMock();
|
||||
|
||||
$this->userSession->expects($this->once())
|
||||
->method('getUser')
|
||||
|
@ -197,7 +193,7 @@ class TwoFactorChallengeControllerTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testSolveInvalidChallenge() {
|
||||
$user = $this->getMock('\OCP\IUser');
|
||||
$user = $this->getMockBuilder('\OCP\IUser')->getMock();
|
||||
$provider = $this->getMockBuilder('\OCP\Authentication\TwoFactorAuth\IProvider')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
|
Loading…
Reference in New Issue