rebuild merchant select to get colors and init_map

This commit is contained in:
Rainer Gümpelein 2022-01-04 11:49:13 +01:00
parent 0184300a35
commit 1b0ba8f010
8 changed files with 112 additions and 119 deletions

View file

@ -49,6 +49,68 @@ my $lang="de";
my $owner=188;#via API
my $dbh = "";
#fetch merchant_id by request or hostname
sub fetch_merchant {
my $self = shift;
my $varenv = shift;
my $req_sessionid = shift || "";
my $req_authcookie = shift || "";
my $req_merchant_id = shift || "";
my $response = { init_map => {
center => { latitude => "", longitude => "" },
radius => ""
}
};
my $merchanized = 0;
my $aowner = 0;
my $merchant_id = "";
while ((my $merchant_conf, my $value) = each %{ $dbt->{merchant_ids}}) {
if($merchant_conf && (($req_sessionid && $req_sessionid =~ /$merchant_conf$/) || ($req_authcookie && $req_authcookie =~ /$merchant_conf$/) || ($req_merchant_id && $req_merchant_id eq $merchant_conf))){
$aowner = $value->{id};
$merchant_id = $merchant_conf;
$merchanized = 1;
my $lat = "";
my $lng = "";
$value->{initMap} =~ s/\s//g;
($lat,$lng) = split(/,/,$value->{initMap}) if($value->{initMap} && $value->{initMap} =~ /\d+,\d+/);
if($lat && $lng){
$response->{init_map}->{center}->{latitude} = $lat;
$response->{init_map}->{center}->{longitude} = $lng;
$response->{init_map}->{radius} = "2.9";
}
$bw->log("merchant select by session-cookie OR authcookie OR merchant_id: if($merchant_conf && (($req_sessionid && $req_sessionid =~ /$merchant_conf$/) || ($req_authcookie && $req_authcookie =~ /$merchant_conf$/) || ($req_merchant_id && $req_merchant_id eq $merchant_conf))){",$merchant_conf,"");
last;
}
}
if(!$merchanized){
if($varenv->{syshost} eq "shareeapp-primary" || $varenv->{syshost} eq "shareedms-primary"){
$aowner = $dbt->{primary}->{sharee_primary}->{owner};
$merchant_id = $dbt->{primary}->{sharee_primary}->{merchant_id};
$merchanized = 1;
$bw->log("merchant select by primary dbname: sharee_primary:",$merchant_id,"");
}
elsif($varenv->{syshost} =~ /shareeapp-(\w+)/ || $varenv->{syshost} =~ /shareedms-(\w+)/){
$aowner = $dbt->{operator}->{$varenv->{dbname}}->{owner};
$merchant_id = $dbt->{operator}->{$varenv->{dbname}}->{merchant_id};
$merchanized = 1;
$bw->log("merchant select by operator dbname=$varenv->{dbname}:",$merchant_id,"");
}
elsif($varenv->{syshost} =~ /shareeweb-/){
$aowner = $dbt->{website}->{$varenv->{syshost}}->{owner};
$merchant_id = $dbt->{website}->{$varenv->{syshost}}->{merchant_id};
$merchanized = 1;
$bw->log("merchant select by website syshost=$varenv->{syshost}:",$merchant_id,"");
}
}
return ($aowner,$merchant_id,$response);
}
#helper to get template
sub get_node_meta {
my $self = shift;
@ -2127,9 +2189,8 @@ sub auth_verify(){
}else{
$bw->log("auth_verified on operator anchor FAILS by dbname $varenv{dbname}, no authcookie, dump \$q",$q,"");
}
my $agb_checked = 0;
$agb_checked = 1 if($record->{int14});#sharee AGB global
$return->{agb_checked} = "$agb_checked";
$return->{agb_checked} = "0";
$return->{agb_checked} = "1" if($record->{int14});#sharee AGB global
my $last_used_operator = $record->{txt19};#check if this is primary and/or useable
$bw->log("last_used_operator selected by txt19:",$last_used_operator,"");
@ -2295,8 +2356,6 @@ sub authcookie_manager {
new_authcoo => "0",
user_id => "$record->{txt08}",
};
$return = { %$return, debuglevel => "$record->{int11}" } if($record->{int11});
$return = { %$return, Ilockit_admin => "$record->{int19}" } if($record->{int19});
#return new generated authcookie
}else{
@ -2340,12 +2399,15 @@ sub authcookie_manager {
user_id => "$record->{txt08}",
};
$return = { %$return, debuglevel => "$record->{int11}" } if($record->{int11});
$return = { %$return, Ilockit_admin => "$record->{int19}" } if($record->{int19});
}
}
}
$return->{debuglevel} = "$record->{int11}" if($record->{int11});
$return->{Ilockit_admin} = "$record->{int19}" if($record->{int19});
$return->{agb_checked} = "0";
$return->{agb_checked} = "1" if($record->{int14});#sharee AGB global
return $return;
}