File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
app/code/Magento/Authorization/Model/Acl/Loader Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -80,12 +80,17 @@ public function __construct(
80
80
*/
81
81
public function populateAcl (\Magento \Framework \Acl $ acl )
82
82
{
83
+ $ foundResources = [];
84
+ $ foundRoles = [];
85
+
83
86
foreach ($ this ->getRulesArray () as $ rule ) {
84
87
$ role = $ rule ['role_id ' ];
85
88
$ resource = $ rule ['resource_id ' ];
86
89
$ privileges = !empty ($ rule ['privileges ' ]) ? explode (', ' , $ rule ['privileges ' ]) : null ;
87
90
88
91
if ($ acl ->has ($ resource )) {
92
+ $ foundResources [$ resource ] = $ resource ;
93
+ $ foundRoles [$ role ] = $ role ;
89
94
if ($ rule ['permission ' ] == 'allow ' ) {
90
95
if ($ resource === $ this ->_rootResource ->getId ()) {
91
96
$ acl ->allow ($ role , null , $ privileges );
@@ -96,6 +101,19 @@ public function populateAcl(\Magento\Framework\Acl $acl)
96
101
}
97
102
}
98
103
}
104
+
105
+ /**
106
+ * for all rules that were not regenerated in authorization_rule table,
107
+ * when adding a new module and without re-saving all roles,7
108
+ * consider not present rules with deny permissions
109
+ * */
110
+ foreach ($ acl ->getResources () as $ resource ) {
111
+ if (!isset ($ foundResources [$ resource ])) {
112
+ foreach ($ foundRoles as $ role ) {
113
+ $ acl ->deny ($ role , $ resource , null );
114
+ }
115
+ }
116
+ }
99
117
}
100
118
101
119
/**
You can’t perform that action at this time.
0 commit comments