Implementing a dynamic security rule function that works with custom claims? [closed] - google-cloud-firestore

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 15 days ago.
Improve this question
I am trying to implement a security rules function that will work with custom claims. depending on the custom claim case it will return a chunk that represent the security rules for the current related case at hand that will represent the state that user is currently in current code looks like this.
// fn arg
// request.resource.data
// request.auth.token.userPlan
function userPlanChecker(requestData, userPlan) {
return (
// max 25 related clients
(userPlan== 'basic' && requestData.clients.size() <= 25) ||
(userPlan== 'pro' && requestData.clients.size() <= 50) ||
(userPlan== 'ultimate' && requestData.clients.size() <= 75)
)
}
the idea is to use custom claim case name to return the current limit on the array size, thus allow more control over limitation of how many clients a user could have. ?

Related

How to elegantly initialize a Scala service from a database? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I've been away from Scala for a while, so I'm trying to get back into the idioms. I have three database calls:
db.getInventory(inventoryId: UUID): Future[Option[Inventory]]
db.getInventoryFields(inventoryId: UUID): Future[Seq[InventoryField]]
db.allInputs: Future[Seq[Input]]
If db.getInventory is Some(inventory), I want to initialize my service by giving it a
CacheContext(inventory: Inventory, fields: Seq[InventoryField], inputs: Seq[Input])
but if it's None, I want to report and error and return.
What is the best combination of for/map/flatMap/fold etc to use here?
This will return a Future[Option[CacheContext]].
for {
optInv <- db.getInventory(theUuid)
invFlds <- db.getInventoryFields(theUuid)
inputs <- db.allInputs
} yield optInv.map(CacheContext(_,invFlds,inputs))
Unpacking the Future (i.e. waiting) should be done much later in the code (if ever), at which point you can .fold() over the Option and report the error.

How to store an array in session in Perl [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I am using Mojolicious Perl framework in my application. I want to store an array in session, but is not successful.
my #returnResult;
$returnResult['fn'] = $decoded->{'fn'};
$returnResult['ln'] = $decoded->{'ln'};
$self->session(returnResult => #returnResult);
Please help.
See hashes in Modern Perl and perldata.
my %return_result;
$returnResult{fn} = $decoded->{fn};
$returnResult{ln} = $decoded->{ln};
or
my %return_result = (
fn => $decoded->{fn},
ln => $decoded->{ln},
);
or simply
# http://perldoc.perl.org/perl5200delta.html#New-slice-syntax
my %return_result = %$decoded{qw(fn ln)};
You do not get automatic references like in other languages. Use the \ operator.
$self->session(returnResult => \%return_result);

web2py form with DB check [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I'm using web2py forms, but I need to set up a limit for 20 users registration. How can I do it?
PS: Edit to make easy to understand
Thanks in advance.
Best regards!
Assuming you wish to limit registration to a maximum of 20 users and you are using the standard /default/user function from the scaffolding application:
In the default.py controller:
def user():
if request.args(0) == 'register' and db.auth_user.count() >= 20:
form = None
else:
form = auth()
return dict(form=form)
In the default/user.html view:
{{if form is None:}}
<p>Sorry, no more registrations allowed.</p>
{{else:}}
{{=form}}
{{pass}}

Please anyone be so kind help! Matlab [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have this data of year, month, date. I want this to show as year,month,date in Matlab and don't know how to do.
X=(2014,01,02 2014,01,03 2014,01,07 2014,01,08 2014,01,09 2014,01,10 2014,01,13
2014,01,14 2014,01,15 2014,01,16 2014,01,17 2014,01,20 2014,01,21 2014,01,22
2014,01,23 2014,01,24 2014,01,27 2014,01,28 2014,01,29 2014,01,30 2014,01,31
2014,02,03 2014,02,04 2014,02,05 2014,02,06 2014,02,07 2014,02,10 2014,02,11
2014,02,12 2014,02,13 2014,02,14 2014,02,17 2014,02,18 2014,02,19 2014,02,20
2014,02,21 2014,02,24 2014,02,25 2014,02,26 2014,02,27 2014,02,28 2014,03,03)
The simplest way would be to reshape the matrix and use it accordingly. I demonstrate the way to reshape and print all the dates in US (MM/DD/YYYY) format.
X=[2014,01,02 2014,01,03 2014,01,07 2014,01,08 2014,01,09 2014,01,10 2014,01,13 2014,01,14 2014,01,15 2014,01,16 2014,01,17 2014,01,20 2014,01,21 2014,01,22 2014,01,23 2014,01,24 2014,01,27 2014,01,28 2014,01,29 2014,01,30 2014,01,31 2014,02,03 2014,02,04 2014,02,05 2014,02,06 2014,02,07 2014,02,10 2014,02,11 2014,02,12 2014,02,13 2014,02,14 2014,02,17 2014,02,18 2014,02,19 2014,02,20 2014,02,21 2014,02,24 2014,02,25 2014,02,26 2014,02,27 2014,02,28 2014,03,03];
X_in_better_format = reshape(X,3,42)';
for it = 1:size(X_in_better_format,1)
sprintf('The date is %d/%d/%d',X_in_better_format(it,2),X_in_better_format(it,3),X_in_better_format(it,1)) %US Format
end

How do I create a Lookup table in Powershell? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a list of servernames
PARDC1 EURDC2 EURDC3 USADC1 USADC22 CHNDC1 CHNDC2
I have created a hashtable to pick the first 3 letters of servernames, and classify it in a region.
PAR = EMEA
EUR = EMEA
USA = NAM
CHN = APAC
I want to use the lookup table to classify all servers in appropriate regions.
How do I go about doing this in Powershell ?
You can create an empty hash table with
$hash = #{}
You can then add entries to it with
$hash['foo'] = $bar
or
$hash.foo = $bar
and access them the same way later again.