Coder Social home page Coder Social logo

identityauthservice's Introduction

IdentityAuthService

IdentityAuthService is a .NET 8 Web API Application that utilizes MSSQL Server as its underlying database.

Setup Instructions

To configure IdentityAuthService for use with IdentityUser, follow these steps:

  1. Install the required NuGet packages:

    • IdentityAuthService.DbContext
    • IdentityAuthService.Services
    • Microsoft.AspNetCore.Identity
    • Microsoft.EntityFrameworkCore
  2. Uncomment the following code snippet in Startup.cs to add the IdentityUser service to the project:

services.AddDbContext<ApplicationDbContext>(options =>
    options.UseSqlServer(Configuration.GetValue<string>("ConnectionStrings:DefaultConnection")));

services.AddIdentity<IdentityUser, IdentityRole>(options =>
    {
        options.User.RequireUniqueEmail = false;
    })
    .AddEntityFrameworkStores<ApplicationDbContext>()
    .AddDefaultTokenProviders();
  1. Then utilize Microsoft.AspNetCore.Identity.UserManager to retrieve data from the identity database.
  2. DbContext is also provided for managing IdentityUser.

User.cs

  • Consists of the following properties. These fields will be usable for other operations. The password will not be stored in the database. string UserFirstName string UserLastName string UserEmailAddress string UserPhoneNumber string UserAddress bool IsMigrated

The isMigrated field tracks whether the user has been migrated from the database or not.

AuthController.cs

The AuthController includes login and signup actions, both annotated with AllowAnonymous and HttpPost.

  • Login: Expects string SignInName and string Password parameters to validate the user login process.
  • SignUp: Expects string SignInName, string FirstName, string LastName, and string PhoneNumber parameters. The password is stored in Azure AD B2C only. Essential user data is added to the custom database for other operations.

AuthService.cs

The AuthService manages essential user data for other operations. Since users are migrated, updates to the Identity User table are unnecessary.

  • UserLoginValidation: Checks user availability in the database. If the user is available but not marked as migrated, it updates the user as migrated and returns userDetails, roles, and needToMigrate (set to 'local') fields with a 200 OK status. If the user is available but already marked as migrated, it returns roles and needToMigrate (set to null) fields with a 200 OK status.
  • UserSignUpValidation: Checks user availability in the database. If the user is available, it returns true. Otherwise, it adds essential user details to the User database and returns false.

identityauthservice's People

Contributors

stanislous avatar shehan-dubliw avatar

Stargazers

Nguyen Viet Manh avatar

Watchers

 avatar

Forkers

gtechsltn

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.