My app is similar to facebook.
I want to retain the userID/Username upon login screen, so that i could use it at rest of the application for queries online data.
I tried storing it in a javascript object after successful login, but it gets washed away when i move to other screens.
Thanks
You can use the App.Properties API.
Example, right from the docs.
Titanium.App.Properties.setString("my_prop","cool");
if(Ti.Facebook.loggedIn) {
if(Ti.App.Properties.hasProperty('fbid')) {
var fbid = Ti.App.Properties.getString('fbid');
}
}
You can use the hasProperty to verify they have logged in in the past and when they do logout you can use the removeProperty so that your app assumes they haven't logged in and starts over.
If you are going to store the information in the properties, you should be aware that the is information persisted on the device.
The use of properties for short term storage IMHO should be avoided if possible.
You have two choices, one store your variables in the Titanium namespace
Titanium.App.credentials = { "user" :"username", "pwd":"password123"};
Or create your own namespace and store your variable there. This will ensure you values are available throughout the application, but not stored on the device.
There is an example on my blog here http://blog.clearlyinnovative.com/post/6519148138/titanium-appcelerator-quickie-global-variables-scopes
Related
I'm building a simple app where that shows product recommendations.
I want to make it possible for the client to choose how many products he'd like to display, like from 5 or 20 with a liquid variable called {{NofProducts}}
I'm using the shopify app example, there are two important pages:
pages/index.js <- here the client can write inputs
theme-app-extension/block.liquid <- here we write a liquid code that will be appended to the page.
How do I pass the inputs from index.js to the block.liquid?
Do I have to store it elsewhere in a database for each user?
Do I have to create a file using graphQL inside each theme with the user choices using "createScriptTag"?
Ok, unfortunately every Shopify tutorial is extremely confusing for beginners.
They way you pass the store owner inputs to the app is using a database, I did it using Redis, but you can use MongoDB or maybe even a local file, but that's not ideal.
You should not store the user inputs inside their theme, because each time you access or modify a file in the customer's store, you need to use their getSessionToken function and make a new request using the token, while using your database you just need to get the session ID using SESSION_STORAGE.
In my Sitefinity back-end there is a user section that I would like to add some setting. Something like DisplayLink where it would be a boolean value that I can set on Login of the user. Is there a way I can do that? I am using sf 14 and can't find anyway to add some setting for the user.
I believe this is what you need ...map the view externally and modify.
However keep in mind these views pull in the XHR JSON and you just expose it to the grid... Open your console and view the XHR network traffic to see the JSON object per user. There's a "Comment" field you might be able to leverage, but man the best way would be to just use a ROLE... because they can be filtered, and already come across in that JSON.
Another thing to note, is this is an OLD UI screen and likely will get revamped in the next few releases of Sitefinity rendering everything you're doing pointless... (have to re-do it with likely the new AdminApp Extensions)
I am developing an identity server 4 dotnet core application so this is as much as a dotnet question than and IDS4 question. One example of state I need to maintain between pages (login, signup etc...) is the returnUrl. The application I'm migrating from used to store it in a session variable but, as I understand, unless I run a persistent session strategy, this won't scale well.
So currently, I'm passing it around as a field in each View Model used by each view so it can be returned. Is this a sound approach? I'll be needing other fields to be passed around as well so I'm wondering whether this is a secure and logical way to do it.
So currently, I'm passing it around as a field in each View Model used by each view so it can be returned. Is this a sound approach?
Yes, how you choose to pass it around is up to you, I choose this same approach. You could use TempData, Sessions or even localStorage as an alternative. I think having it in the models (view models) is a good approach because you are explicitly specifying where you want the return url to exist, otherwise it might persist in context that you wouldn't want.
Now the security question because obviously you might be able to see the return url in the browser address field.
As part of Identity Server 4 setup you specify which return url's you are allowed to redirect back to, so I don't think there is any harm in having the users see the redirect url.
Something to consider is what if the user would share the url to someone else in the middle of the authentication process, would they be able to resume from that part of the process that the initial user has stopped? is this something you want in your app?
If you mean reliably instead of securely, write tests which will provide you with confidence that your code works.
I have a ReactNative app that is working with some constants,
export const BEARER_TOKEN = 'eyJhbGciOiJIU***'
The app works fine until I need to update the token so with a new version distributed by appcenter,
If I just update the app, it keeps the old token
but
If I delete and install a new version, the new token is used
So, how can I make sure that the new token gets loaded? like if the app starts reload constants?
Thanks.
I suggest using Asyncstorage and Redux state in order to maintain your Bearer_Token.
For instance, assume using the Facebook app.
You are logging in for the very first time. Capture and store your Bearer_token in Asyncstorage and also maintain in the redux state.
Next time when you kill the app and open again. Load the Bearer_Token from Asyncstorage.
Your Bearer_Token will be set dynamically.
You can't, with this approach. This is the nature of javascript, it loads everything initially and even if you change it by putting the variable in object. It is a bad practice.
The better approach is to use redux or context api,
I see you want to use BEARER_TOKEN, for user authentication probably.
So you can have a state, authUser inside your redux and it will keep track of the token in your entire app. This approach is very useful when you want the user to logout if any change in authToken.
https://redux.js.org/
For a simple version, you can use context api from react.
now the third option, If you really really really want to not use these approaches.
You can just usewindow.token = 'sdfasdf';
then whenever you want to change it, just use window.token = 'soemthing else'from other files.
I've been using Netlify for storing 100% of my app (both frontend and backend) for the last three months. So far, so good.
The only problem now is that I need to store a custom property for each user (say, the phone number), and apparently Netlify Identity doesn't support this (only email, name and roles https://www.netlify.com/docs/identity/).
I don't want to change the whole app to migrate to another hosting provider just for this detail (actually, I can't, it's for a client and I just don't have time), because it works great, but at the same time I need it.
Can you think of any workaround to this? The less "hackish", the better, but I understand that I'm going beyond the intended use of Netlify Identity.
So it actually does look like Netlify's GoTrue API has a specific endpoint for updating custom user data. After a user is created, you can update metadata by including it as "data" within an authenticated PUT request to /user.
PUT /user
{
"data" {
"custom_key": "value",
}
}
See https://github.com/netlify/gotrue for more info.
There are dozens of ways to do this, so I'll talk about two generally applicable ways now:
the most "generally capable" one is probably using lambda functions: https://www.netlify.com/docs/functions . This lets you run dynamic code, such as "store to database hosted elsewhere" or "email to our office manager to update a spreadsheet" or even "commit to our closed git repo so it's available in-code" (last one is probably a worst practice, but is possible). You can similarly use a function to read that data back out without exposing API tokens (code example: https://github.com/netlify/code-examples/tree/master/function_examples/token-hider)
you could have the data gathered via a form submission (https://www.netlify.com/docs/form-handling). I'd probably use zapier.com to receive a notification of the form submission (https://www.netlify.com/docs/form-handling/#notifications). Zapier can of course connect to just about anything on the planet :) . Getting the data back out if you want to show it in your UI is a bit more of a challenge, but you could use the above mentioned functions if you need to connect to some private data store to pull it out. Or for an MVP, just not show it, only let people enter/update it ;)