GithubHelp home page GithubHelp logo

aspnet-identity-2-extensible-project-template's Introduction

AspNet Identity 2.0 Extensible Project Template

This project expands upon the work done by the ASP.NET Identity Team in the Identity Samples project. The goal is to provide a basic project template wherein the core identity Model classes are easily extensible without messing about with the generic type arguments.

While extending the basic ApplicationUser class provided in the original Identity Samples project was always relatively straightforward, Extending the Role implementation required some significant work.

In this project, you can simply add additional properties and/or methods to any of the Identity Model classes as defined in the IdentityModels.cs file.

For more information, see:

The code in this repo is for a project where the Identity models use string keys. If you prefer integer keys (and database PK fields) see this repo instead:

AspNet Identity 2.0 Extensible Project Template (integer keys)

There is a lot of good information here about how things work under the hood with the generic types, even if you don;t plan to use the integer keys:

Please feel free to open issues, report bugs, and/or shoot me a pull request if you see potential fixes/improvements.

aspnet-identity-2-extensible-project-template's People

Contributors

xivsolutions avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aspnet-identity-2-extensible-project-template's Issues

each line of above Register method that exist 'RoleManager' word I'm getting compile time error as below

   // POST: /Account/Register
    [HttpPost]
    [AllowAnonymous]
    [ValidateAntiForgeryToken]
    public async Task<ActionResult> Register(RegisterViewModel model, HttpPostedFileBase upload, params string[] selectedRoles)
    {

        try
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser { UserName = model.UserName, Email = model.Email };                      


                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    //Add User to the selected Roles 
                    if (selectedRoles != null)
                    {
                        var addroles = await UserManager.AddToRolesAsync(user.Id, selectedRoles);
                        if (!addroles.Succeeded)
                        {
                            ModelState.AddModelError("", result.Errors.First());
                            ViewBag.RoleId = new SelectList(await RoleManager.Roles.ToListAsync("Name", "Name"));
                            return View();
                        }
                    }

                }

                else
                {
                    ModelState.AddModelError("", result.Errors.First());
                    ViewBag.RoleId = new SelectList(RoleManager.Roles, "Name", "Name");
                    return View();
                }

                return RedirectToAction("Index");
                // AddErrors(result);
            }

        }

        // If we got this far, something failed, redisplay form
        catch (RetryLimitExceededException /* dex */)
        {
            //Log the error (uncomment dex variable name and add a line here to write a log.
            ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
        }

        ViewBag.RoleId = new SelectList(RoleManager.Roles, "Name", "Name");

        return View(model);
    }

Using the generic type 'RoleManager' requires 2 type arguments

which means I'm getting 3 compile time errors in above method.

ApplicationUser must be convertible to microsoft.aspnet.identity.framework.identityuser inorder to use it as parameter TUser

Thank you so much for the template. I am not very experienced program however manage to use the template. I am trying to import users information from an old project using SqlMembership, I need to use SQLPasswordHasher which I got from this example: http://www.asp.net/identity/overview/migrations/migrating-an-existing-website-from-sql-membership-to-aspnet-identity.

I am trying to add UserManger:
public MyUserManager ()
: base(new UserStore(new ApplicationDbContext()))
{
this.PasswordHasher = new SQLPasswordHasher();
}
I get the above error.
When I change the public class ApplicationUser : IdentityUser I don't get this error

I would appreciate your suggestions.

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.