Skip to content

ani-6/Webapi_mvc_admin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Webapi_mvc_Admin

Standalone webapi created For Authentication and Authorization using jwt token.

Requirements

1. SqlServer 2019
2. Visual studio 2022 prefferd

Change data source in Web.config (line 12) "LAPTOP-NAIGAH36\SQLEXPRESS" with yours

Create new role

1. Start debuging
2. open postman->body->raw (Format shoould be json)
3. Method - POST Url - https://localhost:44310/api/Roleapi/createrole (Check your port once)
4. For creating admin role put
"Admin"
5. Send

6. Create "User" as well because its default registration role.

To check role created and users assgned to that role
Method - GET Url - https://localhost:44310/api/Roleapi

To add additional info while registering user

1. Goto Models->IdentityModel.cs
2. put your desired parameter in Class Applicationuser
eg public string Name { get; set; }
3. Perform migration with following commands
  • enable-migration
  • add-migration Newmigration
  • update-database
4. Add those parameter
Models->AccountBindingModels.cs->Public Class RegisterBindingModel
as well as
Controller->Accountcontroller.cs->public async Task Register(RegisterBindingModel model)

Register

1. Goto Postman
2. Method - POST Url - https://localhost:44310/api/Account/register
3. select x-www-form-urlencode
4. put all required values as key and value (username,name,email,password,confirmpassword)
eg key - username value - admin

To crate user as per various roles AccountController.cs->Register
and change UserManager.AddToRole(user.Id, "User"): accordingly.

Check Login

1. Goto Postman
2. Method - POST Url - https://localhost:44310/api/Account/login
3. select x-www-form-urlencode
4. put all required values as key and value
eg key - username value - admin
key - password value - Pass@123

About

Standalone webapi created For Authentication and Authorization using jwt.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •