Check 2FA state for raw php files too

This commit is contained in:
Christoph Wurst 2016-06-10 09:52:52 +02:00
parent e8a66f8e7d
commit 7b3dc806eb
No known key found for this signature in database
GPG key ID: FEECD2543CA6EAF0
2 changed files with 8 additions and 1 deletions

View file

@ -64,7 +64,9 @@ class OC_JSON{
* @deprecated Use annotation based ACLs from the AppFramework instead
*/
public static function checkLoggedIn() {
if( !OC_User::isLoggedIn()) {
$twoFactorAuthManger = \OC::$server->getTwoFactorAuthManager();
if( !OC_User::isLoggedIn()
|| $twoFactorAuthManger->needsSecondFactor()) {
$l = \OC::$server->getL10N('lib');
http_response_code(\OCP\AppFramework\Http::STATUS_UNAUTHORIZED);
self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' )));

View file

@ -970,6 +970,11 @@ class OC_Util {
);
exit();
}
// Redirect to index page if 2FA challenge was not solved yet
if (\OC::$server->getTwoFactorAuthManager()->needsSecondFactor()) {
header('Location: ' . \OCP\Util::linkToAbsolute('', 'index.php'));
exit();
}
}
/**