Last active
November 18, 2020 21:30
-
-
Save vaygeth89/f7ae06148433ef482835361ae3e3792d to your computer and use it in GitHub Desktop.
tutorial-dotnet-JWTProtectedAPI AccountController Setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Data.Entity; | |
using System.IdentityModel.Tokens.Jwt; | |
using System.Linq; | |
using System.Security.Claims; | |
using System.Text; | |
using System.Threading.Tasks; | |
using JWTProtectedAPI.Models; | |
using JWTProtectedAPI.ViewModels; | |
using Microsoft.AspNetCore.Authorization; | |
using Microsoft.AspNetCore.Identity; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.Extensions.Options; | |
using Microsoft.IdentityModel.Tokens; | |
namespace JWTProtectedAPI.Controllers | |
{ | |
[Route("api/{Controller}/")] | |
[ApiController] | |
public class AccountController : ControllerBase | |
{ | |
private AppDbContext _appDbContext; | |
private readonly JWTBearerTokenSettings _jwtBearerTokenSettings; | |
protected readonly UserManager<IdentityUser> _userManager; | |
public AccountController(AppDbContext appDbContext, UserManager<IdentityUser> userManager, IOptions<JWTBearerTokenSettings> jwtTokenOptions) | |
{ | |
_appDbContext = appDbContext; | |
_jwtBearerTokenSettings = jwtTokenOptions.Value; | |
_userManager = userManager; | |
} | |
//To be continued | |
//Rest of the code coming | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment