Skip to content

Commit

Permalink
chors: config appsetting on production
Browse files Browse the repository at this point in the history
  • Loading branch information
mtai0524 committed Nov 18, 2024
1 parent 935da05 commit 4d066de
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 62 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ msbuild.wrn
/WebGame/.vs/NotionWebApp/DesignTimeBuild
/WebGame/TicTacToe/Properties/PublishProfiles
/NotaionWebApp/.vs

appsettings.Production.json
appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
using Microsoft.AspNetCore.Identity;
using Notaion.Domain.Models;
using Notaion.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Notaion.Repositories
namespace Notaion.Application.Repositories
{
public interface IAccountRepository
{
Expand Down
2 changes: 2 additions & 0 deletions NotaionWebApp/Notaion.Infrastructure/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public static IServiceCollection AddInfrastructure(this IServiceCollection servi

services.AddScoped<IChatRepository, ChatRepository>();
services.AddScoped<ICloudinaryService, CloudinaryService>();
services.AddScoped<IAccountRepository, AccountRepository>();

return services;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<ItemGroup>
<PackageReference Include="CloudinaryDotNet" Version="1.26.2" />
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="5.0.17" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.20" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.IdentityModel.Tokens;
using Notaion.Application.Repositories;
using Notaion.Domain.Entities;
using Notaion.Domain.Models;
using Notaion.Models;
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Security.Claims;
using System.Text;
using CloudinaryDotNet;
using CloudinaryDotNet.Actions;
using Notaion.Domain.Models;
using Notaion.Domain.Entities;
using System.Threading.Tasks;

namespace Notaion.Repositories
namespace Notaion.Infrastructure.Persistence
{
public class AccountRepository : IAccountRepository
{
Expand Down Expand Up @@ -59,7 +63,7 @@ public async Task<string> SignInAsync(SignInModel model) // đăng nhập
new Claim(ClaimTypes.Country, user.Avatar),
new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
};

var authenKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configuration["JWT:Secret"]));

var token = new JwtSecurityToken(
Expand Down Expand Up @@ -108,4 +112,4 @@ public async Task<IdentityResult> SignUpAsync(SignUpModel model) // đăng kí
return result;
}
}
}
}
2 changes: 1 addition & 1 deletion NotaionWebApp/Notaion/Controllers/ApiAccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Notaion.Repositories;
using Notaion.Models;
using Notaion.Infrastructure.Context;
using Microsoft.AspNetCore.Http.HttpResults;
Expand All @@ -14,6 +13,7 @@
using Notaion.Hubs;
using Notaion.Domain.Entities;
using Notaion.Domain.Models;
using Notaion.Application.Repositories;

namespace WebAPI.Controllers
{
Expand Down
37 changes: 0 additions & 37 deletions NotaionWebApp/Notaion/Controllers/WeatherForecastController.cs

This file was deleted.

9 changes: 7 additions & 2 deletions NotaionWebApp/Notaion/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using Notaion.Domain.Models;
using Notaion.Hubs;
using Notaion.Models;
using Notaion.Repositories;
using System.Text;
using Notaion.Application;
using Notaion.Infrastructure;
Expand All @@ -34,6 +33,13 @@
builder.Services.AddSwaggerGen();
builder.Services.AddSignalR();

builder.Configuration
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables();


builder.Services.AddCors(options =>
{
options.AddPolicy("AllowAllOrigins",
Expand All @@ -48,7 +54,6 @@
builder.Services.Configure<CloudinaryOptions>(builder.Configuration.GetSection("Cloudinary"));

// Services inject
builder.Services.AddScoped<IAccountRepository, AccountRepository>();
builder.Services.AddTransient<ApplicationDbContext>();

builder.Services.AddDefaultIdentity<User>(options => options.SignIn.RequireConfirmedAccount = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ by editing this MSBuild file. In order to learn more about this please visit htt
<PropertyGroup>
<TimeStampOfAssociatedLegacyPublishXmlFile />
<EncryptedPassword>AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAA45ACkv6Ev0Gy7utx8HyVkgAAAAACAAAAAAAQZgAAAAEAACAAAABSm0dADuKEoSXI2PM3/C+djjsZNaNJvaNktK2zzOh0ZQAAAAAOgAAAAAIAACAAAAAaubSe329ikteIzbdUehSGkeEFWcMirIFoj/tBJlG3PCAAAAAaOwJII3B0tuPaPOzYnGrfQAgIQnX5FDaCdhlVr8BQDEAAAADxwckrnekLCzuMBtAKkP1cCWMOulRqdqFNLxcPxe9HXD/Y0JACDx7eUDw/7grdO/SQQKIkbvxPSZZdbFnGYkiS</EncryptedPassword>
<History>True|2024-11-14T04:37:13.0792751Z||;True|2024-10-28T19:07:16.1054653+07:00||;True|2024-10-08T17:12:03.4740526+07:00||;</History>
<History>True|2024-11-18T01:56:26.6539288Z||;False|2024-11-18T08:54:38.8724697+07:00||;True|2024-11-17T23:02:34.2326203+07:00||;True|2024-11-17T22:58:09.9977191+07:00||;True|2024-11-14T11:37:13.0792751+07:00||;True|2024-10-28T19:07:16.1054653+07:00||;True|2024-10-08T17:12:03.4740526+07:00||;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>
13 changes: 0 additions & 13 deletions NotaionWebApp/Notaion/WeatherForecast.cs

This file was deleted.

8 changes: 8 additions & 0 deletions NotaionWebApp/Notaion/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
"Microsoft.AspNetCore": "Warning"
}
},

// config api key cloud here
"Cloudinary": {
"CloudName": "...",
"ApiKey": "...",
"ApiSecret": "..."
},

"AllowedHosts": "*",
"FileUpload": {
"FileSizeLimit": 300012000,
Expand Down

0 comments on commit 4d066de

Please sign in to comment.