1

we have a project in multiple layer ( containing data access layer , service layer , web .... ) also we have some entity like Person , User , Customer , Employee now we are going to use asp.net identity in our website for user register and authentication now if we want to register a user in one of the layers ( not website ) how we can do it according to asp.net identity , and what about authentication ?

(my first idea is add a user to database and use PasswordHasher Class of Microsoft.AspNet.Identity to hash a password , is there a better way ? for example move asp.net identity into a new class library project or any other ways )

another thing :

i want to know how we can use another entities like Customer , Employee ... in this design ?

2 Answers 2

1

If we want to register a user in one of the layers ( not website ) how we can do it according to asp.net identity

You do not want bring ASP.Net Identity into Business Logic Layer. It should be at Presentation Layer only.

(my first idea is add a user to database and use PasswordHasher Class of Microsoft.AspNet.Identity to hash a password , is there a better way ? for example move asp.net identity into a new class library project or any other ways )

First of all, if you want to use ASP.Net Identity, you do not want to change or modify its tables.

Easiest way is let ASP.Net Identity create tables first. Then you create your tables such as Customer, Employee. If you need relationship to UserId, use AspNetUsers - Id column as Primary Key or Foreign Key in your tables.

Adam Freeman has free chapter for ASP.Net Identity here.

Other Thoughts

If you want to change a lot, you might just want to consider using just OwinContext and AuthenticationManager instead of entire Identity.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for your answer , be informed that i am trying to put it in business logic layer in order to handle user requests from website and from mobile app
I see. For that case, you want to make a common project/layer between web and mobile. Leave the Business Logic Layer by itself; the reason is BLL should not know what front end technology you use - it should still be working if someone consider using WPF or WCF later.
0

Finally I found my answer and thank you Win for your guide finally i transferred user manager objects from AccountController to a class library to use register and sign in methods in diffrent controllers and also i add Microsoft.AspNet.identity to one of my class library projects and create 2 methods for Register and authenticate to use it in webservice i used Password hasher to hash the password and checked hashed password

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.