Retrieve User ID using WinJS - windows-8

I have an app that performs a calculation, and I need to store this results in a database via webservice. I need to store this results with some user identification, in a table structure like this:
user_id| test_result
The problem I have is that I don't know how to obtain the "user_id". Is there an API that simply retrieves the store username/e-mail? If there's not, What's the simplest approach?
Thank you in advance.

There is a class in WinRT that will give you the users name (domain name and display name):
Take a look at
Windows.System.UserProfile.UserInformation
Or you could use a third party authentication, like a Facebook login. There's an app sample for that at http://code.msdn.microsoft.com/windowsapps/Web-Authentication-d0485122

Related

Is there a way to register routes after the application is started?

I want to have app which has some default route and controller (Let's say Login page). I can register this at the Configure method but after the user successfully logs in I want to fetch the pages related to the user and register them so he can have access to it. Is there a way to achieve that?
As long as I read that's impossible but who knows, I'm new to ASP NET Core?
Based on the wording, this sounds like a security question. You only want users to have access to certain pages. If that's the case then I would look at something like role-based authorization.
If the question is more about showing the user a list of resources they can access, then the most obvious solution I can think of is to store that information in a relational database. When the user logs in, select the relevant pages / resources by user ID.
In any case, changing the registered routes is not the correct approach.

Advice on implementing secure page with a list returned from REST API

I'm new to Piranha CMS and just trying to get my head around it. I'm using the MVC implementation and I need to do the following:
I need to extend the User with a property that stores an account number.
I need a page that is only accessible once the user logs in
On this page, I need to call a REST API on another server, using the account number a parameter, to retrieve a list of documents that the user has stored on this server.
When the user clicks the document, it will be downloaded as a PDF using the REST API once again
I just need general guidance on how to do this. How do I store the account number against the user (and manage this) and do I need to create a new Region that will show the list of documents from the remote server. Is there an example of creating a new Region anywhere and maybe returning a list from SQL that I can adapt?
Any help gratefully received.
Thanks in advance
Mike
The easiest way is to implement an extension with your custom fields that you attach to the user where you store this information.
When editing a page, go in under "settings" and select which groups should have access to your page. For this purpose I suggest creating a new group for site users that are not admins.
This should be easily implemented in either the controller or model for your page. When the user is logged in "User.Identity.Name" is the user id. Get the user, load the extensions & use the account number.
See number three.
Regards

How to get user access in Hybris?

I would like to know how I can get users login Access information and their login frequency from Hybris db. Is it possible to know the table/s where this kind of data is stored?
Thanks in advance,
AC
The only available information would be the last login date, if you want to keep more information about the login frequency, you will need to :
Update the User or Employee model to add something like a collection of Date
Customize the 'CockpitAuthenticationProvider' class to populate your new attribute whenever a cockpit user successfully login
Adding to #Benoit answer, you can write your custom logic in StorefrontAuthenticationSuccessHandler & LoginAuthenticationFailureHandler (based on success or failure) to save newly added attributes in User/Employee model.

Receiving data using GET with a RESTful API

I'm building an API. When requesting the data of a user this is shown to be the best practice to retrieve the data:
Requests user data with ID:
https://api.example.com/users/1
However it would be more convenient to requests user data with their email:
https://api.example.com/users/johnsmith#outlook.com
Is it safe to use the second method? Even if I was to use the first method, there is no way that a developer would know the ID for the user which they would like to request, so it would not be useful at all.
So is the second method safe? If not, is there a solution? Thanks.
As long as the ID is unique and parsable in the URI. The '#' would need to be encoded into a "%40". Other than that its fine, IMHO. If you have two different types of identifiers, like email and ID then you might want to allow a client to select which identifier to use
https://api.example.com/users?email=johnsmith#outlook.com
or
https://api.example.com/users?id=1
Here is some good literature for how to use filters in REST API's.
Passing email address in URL is not a good idea as it is non-public information. If you really need to go with email address then go with POST call or you can use id which is completely safe if you are using proper authorization at API end.

How to save user data in an iPhone login type app

Im developing an iPhone app with user logging design and i am trying to understand how to save user data and app state for each user in the same iPhone.
For example suppose my app flow is as follow:
1. user log in.
2. app gets the user friends list from core date and present it.
3. in the background the app fetch the user friend list from a server and update core data.
Now suppose there are two users that simultaneity uses the app with the same iPhone
how can i know witch data to load from core data to each user? haw can i know witch app state to return to?
First of all, it seems important to pose the question of why you are trying to do this in the first place. As I'm sure you have noticed, Apple designed the iPhone to be a single user device. This is why you don't see their apps (and generally apps from 3rd parties as well) allowing multiple users.
That said, if you are absolutely sure you want to do this, then you clearly need to give the user some ability to change user accounts. You're never going to know when one person is using the phone over another, so you have to provide the ability to switch users similarly to how fast user switching works in OS X.
Anyway, you probably need to start by creating an additional Core Data entity called "User". That entity should contain information about each user (name, nickname, photo, etc). Then you need to create a relationship from the "User" entity to whatever entities you are using to store your friends list.
You'll need to decide what the behavior of the app will be. Will the current user automatically be logged out when the app quits? Hard to say as you don't know who is going to use the app next.
I would create a core data entity for users and link the entries in it with the friend list entries. Therefore every user should have a unique identifier. Also in your friendlist entity there should be a key like "userId" to hold the reference to the user.