store a field calculated with Javascript on a hidden field in the Auth0 Lock - auth0

I'm using Auth0 lock and would like to store a calculated field with JS during the signup. So far I've added a hidden field like:
additionalSignUpFields: [{
type: "hidden",
name: "myField",
value: "abc123"
}],
During the sign up I change the value of the field using JavaScript, and I can see the value has changed in the HTML. However, the value stored is always abc123. Is there a way to achieve what I want?

Related

GA4 ecommerce items Array do not show up in debug mode

GA4 ecommerce items Array do not show up in debug mode
i am using the GTM, i am sure i passed the Array for items (using Datalayer or CJS), but GA4 does not recognized it , what i see is missing the items tab in debug mode, i don't know how that could be show up , am i doing something wrong? anyone has the same experience?
Looks like the event name is incorrect here -> View_Items.
Make sure that the event name exactly matches view_item
(stylized as snake_case).
As GA4 only allows ecommerce data collection with a set of pre-defined
event names.
Update :
I saw this checkbox is being checked
As you already set the value currency items in the event parameter. You can uncheck this setting.
I think you can follow Google's document about it
view_item_details
items: [
{
item_id: "SKU_12345",
item_name: "Stan and Friends Tee",
affiliation: "Google Merchandise Store",
coupon: "SUMMER_FUN",
currency: "USD",
discount: 2.22,
index: 0,
item_brand: "Google",
item_category: "Apparel",
item_category2: "Adult",
item_category3: "Shirts",
item_category4: "Crew",
item_category5: "Short sleeve",
item_list_id: "related_products",
item_list_name: "Related Products",
item_variant: "green",
location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
price: 9.99,
quantity: 1
}
]
Make items array only contain 1 item
Google has a list of recommended events suggesting that the items are automatically collected. If your custom event name doesn't match the listed event, GA4 won't take the items data.
Note that even though you can use the GTM preview mode to check whether the data is correctly constructed, the shown data won't necessarily send to GA4.
The reason is that GTM only forwards the requested data instead of sending it to GA4 directly. To see this behavior, you may have a look at the dev tool such as Chrome dev tool. You can examine the forwarded request's payload in the network tab (search /collect.*/). If it's the recommended event, in payload, there's pr1, pr2, etc., representing your items' array data; otherwise, you'll see nothing, and thus the data won't show up in the GA4 debugging mode.
Do you use the same GTM data layer which initially track for GA Universal events ? If yes, then this may be the cause why the items array did not show on debug view since I found this issue also.
The solution is to create the new GTM Container, and name the data layer differently like 'datalayer2' to differentiate those data layers and set up your config again with 'datalayer2'
for instance, datalayer2.push(
{
event : view_promotion
....}

Different JSON object value when logging the object and logging only specific field

I have a problem on accessing JSON Object on Javascript, especially React Native with Redux.
I want to access the value of some specific key within the object.
Here is the JSON object when I print it using console.log
{
"username": "user_name_of_user",
"name": "name_of_user",
"idVerified": false,
"emailVerified": true,
"phoneVerified": false,
"blocked": false,
"active": true
}
In particular, I want to access the emailVerified value.
I've been trying
user.emailVerified, user['emailVerified']
without luck,
I even try to do
console.log('user', user)
console.log('verification access using key', user['emailVerified'])
console.log('verification access using .', user.emailVerified)
strange enough, the first line, show the emailVerified, inside json content to be true but the others show as false
I have to try to search on Search Engine but didn't seem to find a similar problem, but maybe the keyword that I use is not correct too.
Have anyone find this strange behavior? Maybe some hint on how it was possible to happen and the solution?
By the way, this is react-native application, and the data is provided using redux.
EDIT 1:
a full response in a successive call as I write above
EDIT 2:
I call the data in successive as shown on the image
EDIT 3:
as per Pety Ialimijoro Rakotoniaina suggestion, I try to switch the console.log order, as shown on the Image, with no luck
EDIT 4:
OK, it seems something is wrong with the console.log itself, I try to show the content using the following code
and got these as the result
as you can see, the console.table(user), show different result as console.log('user', user), and console.table(user) is align with console.log('verification access using key', user['emailVerified']) and
console.log('verification access using .', user.emailVerified)
so I suspect that the result on console.log('user', user) might be the content from other item on the list,
OK, it seems something is wrong with the console.log itself, I try to show the content using the following code
and got these as the result
as you can see, the console.table(user), show different result than console.log('user', user), and console.table(user) is align with console.log('verification access using key', user['emailVerified']) and console.log('verification access using .', user.emailVerified)
so I suspect that the result on console.log('user', user) might be the content from other item on the list,
EDIT 1:
when I see the image result again, I see that the result to the right of user on third line, which is start with {name:"", is different than values below it, name, which is I censor, has a value, where the value above that on third line, show name: "". So maybe it was the Browser Cache that is to blame :p

Sapui5 autocomplete input

I'm developing an app with a login and I need use an autocomplete input. In HTML is easy to develop it, but I don't know how to implement.
I find a solution where set data to the input, but in my case, I can't do it.
Example:
First Time: Log with the name: "Name1"
Second Time: Log with the name: "Name2"
Third Time: When the user write "N", the input must show "Name1", "Name2"
Thanks!
Please use sap.m.Input and set it's property showSuggestion to true, also bind suggestionItems as in this example.

How to prevent DataTables from displaying or hiding columns on the basis of an obsolete saved state

I have a table driven by DataTables 1.10. Filtering is turned on. When I talk about "doing a search" below, I'm talking about using the filtering function of this table.
Description of the Problem
Everything works fine with stateSave off. However, when stateSave is on, the following happens:
Alice logs in as admin. Because admin has all privileges, when she does a search through articles, she can see all articles. Because some articles are published and some are unpublished the table has a column that show which are published and which are not. So far so good.
Bob, a random user, accesses the site. Random users cannot ever see unpublished articles so the table hides the column that shows publication status. So far so good.
Alice logs out. She now accesses the site like a random user. So she should see exactly what Bob sees. However, when she does a search she still sees the column that indicates publication status.
(Note: The issue I'm discussing here is purely one of user interface. The server ensures that unprivileged users cannot ever get a record for an unpublished article. The problem though is that the additional column gives unpriviledged users information that they do not need. They can only see published articles in their search so they don't need to see that every article they get in a search is published.)
The code that configures the datatable hides the publication column by doing something like this:
var columnDefs = [];
if (!privileged) {
columnDefs.push({
targets: [1],
orderable: false,
visible: false
});
}
columnDefs is passed to DataTables as the columnDefs option.
Technical Reason for the Problem
The problem is that DataTables store things like column visibility into the state it saves into localStorage. So when Alice logs out and makes a search again as an unprivileged user, even though the value of columnDefs is correct, it is overwritten by the saved state. That state was stored when Alice was an admin, and it declared the publication column to be visible, so it remains visible even when Alice is accessing the site as an unprivileged user.
What I want is for users to benefit from the saved state but avoid having this state carry over when the user's privileges change.
Caveats:
I don't want to use sessionStorage because I want the state to persist between browser closings, but sessionStorage is cleared when the browser is closed.
I cannot use the session cookie assigned by the server to detect logins and logouts because it is HTTP only. Besides, privileges could change for other reasons.
I do not want to arbitrarily set an expiration time on the saved state.
The solution I've settled on is to use an additional field in the saved data to know when the conditions I care about have changed. This is a field whose value changes depending on the privileges that the user currently has. For instance, because in the case I described here, I decide to hide or show a column on the basis of a variable named priviledged (which is initialized from data provided by the server), it could be as simple as:
var token = privileged;
Then I set stateSaveParams to record the token when the state is saved:
stateSaveParams: function (settings, data) {
data.myapp_token = token;
}
The prefix myapp_ is just there to avoid possible collisions with DataTable's own fields.
I set stateLoadParams so that if the current value of token differs from what has been recorded before, the state is cleared:
stateLoadParams: function (settings, data) {
if (data.myapp_token !== token) {
this.api().state.clear(); // Clears the state.
return false; // Tells DataTables to not use the state that was stored.
}
// This return is here to keep the IDE happy but does not do anything special.
return undefined;
},
I've just set token to the single condition I've shown in my question (privileged) in this example but in production I use a combination of variables plus a local version number so I can bump the value of token as needed if I do something that requires clearing the state but cannot be detected just as a privilege change.

Passing variables into JavaScript in ExpressJS/PassportJS/Jade app

This is essentially a continuation of the question here: Nodejs Passport display username.
app.get('/hello', function(req, res) {
res.render('index.jade', { name: req.user.username });
});
So users log in via PassportJS, and goes to index.jade, which contains #{name} in the body, which will be replaced by the value of req.user.username.
Question: Is it possible to use the value of req.user.username in index.jade's JavaScript? I tried assigning its value to a variable but it doesn't work.
I have been using the trick of having a hidden input with #{name} as value:
input(type='hidden', id='variableName', value='#{name}')
Then JavaScript can access this value using:
$("#variableName").val()
This works. But does it have any potential downside like security issues? What is the right way to do this?
You have a few options. One of them is what you did and put the value inside you html. You can also solve it by doing:
script
window.name = #{name};
This will create an inline script that sets the variable. The other option you have is using ajax. That means you probably need to make an extra route to reply to that request.