I plan to create an firebase tree solution to make possible to some operator link a person to some data before that person has an account.
So, when that person create its account, it will be possible to find that data. I was thinking about create some tree like this:
- Before_Signup_Link_User
- $user_email
- OperatorONE: true
- OperatorTWO: true
After signup and with its email informed on Firebase, the user would get the operator ID to find data on another path.
The problem is that Firebase does no let us put email as child. Do you have some ideia to do that.
Maybe you can use space char instead of dot char.
For Example:
- user#mail com
- OperatorONE: true
- OperatorTWO: true
a basic solution.. :)
From what I understand, Firebase doesn't allow some special characters (its indicated on their old docs, but I believe its still a valid rule on the new version)
A child node's key cannot be longer than 768 bytes, nor deeper than 32 levels. It can include any unicode characters except for . $ # [ ] / and ASCII control characters 0-31 and 127.
So if you want to use the email as child, you'll have to provide its proper unicode value
Related
UserCollection/{id}/PlayerCollection/{id}
In the last document, there are number of fields
active: true or false
dateInMillies : 123456789
return _firestore
.collection('UserCollection')
.document(userID)
.collection("PlayerCollection")
.orderBy('dateInMillis', descending: true)
.where('active', isEqualTo: true)
.snapshots();
this block of code through an exception:
failed: Status{code=FAILED_PRECONDITION, description=The query requires an index. You can create it here: link to fix it
but the link is broken, so i must do it manually!
so, i went to indexes tab, and created a new composite index
collectionID : PlayerCollection
Fields Indexed: dateInMillis : Descending , active : Ascending
but also didn`t work!
I have an alternative answer.
Make sure when you open the link that you don't include any random characters at the end. I opened the link from vscode's terminal, and it actually had three links that were available to open, but two of them had a trailing comma, which opened a white screen in the Firebase console.
The problem is solved D:
I contacted Firebase support about the broken URL and here is the solution:
It seems that you might have another account linked on your browser.
Probably gmail, if that is the case, please verify that your current
session corresponds with the selected project, or simply try logout /
login with the account that owns the project. You can also try it from
an incognito window
And the generated link solved my issue.
In my case,
I found that the fields indexed should be exactly the same in the query, no more, no less.
If you want to make a new query with different fields (but still in the same collection), you can create new composite indexing with the same collection name.
I hope this will solve the problem.
I'm using TravelItineraryReadRQ to get information about Price Quotes in pnr. In some cases service response hides number sequences with ("XXXX") even if it was not credit card information. For example:
PQ creation commatnd: WPASU‡EDUFS123456‡FINVOICE*QUW12345‡RQ«
and here is what I get in response:
<tir39:PricedItinerary DisplayOnly="false" InputMessage="WPASU¥EDUFS1XXXX6¥FINVOICE*QUW1XXX5¥RQ" RPH="1" StatusCode="A" StoredDateTime="2018-12-21T09:13" TaxExempt="false" ValidatingCarrier="SU">
<tir39:AirItineraryPricingInfo>
<tir39:ItinTotalFare>
<tir39:BaseFare Amount="1980" CurrencyCode="RUB"/>
<tir39:Taxes>
<tir39:Tax Amount="2541" TaxCode="XT"/>
<tir39:TaxBreakdownCode TaxPaid="false">2265YQ</tir39:TaxBreakdownCode>
<tir39:TaxBreakdownCode TaxPaid="false">276RI</tir39:TaxBreakdownCode>
</tir39:Taxes>
<tir39:TotalFare Amount="4521" CurrencyCode="RUB"/>
<tir39:Totals>
<tir39:BaseFare Amount="1980"/>
<tir39:Taxes>
<tir39:Tax Amount="2541"/>
</tir39:Taxes>
<tir39:TotalFare Amount="4521"/>
</tir39:Totals>
</tir39:ItinTotalFare>
<tir39:PassengerTypeQuantity Code="ADT" Quantity="01"/>
<tir39:PTC_FareBreakdown>
<tir39:Endorsements>
<tir39:Endorsement type="PRICING_PARAMETER">
<tir39:Text>WPASU$EDUFS1XXXX6$FINVOICE*QUW1XXX5$RQ</tir39:Text>
</tir39:Endorsement>
Is there any way to get those numbers?
I believe Sabre has logic on their end due to GDPR requirements that masks credit card info from being viewed unless you have the CC in the correct form of payment field AND your EPR has the "CCVIEW" attribute assigned.
Essentially, Sabre doesn't want CC data stored anywhere but the secured Form of Payment field and they control who can and cannot see that data by using the EPR Keywords (the login info you get from Sabre).
So, for your example, my guess is that Sabre's regex or whatever they use to identify credit card data sees your strings in those fields, assumes they are CC numbers, and masks them. You may want to open a ticket with Sabre to address this, or as Andy K suggested above, try adding CCVIEW to that EPR (although I think that probably won't work).
I want to have the same WordPress users in two different databases
For example, if a user registers on SiteA, then he can login to SiteB. And reverse.
Also i want create same cookie for both after login.
mywebsite.com/ (SiteA_DB)
mywebsite.com/blog/ (SiteB_DB)
I've never done this before and maybe Wordpress has hooks to archive this, but I prefer using mysql for such a trick.
You could try ..
.. using 'federated storage' ( https://stackoverflow.com/a/24532395/10362812 )This is my favorite, because you don't even have to share a database or even the mysql serverThe downside is, that it doesn't work with db cache and uses an additional connection.
.. creating a 'view' ( https://stackoverflow.com/a/1890165/10362812 )This should be possible when using the database-name in the query itself and it would be the simplest solution if it works. Downside: The 2 tables have to share the same mysql-server and have to be assigned to the same user as far as I know.
-- **Backup your database before trying!** --
DROP TABLE `second_database`.`wp_users`;
DROP TABLE `second_database`.`wp_usermeta`;
CREATE VIEW `second_database`.`wp_users` AS SELECT * FROM `first_database`.`wp_users`;
CREATE VIEW `second_database`.`wp_usermeta` AS SELECT * FROM `first_database`.`wp_usermeta`;
This should work, according to: Creating view across different databases
.. creating a 'shadow copy' ( https://stackoverflow.com/a/1890166/10362812 )Works with caching and is a standalone tableDownsides as 2. solution + a bit of setup and I think it might be the worst option in performance
This were answers to this question: How do I create a table alias in MySQL
I merged them together for you and made them fit your use-case.
Please also notice, that solution 1 and 2 will replace your current user-tables auf "second_database" because you write directly into "first_database" when querying the fed. storage or the view. This can lead to problems with user-role plugins. You should take care of syncing the plugin-options too, if you should use one of them and in case it uses different tables or 'wp_options' values.
Let me know if this works, I have to do a similar task next week. While researching I found the linked answers.
EDIT: I was missing the point of "cookie-sharing" in my answer. Your example shows a blog on the same domain - you should be able to change the way wordpress sets its cookies to be domain-wide. What I did once for 2 different domains was, that I hooked into the backend (is_admin) and added a javascript which did a post-request to siteB, receiving a token which is stored but marked as 'invalid' on siteB. This token then was passed back to my plugin on siteA which checked if the user is logged_in and (in my case) have adminrights (current_user_can()) and if so, it was sending this token back to sideB which was marking this token as valid to login. (Make sure only sideA can tell sideB to make this token valid!) Once a user is seen with this token in a cookie on siteB, the user is logged-in automatically in the background. Also I made this bidirectional. I am sorry, that I can't share the code for you. I don't have access to it anymore.
Greetings, Eric!
I need to implement role based authorization in my app before we launch for production. I have a function that checks whether the user is accessing data from only their company. I need to also make sure that a user with the role "SuperUser", "Tester", or "Manager" can also access the data even though they aren't part of the company. I've looked at other role based implementations but they don't seem to address this scenario of having to check either the company or the role.
I have the rule that has the OR statement here:
allow read: if exists(/databases/$(database)/documents/companies/$(company)/users/$(request.auth.uid))
|| hasRole(['SuperUser', 'Manager', 'Tester']);
And I have this as the function for hasRoles:
function hasRole(roles) {
return get("/databases/$(database)/documents/companies/Seva Development/users/$(request.auth.uid)").data.roles.hasAny(roles);
}
When I add this function the user is denied access, even when the left side of the OR statement is true. I can only assume something is wrong with the function, but I've been unable to find where from firebase documentation.
The document I'm trying to access looks like this:
How can I modify this function to allow me to check if the user is part of our organization and has one of the specified roles?
This works if you have the role but aren't part of the company:
allow read: if isUserCompany(company)
|| hasRole(['SuperUser', 'Manager', 'Tester']);
But it will fail if you are part of the company and don't have the role. What I can't figure out, is that this works if you are part of the company but don't have the role:
allow read: if isUserCompany(company)
So the left side works, the right side works. But they don't work together.
It also works if I write:
allow read: if isUserCompany(company) || false;
Which makes me assume the problem must be with the hasRole function if the role doesn't exist. I tried writing a function to check for the role first, but it still failed.
The problem is that you're passing a string to get() instead of a path. Note the reference documentation for get() says the argument is a Path. According to the docs for Path:
Paths can be created in two ways. The first is in the "raw" form
beginning with a forward slash /:
/path/to/resource
The second is by converting from a string using the path() function:
path("path/to/resource")
If you want to compose a string to become a path (because you have a space in there somewhere), you'll have to use the path() function. Or, you can use the bind() function to insert the values that have spaces in them. Using path():
function hasRole(roles) {
return get(path("databases/" + database + "/documents/companies/Seva Development/users/" + request.auth.uid)).data.roles.hasAny(roles);
}
Note that the leading slash is missing from the string form of the path, and all variables need to be added by concatenation.
Or you can just remove the space from "Seva Development" and just use the raw form of the path.
I want to customize the standard drill-down functionality and add a text parameter to the drill-down URL. I will then parse and use the parameter in the SysStartUpCmdDrillDown or EventDrillDownPoller class like the solution provided by Jan B. Kjeldsen in this question.
The standard drill-down link is dynamics://Target/?DrillDown_RecID/ :
dynamics://0/?DrillDown_5637230378/
In previous versions of AX it was possible to modify the RecId to custom text and parse the text once the client is started:
dynamics://0/?DrillDown_0MenuItemName=PurchTable&FieldName=PurchId&FieldValue=P000044
Unfortunately, in AX 2012 the RecId is checked before the client is started and if it is not a valid int64, the drill-down event is not sent to the client. Since it is not possible to change the RecId to anything other than an integer, #Alex Kwitny suggested in the comments at that same question that you can add the custom text to the drill-down target like this:
dynamics://0MenuItemName=PurchTable/?DrillDown_5637230378/
The problem I experience with this is that the link now gets confused about which instance to start.
If the target is equal to the value in the System Admin -> system parameters -> Alerts ->Drill-down target, a client with the correct server instance is started. When I append the text with my custom text, it always starts the default instance(Which could be different from the instance I intended to start). While this is not ideal, I could work around this issue.
The bigger problem is that it now always starts a new session of the default instance, even if a client session is already started. As far as I can see I cannot write X++ code to solve this issue since the server instance is determined before any code in the client is executed.
My question is this - How can I add custom text to the drill-down link while preserving the way the client instance is started: If a client for the instance is already open, it should process the link in the open client, and not start up a new client of the default instance.
You should probably come up with another solution as mentioned in this post, but there could still be a way.
The URL has two objects that can be modified:
dynamics://[Drill-down target(str)]/?Drilldown_[Int64]
According to you, if you modify the [Drill-down target], then it launches AX using the default client config, and that is behavior that you don't want. If you have a matching [Drill-down target], it'll launch in the open client window, which is behavior I can't confirm, but I'll take it at face value and assume you're correct.
So that means the only thing you can modify in the URL is [int64]. This is actually a string that is converted to an int64 via str2int64(...), which in turn corresponds to a RecId. This is where it gets interesting.
This work all happens in \Classes\SysStartUpCmdDrillDown\infoRun.
Well, lucky for you the ranges for the objects are:
RecId - 0 to 9223372036854775807
Int64 - -9223372036854775808 to 9223372036854775807
You can call minRecId() and maxRecId() to confirm this.
So this means you have -9223372036854775808 to -1 numbers to work with by calling URLs in this range:
dynamics://0/?DrillDown_-1
to
dynamics://0/?DrillDown_-9223372036854775808
Then you would modify \Classes\SysStartUpCmdDrillDown\infoRun to look for negative numbers, and fork to your custom code.
HOW you decide to user these negative #'s is up to you. You can have the first n-digits be a table id or a look-up value for a custom table. You can't technically use a RecId as part of that negative number because in theory the RecId could get up that high (minus 1).