Mailing List Archive

[interchange] Add "promote_admin" option, to be used with "scratch". The option is set to the value of a
commit a8195b200c20927a34a8f38cfadd5496a78e32d6
Author: Mike Heins <mikeh@endpoint.com>
Date: Sun Jan 22 21:39:26 2017 -0500

Add "promote_admin" option, to be used with "scratch". The option is set to the value of a
field name, which also has to be a "scratch" value. If that is true, and the value of the
field is true, the user will be promoted to $Vend::admin. They will not be $Vend::super.
Note that this does not gain access to the classic Interchange UI without modification,
since the login_table will not be admin (the test which is used in most cases).

WHATSNEW-5.11 | 6 ++++++
lib/Vend/UserDB.pm | 24 +++++++++++++++++++++++-
2 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/WHATSNEW-5.11 b/WHATSNEW-5.11
index 8097817..ade81fe 100644
--- a/WHATSNEW-5.11
+++ b/WHATSNEW-5.11
@@ -84,3 +84,9 @@ UserDB
to the primary key (by default, username). This could allow users to login with email
(indirect_login = usernick), but still support login via username if they opted to use their
username instead.
+
+* Add "promote_admin" option, to be used with "scratch". The option is set to the value of a
+ field name, which also has to be a "scratch" value. If that is true, and the value of the
+ field is true, the user will be promoted to $Vend::admin. They will not be $Vend::super.
+ Note that this does not gain access to the classic Interchange UI without modification,
+ since the login_table will not be admin (the test which is used in most cases).
diff --git a/lib/Vend/UserDB.pm b/lib/Vend/UserDB.pm
index 7554f6e..3015e85 100644
--- a/lib/Vend/UserDB.pm
+++ b/lib/Vend/UserDB.pm
@@ -1091,6 +1091,25 @@ sub get_values {
$v ||= $k;
$scratch{$k} = $v;
}
+ #
+ ## $self->{ADMIN} comes when promote_admin option is set to a field,
+ ## and that field is set in both scratch and the database.
+ ## For instance:
+ #
+ # UserDb default scratch "dealer promote_admin"
+ # UserDb default promote_admin promote_admin
+ #
+ # If the "promote_admin" field is present in the database and
+ # set to a true value, user will be made $Vend::admin. Cannot be
+ # superuser.
+ #
+ # This allows use of potential AllowGlobalAdmin and NoStrictAdmin
+ # features.
+ #
+ my $pafield;
+ if($pafield = $self->{OPTIONS}{promote_admin} and $scratch{$pafield}) {
+ $self->{ADMIN} = 1;
+ }
#::logDebug("scratch ones: " . join " ", @s);
}

@@ -1946,7 +1965,10 @@ sub login {
$Vend::login_table = $Vend::Session->{login_table} = $self->{DB_ID};
$Vend::username = $Vend::Session->{username} = $self->{USERNAME};
$Vend::Session->{logged_in} = 1;
- if ( $Vend::ReadOnlyCfg->{AdminUserDB}{$self->{PROFILE}} ) {
+
+ ## $self->{ADMIN} comes when promote_admin option is set to a field,
+ ## and that field is set in both scratch and the database.
+ if ( $self->{ADMIN} or $Vend::ReadOnlyCfg->{AdminUserDB}{$self->{PROFILE}} ) {
$Vend::admin = 1;
}


_______________________________________________
interchange-cvs mailing list
interchange-cvs@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-cvs