GithubHelp home page GithubHelp logo

aspnetidentitysample's Introduction

AspnetIdentitySample

Running this sample

Following are the features of ASP.NET Identity in this sample

  • Initialize ASP.NET Identity You can initialize ASP.NET Identity when the application starts. Since ASP.NET Identity is Entity Framework based in this sample, you can create DatabaseInitializer which is configured to get called each time the app starts. Please look in Global.asax and App_Start\IdentityConfig.cs This code shows the following
    • Create user
    • Create user with password
    • Create Roles
    • Add Users to Roles
  • Add profile data for the user Please follow this tutorial.
  • Display profile data for the user Click Profile view profile info for the logged in user. For the code look in HomeController.cs Profile Action
  • Customize Table Name for AspNetUsers If you want to change the default table name for the Users table, then you can do so by overriding the default mapping of the EF Code First types to table names. Look in Models\AppModel.cs on how we override the table name in ModelCreating event of DbContext For more info on override ModelCreating please visit
  • Register a user, Login Click Register and see the code in AccountController.cs and Register Action. Click Login and see the code in AccountController.cs and Login Action.
  • Basic Role Management Do Create, Update, List and Delete Roles. Only Users In Role Admin can access this page. This uses the [Authorize] on the controller.
  • Basic User Management Do Create, Update, List and Delete Users. Assign a Role to a User. Only Users In Role Admin can access this page. This uses the [Authorize] on the controller.
  • Associating ToDoes with User This example shows how you can create a ToDo application where you can associate ToDoes with a User. Following are the salient features of this sample.
    • Create ToDo model and associate User in EF Code First. Goto Models\AppModel.cs
    • Only Authenticated Users can Create ToDo
    • When you create/list ToDo, we can filter by User. Look at ToDoController
    • Only Users in Role Admin can see all ToDoes. Look at ToDoController and All action.
    • v1.0.0-RTM ----------- Following are the features in this project. https://github.com/rustd/AspnetIdentitySample/commit/776680f37657affff109a1107c90cde4963d2eb2 has the list of changes as well the code to change to migrate from v1.0-RC1 to v1.0-RTM - Initialize ASP.NET in App_Start by creating an Admin user and add the user to Admin Role - Basic Role Management which is restricted to Users in Admin Roles Only. Admin can create, update, delete (remove all users from this role) roles and view the details of the role (Users in this role). You can look at the RolesAdmin Controller - Basic User Management which is restricted to Users in Admin Roles Only. Admin can create user (add a user to role as well), edit user details(such as profile data and modify the roles for the user). You can look at the UsersAdmin Controller

      V1.0.0-RC1

      Following are the features in this project. https://github.com/rustd/AspnetIdentitySample/commit/3738ae8a36bf8ad568e4593c6cd3174e6af6ed41 has the list of changes

      • Initialize ASP.NET in App_Start by creating an Admin user and add the user to Admin Role
      • Basic Role Management which is restricted to Users in Admin Roles Only. Admin can create, update, delete (remove all users from this role) roles and view the details of the role (Users in this role). You can look at the RolesAdmin Controller
      • Basic User Management which is restricted to Users in Admin Roles Only. Admin can create user (add a user to role as well), edit user details(such as profile data and modify the roles for the user). You can look at the UsersAdmin Controller

      V1.0.0-Beta1

      Following are the steps to customize profile. Note once you do this then Basic User and Role Management will not work

      • Open the solution
      • Build and run
      • Regsiter a user ---- Notice that the user registration field only has user name and password
      • Let's ask for a birthdate option from the user while registering an account.
      • Goto Nuget Package Manager console and run "Enable-Migrations"
      • Goto Models\AppModel.cs and uncomment BirthDate property in the MyUser class
      • Goto Models\AccountViewModels.cs and uncomment BirthDate property in RegisterViewModel
      • Goto AccountController and in Register Action and have the following code var user = new MyUser() { UserName = model.UserName,BirthDate=model.BirthDate }; //var user = new MyUser() { UserName = model.UserName };
      • Goto Views\Account\Register.cshtml and uncomment the html markup to add a BirthDate column
      • Goto Nuget Package Manager console and run "Add-Migration BirthDate"
      • Goto Nuget Package Manager console and run "Update-Database"
      • Run the application
      • When you register a user then you can enter BirthDate as well

aspnetidentitysample's People

Contributors

rustd avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.