Coder Social home page Coder Social logo

Comments (4)

estradege avatar estradege commented on June 11, 2024

Hello, I have the same problem when I update from 2.1.1 to 3.1.1. Have you find a fix for this?

from aspnetcore.identity.mongodbcore.

alexandre-spieser avatar alexandre-spieser commented on June 11, 2024

Hi, thanks for reaching out, have you compared your project with the sample project?

Here's the link to the startup class:
https://github.com/alexandre-spieser/AspNetCore.Identity.MongoDbCore/blob/master/sample/MongoIdentitySample.Mvc/Startup.cs

            services.AddIdentityCore<ApplicationUser>()
                    .AddRoles<MongoIdentityRole>()
                    .AddMongoDbStores<ApplicationUser, MongoIdentityRole, Guid>(settings.ConnectionString, settings.DatabaseName)
                    .AddSignInManager()
                    .AddDefaultTokenProviders();

There were breaking changes in 3.1.0: https://github.com/alexandre-spieser/AspNetCore.Identity.MongoDbCore/releases/tag/3.1.0

from aspnetcore.identity.mongodbcore.

estradege avatar estradege commented on June 11, 2024

Hi, thanks for your reply.
I'm using ConfigureMongoDbIdentity :

services.ConfigureMongoDbIdentity<User, Role, ObjectId>(new MongoDbIdentityConfiguration
{
  MongoDbSettings = new MongoDbSettings
  {
      ...
  },
  IdentityOptionsAction = options =>
  {
      ...
  }
})
.AddSignInManager()
.AddDefaultTokenProviders();

Adding AddSignInManager() and AddDefaultTokenProviders() resolve the DI error but, raise a new one during the login process :
No sign-in authentication handlers are registered. Did you forget to call AddAuthentication().AddCookie("Identity.Application",...)?

Thank's for your help

from aspnetcore.identity.mongodbcore.

alexandre-spieser avatar alexandre-spieser commented on June 11, 2024

hmm that seems to be related to the auth middleware missing, are you calling AddAuthentication() ?

            services.AddIdentityCore<ApplicationUser>()
                    .AddRoles<MongoIdentityRole>()
                    .AddMongoDbStores<ApplicationUser, MongoIdentityRole, Guid>(settings.ConnectionString, settings.DatabaseName)
                    .AddSignInManager()
                    .AddDefaultTokenProviders();

will not handle authentication for you, referring to the sample startup class I linked, on line 44 you'll find

            services.AddAuthentication(o =>
           {
               o.DefaultScheme = IdentityConstants.ApplicationScheme;
               o.DefaultSignInScheme = IdentityConstants.ExternalScheme;
           })
           .AddIdentityCookies(o => { });

and later on

            services.ConfigureApplicationCookie(options =>
            {
                // Cookie settings
                options.Cookie.HttpOnly = true;
                options.ExpireTimeSpan = TimeSpan.FromMinutes(5);

                options.LoginPath = "/Account/Login";
                options.SlidingExpiration = true;
            });

Please compare https://github.com/alexandre-spieser/AspNetCore.Identity.MongoDbCore/blob/master/sample/MongoIdentitySample.Mvc/Startup.cs with your setup.

from aspnetcore.identity.mongodbcore.

Related Issues (20)

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.