Skip to content

Commit

Permalink
different message if you are in an MFA-verified session
Browse files Browse the repository at this point in the history
  • Loading branch information
michielbdejong committed Dec 30, 2023
1 parent 5c7b414 commit abacd62
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
1 change: 1 addition & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
return [
'routes' => [
['name' => 'mfazones#get', 'url' => '/get', 'verb' => 'GET'],
['name' => 'mfazones#getMfaStatus', 'url' => '/getMfaStatus', 'verb' => 'GET'],
['name' => 'mfazones#getList', 'url' => '/getList', 'verb' => 'GET'],
['name' => 'mfazones#access', 'url' => '/access', 'verb' => 'GET'],
['name' => 'mfazones#set', 'url' => '/set', 'verb' => 'POST'],
Expand Down
26 changes: 22 additions & 4 deletions js/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
var mfazoneFileListPlugin = {
attach: function(fileList) {
console.log('FILELIST>>>>>>', fileList);
// console.log('FILELIST>>>>>>', fileList);
// if (fileList.id === 'trashbin' || fileList.id === 'files.public') {
// return;
// }
Expand All @@ -18,9 +18,27 @@ var mfazoneFileListPlugin = {
permissions: OC.PERMISSION_NONE,
iconClass: 'icon-category-security',
actionHandler: function(fileName, context) {
if (confirm('You must enable two factor authentication to use MFAZone app. Do you want to enable 2FA?')) {
window.location.href = OC.generateUrl('/settings/user/security');
}
const statusUrl = OC.generateUrl('/apps/mfazones/getMfaStatus');
$.ajax({
type: 'GET',
url: statusUrl,
dataType: 'json',
async: true,
success: function (response) {
if (response.error){
console.log(response.error);
return;
}
if (response.mfa_passed !== true) {
const choice = confirm('This folder requires Multi Factor Authentication. Do you want to enable it for your account?')
if (choice) {
window.location.href = OC.generateUrl('/settings/user/security');
}
} else {
alert('You have already enabled Multi Factor Authentication for your account.');
}
}
});
},
// fileName: 'asdf',
});
Expand Down
12 changes: 12 additions & 0 deletions lib/Controller/MfazonesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@ public function hasAccess($source)
}
}

/**
* @NoAdminRequired
*/
public function getMfaStatus()
{
return new JSONResponse(
array(
'mfa_passed' => $this->isMfaVerified()
)
);
}

/**
* @NoAdminRequired
*/
Expand Down

0 comments on commit abacd62

Please sign in to comment.