Skip to content

Instantly share code, notes, and snippets.

@vaygeth89
Last active November 18, 2020 21:30
Show Gist options
  • Save vaygeth89/f7ae06148433ef482835361ae3e3792d to your computer and use it in GitHub Desktop.
Save vaygeth89/f7ae06148433ef482835361ae3e3792d to your computer and use it in GitHub Desktop.
tutorial-dotnet-JWTProtectedAPI AccountController Setup
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