I have been reading tutorial articles for a few days now, and most of the tutorials show either how to create login with IdentityUser class and Facebook, Google etc.(but no additional user data) or how to create user with their details without authentication.
My goal is to create application where a user can:
Login with Facebook(done)
Add personal data after that
Link personal data with the User entry in the default database that is created from ASP.NET
My question is:
Should I write a standalone controller and link it to the created user and how it is done?
Or should I add the additional data to ApplicationUser class?
I will be happy if someone share a good resource on that topic.
A standalone class linked to the Application user should be the best solution.
You should create a table with the structure: USERID, DATA1,DATA2....
Related
Dear every good fellows in this forum
Currently I am creating a site where there shalld be a sign up page - not to created every user but only to approve them.
I havent seen any samples on "disable" user in MVC identity but now from the previus "asp.net" membership that there was a possibiliy to make a "approve" user etc.
I am thinking of making a signup page that has now relation to the users in and then after make a function that transfer data to te user table.
Is this the right approach?
If any information is need please let me know.
Happy coding
Best regards
Casper KVolle.
I would recommend that you set up roles, and limit and grant functionality by roles. You can assign roles in code or by manually manipulating the database. Roles are part of aspnet identity and the database tables that support it.
You can apply the authorize with role parameters as such on your controller and actions
[Authorize(Roles="Client, Adminstrator")]
public ActionResult ChangePrice(int ProductID, int price)
{
return View();
}
How would I go about hardcoding a role in ASP.NET MVC within the program itself, rather than through a database, for authentication (and then how could I add people to this role)?
What I'm trying to do is have 3 roles: Progammer, DatabaseAdministrator, and SystemsAdministrator. I'd like to be able to add people to those roles (also hardcoded), and then authenticate people based on role, rather than username. Right now, I am authenticating people like this:
If (#User.Identity.Name == "DOMAIN\\first.m.last")
What I want to be able to do is:
If (#User.Identity.Role == "ROLENAME")
However, I only have three roles and 8 people; I do not want to have to create a table in my database for them. So I'd create the role DatabaseAdministrator, and then add three people into as the string "DOMAIN\first.m.last". Then, I could have the action populate the view based on their rolename.
Everything I've seen so far has you do it through the database. Would appreciate any help. Thanks!
I am assuming that you are using Windows Authentication.
With that said you can easily authorize based on the users Active Directory Groups. This will keep you out of the database and all you have to do is add a user to an AD group if the users change.
Then you can authorize on the controller or action with this annotation.
[Authorize(Roles = #"DOMAIN\ADGroup")]
I have created a new asp.net MVC-5 web application , and I define individual user accounts as the authentication type.
Now when users register a new account they can enter email and password. Now I want to extend the users information when registering their account as follow:-
First name
Last name
Data of birth
Country
City
Address
Etc…
Now I am not sure what is the recommended way to extend the user info. Now I am trying to do the following 2 steps, as when the project was created a new database has been created automatically and it has a table named “ASPNETUSers”, which store the users info.
So I am thinking of adding the additional fields inside this table.
Then to modiy the “Account >> Register” view to render the additional fields.
So can anyone advice if my above 2 steps to store additional info about the users upon registration is valid ?or I should not modify the built-in database tables which include the ASPNETUSers ??
I work with alfresco 5.0.d
I want some users (who have a particular role) can create other user.
I don't want to add these users to the Administrators group.
I realize that the user can enter to create page (http://localhost:9090/share/page/console/admin-console/users) only if he is admin.
So how can I authorize a user with a particular role to enter the user management page? and create , delete or modify user ?
thank you
There are multiple ways of doing this,One way is too manipulation of permissions.But that will become more difficult.Instead of that do below things.
1.Create a webscript and pass required parameter for creating user.From that webscript create a user.
2.Create one dashlet or page in alfresco share and call the webscript, pass userName as parameter(along with the data of new user) and validate that user inside webscript(for identifying that user have access to create user or not).
Above approach is less secure.But if you don't have issue of confidentiality than you can go with that.If confidentiality is an issue.Than you need to find something which validates your user.Like creating another webscript which validates user.
It's my first contact with MVC so please be understanding for me. First of all:
1) If I will implement custom Membership provider with sql database, with my methods to activate user via e-mail, putting user into database etc. (and just one table - tableUsers), this solution about oAuth and Facebook login will works properly? Honestly, it's not clear for me at all.
2) What solution is better. My custom membership provider, or using default?
I want to sending my custom activation e-mail, then activate account. Later, I want to add new columns into userProfile table - "ID type" and "isActivated". I will storage additional info about user in separate table (telephone, webiste, about me, hobby etc) - I will get this data by IDuser from userProfile. What is more, I want to use loggin method via Facebook or Twitter. I found solution on asp.net website, how to do it with Oauth.
What solution I have to choose?
Regards
What solution is better. My custom membership provider, or using default?
As you want to store extra user information in the database, you will need to create your own custom Membership Provider as the default one lacks this flexibility. Also with the default membership Provider , you will not be able to verify your user with an activation email. You will have to customize it.
How to do it with Oauth.?
The default Membership Provider provided with MVC4 in VS 2012 has the ability to do login using Facebook and Twitter and you can add even more like LinkedIn. But, as you will need to create Custom Membership provider for storing additional information, you can use DotNetOpenAuth library for this. It is the same used by the default Membership Provider. You can add it through Nuget.