Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default role to permit less restrictive #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions authMgrPlus/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,10 @@ function amp_have_capability( $capability ) {
$user = YOURLS_USER !== false ? YOURLS_USER : NULL;
$user_caps = array();
foreach ( $amp_role_capabilities as $rolename => $rolecaps ) {
if ( amp_user_has_role( $user, $rolename ) ) {
$user_caps = array_merge( $user_caps, $rolecaps );
}
if ( amp_user_has_role( $user, $rolename ) ) {
$amp_role_assigned = True;
$user_caps = array_merge( $user_caps, $rolecaps );
}
}
$user_caps = array_unique( $user_caps );
// Is the requested capability in this list?
Expand All @@ -287,11 +288,11 @@ function amp_have_capability( $capability ) {
break;
}
}
if( !$return ) {
if ( isset( $amp_default_role ) && in_array ($amp_default_role, array_keys( $amp_role_capabilities ) ) ) {
$default_caps = $amp_role_capabilities [ $amp_default_role ];
$return = in_array( $capability, $default_caps );
}
if( !$amp_role_assigned ) {
if ( isset( $amp_default_role ) && in_array ($amp_default_role, array_keys( $amp_role_capabilities ) ) ) {
$default_caps = $amp_role_capabilities [ $amp_default_role ];
$return = in_array( $capability, $default_caps );
}
}
return $return;
}
Expand Down Expand Up @@ -486,7 +487,7 @@ function amp_env_check() {
yourls_add_action( 'activated_authMgrPlus/plugin.php', 'amp_activated' );
function amp_activated() {
global $ydb;

$table = YOURLS_DB_TABLE_URL;
$sql = "DESCRIBE `".$table."`";
$results = $ydb->fetchObjects($sql);
Expand Down