Use Identity in an Asp.Net MVC 5 application with Web Api and vice versa

2

When I create a project Asp.Net MVC with Individual User Accounts I can enter the application in this way:

var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);

But I need to make login access to mobile applications as follows:

link: http://localhost:51836/token  
header: content-type: application/x-www-form-urlencoded  
body: [email protected]&password=123456&grant_type=password  

How can I continue to login in this way and also make Web Api available (in the same project Asp.Net MVC ) so that mobile devices log in and receive% access% to be able to access the Token pages I have in application Web Api ?

    
asked by anonymous 10.09.2014 / 14:53

1 answer

1

I would make an Action (anonymous) part for the mobile app login.

So in this action I would look up the user and then call the code you posted.

Exit?

Create an Action I controller that can be accessed without authenticating

In this action, search the user, and if successful call

var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);

After that the rest of the application does not have to worry about where the user came from

    
16.09.2014 / 23:46