mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 08:02:49 -05:00
Created sso config service with save (#936)
This commit is contained in:
@ -57,17 +57,5 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
return results.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public override async Task CreateAsync(SsoConfig obj)
|
||||
{
|
||||
obj.CreationDate = obj.RevisionDate = DateTime.UtcNow;
|
||||
await base.CreateAsync(obj);
|
||||
}
|
||||
|
||||
public override async Task ReplaceAsync(SsoConfig obj)
|
||||
{
|
||||
obj.RevisionDate = DateTime.UtcNow;
|
||||
await base.ReplaceAsync(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
10
src/Core/Services/ISsoConfigService.cs
Normal file
10
src/Core/Services/ISsoConfigService.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core.Models.Table;
|
||||
|
||||
namespace Bit.Core.Services
|
||||
{
|
||||
public interface ISsoConfigService
|
||||
{
|
||||
Task SaveAsync(SsoConfig config);
|
||||
}
|
||||
}
|
29
src/Core/Services/Implementations/SsoConfigService.cs
Normal file
29
src/Core/Services/Implementations/SsoConfigService.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Repositories;
|
||||
|
||||
namespace Bit.Core.Services
|
||||
{
|
||||
public class SsoConfigService : ISsoConfigService
|
||||
{
|
||||
private readonly ISsoConfigRepository _ssoConfigRepository;
|
||||
|
||||
public SsoConfigService(
|
||||
ISsoConfigRepository ssoConfigRepository)
|
||||
{
|
||||
_ssoConfigRepository = ssoConfigRepository;
|
||||
}
|
||||
|
||||
public async Task SaveAsync(SsoConfig config)
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
config.RevisionDate = now;
|
||||
if (config.Id == default)
|
||||
{
|
||||
config.CreationDate = now;
|
||||
}
|
||||
await _ssoConfigRepository.UpsertAsync(config);
|
||||
}
|
||||
}
|
||||
}
|
@ -112,6 +112,7 @@ namespace Bit.Core.Utilities
|
||||
services.AddScoped<Services.IEventService, EventService>();
|
||||
services.AddSingleton<IDeviceService, DeviceService>();
|
||||
services.AddSingleton<IAppleIapService, AppleIapService>();
|
||||
services.AddSingleton<ISsoConfigService, SsoConfigService>();
|
||||
}
|
||||
|
||||
public static void AddDefaultServices(this IServiceCollection services, GlobalSettings globalSettings)
|
||||
|
Reference in New Issue
Block a user