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
namespace CleanArchitectureApp.Infrastructure.Persistence.Repositories | |
{ | |
public partial class UserMap : ClassMapping<Domain.User> | |
{ | |
public UserMap() | |
{ | |
Schema("dbo"); | |
Table("Users"); | |
Lazy(true); | |
Id(x => x.UserId, map => |
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
namespace CleanArchitectureApp.Domain | |
{ | |
public class User : AuditableBaseEntity | |
{ | |
public User() | |
{ | |
UserTokens = new List<UserToken>(); | |
} | |
public virtual Guid UserId { get; set; } |
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
namespace CleanArchitectureApp.Infrastructure.Persistence | |
{ | |
public static class ServiceRegistration | |
{ | |
public static void AddPersistenceInfrastructure(this IServiceCollection services, IConfiguration configuration) | |
{ | |
var mapper = new ModelMapper(); | |
mapper.AddMappings(typeof(UserMap).Assembly.ExportedTypes); | |
HbmMapping domainMapping = mapper.CompileMappingForAllExplicitlyAddedEntities(); |
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
namespace CleanArchitectureApp.WebApi.Middlewares | |
{ | |
using CleanArchitectureApp.Application.Exceptions; | |
using CleanArchitectureApp.Application.Wrappers; | |
using Microsoft.AspNetCore.Http; | |
using System; | |
using System.Collections.Generic; | |
using System.Net; | |
using System.Text.Json; | |
using System.Threading.Tasks; |
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
private Task<JwtSecurityToken> GenerateJWToken(User user) | |
{ | |
var claims = new[] | |
{ | |
new Claim(JwtRegisteredClaimNames.Sub, user.UserName), | |
new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()), | |
new Claim(JwtRegisteredClaimNames.Email, user.UserEmail), | |
new Claim("uid", user.UserId.ToString()), | |
}; |
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
namespace CleanArchitectureApp.WebApi.Extensions | |
{ | |
using CleanArchitectureApp.Application.Wrappers; | |
using CleanArchitectureApp.Domain; | |
using Microsoft.AspNetCore.Authentication.JwtBearer; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.IdentityModel.Tokens; | |
using Newtonsoft.Json; |
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
namespace CleanArchitectureApp.WebApi.Extensions | |
{ | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.OpenApi.Models; | |
using System; | |
using System.Reflection; | |
public static class SwaggerConfig |
NewerOlder