Release v1.0.0 #16
.env
.gitea/workflows
ApiDto
ApiDto.csproj
Backend.slnCommon
Requests
Responses
Endpoint
Common
Attributes
BadRequestResponseAttribute.csLocalhostAttribute.csMaintenanceModeIgnoreAttribute.csNotFoundResponseAttribute.csTokenAuthenticationAttribute.cs
Exceptions
Interfaces
Model
Services
Configuration
EnvironmentManager.cs
General
Swagger
Controllers
BaseController.cs
Endpoint.csprojConfiguration
V1
CampusController.csDisciplineController.csFacultyController.csGroupController.csLectureHallController.csProfessorController.csScheduleController.cs
WeatherForecastController.csMiddleware
Program.csWeatherForecast.csSecurity
SqlData
Application
Application.csprojDependencyInjection.cs
Common
Cqrs
Campus/Queries
GetCampusBasicInfoList
CampusBasicInfoDto.csCampusBasicInfoVm.csGetCampusBasicInfoListQuery.csGetCampusBasicInfoListQueryHandler.cs
GetCampusDetails
Discipline/Queries
GetDisciplineDetails
GetDisciplineList
Faculty/Queries
GetFacultyDetails
GetFacultyList
Group/Queries
GetGroupDetails
GetGroupList
LectureHall/Queries
GetLectureHallDetails
GetLectureHallList
Professor/Queries
GetProfessorDetails
GetProfessorList
Schedule/Queries/GetScheduleList
Interfaces/DbContexts
Domain
Domain.csproj
Schedule
Migrations
MysqlMigrations
Migrations
20240601023106_InitialMigration.Designer.cs20240601023106_InitialMigration.csUberDbContextModelSnapshot.cs
MysqlMigrations.csprojPsqlMigrations
Migrations
20240601021702_InitialMigration.Designer.cs20240601021702_InitialMigration.csUberDbContextModelSnapshot.cs
PsqlMigrations.csprojSqliteMigrations
Persistence
Common
BaseDbContext.csConfigurationResolver.csDatabaseProvider.csDbContextFactory.csModelBuilderExtensions.cs
Contexts/Schedule
CampusDbContext.csDisciplineDbContext.csFacultyDbContext.csGroupDbContext.csLectureHallDbContext.csLessonAssociationDbContext.csLessonDbContext.csProfessorDbContext.csSpecificWeekDbContext.csTypeOfOccupationDbContext.cs
DbInitializer.csDependencyInjection.csEntityTypeConfigurations
Mark.cs
Persistence.csprojUberDbContext.csMysql/Schedule
CampusConfiguration.csDisciplineConfiguration.csFacultyConfiguration.csGroupConfiguration.csLectureHallConfiguration.csLessonAssociationConfiguration.csLessonConfiguration.csProfessorConfiguration.csSpecificWeekConfiguration.csTypeOfOccupationConfiguration.cs
Postgresql/Schedule
CampusConfiguration.csDisciplineConfiguration.csFacultyConfiguration.csGroupConfiguration.csLectureHallConfiguration.csLessonAssociationConfiguration.csLessonConfiguration.csProfessorConfiguration.csSpecificWeekConfiguration.csTypeOfOccupationConfiguration.cs
Sqlite/Schedule
@ -32,7 +32,11 @@ namespace Mirea.Api.Endpoint.Controllers.Configuration;
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
[MaintenanceModeIgnore]
|
[MaintenanceModeIgnore]
|
||||||
[ApiExplorerSettings(IgnoreApi = true)]
|
[ApiExplorerSettings(IgnoreApi = true)]
|
||||||
public class SetupController(ISetupToken setupToken, IMaintenanceModeNotConfigureService notConfigureService, IMemoryCache cache) : BaseController
|
public class SetupController(
|
||||||
|
ISetupToken setupToken,
|
||||||
|
IMaintenanceModeNotConfigureService notConfigureService,
|
||||||
|
IMemoryCache cache,
|
||||||
|
PasswordHashService passwordHashService) : BaseController
|
||||||
{
|
{
|
||||||
private const string CacheGeneralKey = "config_general";
|
private const string CacheGeneralKey = "config_general";
|
||||||
private const string CacheAdminKey = "config_admin";
|
private const string CacheAdminKey = "config_admin";
|
||||||
@ -208,6 +212,18 @@ public class SetupController(ISetupToken setupToken, IMaintenanceModeNotConfigur
|
|||||||
|
|
||||||
if (!MailAddress.TryCreate(user.Email, out _))
|
if (!MailAddress.TryCreate(user.Email, out _))
|
||||||
throw new ControllerArgumentException("The email address is incorrect.");
|
throw new ControllerArgumentException("The email address is incorrect.");
|
||||||
|
|
||||||
|
var (salt, hash) = passwordHashService.HashPassword(user.Password);
|
||||||
|
|
||||||
|
var admin = new Admin
|
||||||
|
{
|
||||||
|
Username = user.Username,
|
||||||
|
Email = user.Email,
|
||||||
|
PasswordHash = hash,
|
||||||
|
Salt = salt
|
||||||
|
};
|
||||||
|
|
||||||
|
cache.Set(CacheAdminKey, admin);
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,14 +313,13 @@ public class SetupController(ISetupToken setupToken, IMaintenanceModeNotConfigur
|
|||||||
if (!new SettingsRequiredValidator(GeneralConfig).AreSettingsValid())
|
if (!new SettingsRequiredValidator(GeneralConfig).AreSettingsValid())
|
||||||
throw new ControllerArgumentException("The necessary data has not been configured.");
|
throw new ControllerArgumentException("The necessary data has not been configured.");
|
||||||
|
|
||||||
// todo: change CreateUserRequest to Domain entity
|
if (!cache.TryGetValue(CacheAdminKey, out Admin? admin) || admin == null)
|
||||||
if (!cache.TryGetValue(CacheAdminKey, out CreateUserRequest? user) || user == null)
|
|
||||||
throw new ControllerArgumentException("The administrator's data was not set.");
|
throw new ControllerArgumentException("The administrator's data was not set.");
|
||||||
|
|
||||||
if (System.IO.File.Exists(PathBuilder.Combine(GeneralConfig.FilePath)))
|
if (System.IO.File.Exists(PathBuilder.Combine(GeneralConfig.FilePath)))
|
||||||
System.IO.File.Delete(PathBuilder.Combine(GeneralConfig.FilePath));
|
System.IO.File.Delete(PathBuilder.Combine(GeneralConfig.FilePath));
|
||||||
|
|
||||||
System.IO.File.WriteAllText(PathBuilder.Combine("admin.json"), JsonSerializer.Serialize(user));
|
System.IO.File.WriteAllText(PathBuilder.Combine(Admin.PathToSave), JsonSerializer.Serialize(admin));
|
||||||
|
|
||||||
System.IO.File.WriteAllText(
|
System.IO.File.WriteAllText(
|
||||||
PathBuilder.Combine(GeneralConfig.FilePath),
|
PathBuilder.Combine(GeneralConfig.FilePath),
|
||||||
|
Reference in New Issue
Block a user