| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using Diligent.WebAPI.Business.Services.Interfaces;
- using Diligent.WebAPI.Business.Settings;
- using Diligent.WebAPI.Data;
- using Microsoft.AspNetCore.Identity;
- using Microsoft.Extensions.Logging;
-
- namespace Diligent.WebAPI.Business.Services
- {
-
- public class UserService : IUserService
- {
- private readonly AuthorizationSettings _authSettings;
- private readonly FrontEndSettings _frontEndSettings;
- private readonly UserManager<User> _userManager;
- private readonly IMapper _mapper;
- private readonly DatabaseContext _databaseContext;
- private readonly IEmailer _emailer;
- private readonly ILogger<UserService> _logger;
- private const string GoogleApiTokenInfoUrl = "https://www.googleapis.com/oauth2/v3/tokeninfo?id_token={0}";
- private string[] SupportedClientsIds = { "" };
-
- public UserService(IOptions<AuthorizationSettings> authSettings, IOptions<FrontEndSettings> frontEndSettings, UserManager<User> userManager, IMapper mapper, DatabaseContext databaseContext, IEmailer emailer, ILogger<UserService> logger)
- {
- _authSettings = authSettings.Value;
- _frontEndSettings = frontEndSettings.Value;
- _userManager = userManager;
- _mapper = mapper;
- _databaseContext = databaseContext;
- _emailer = emailer;
- _logger = logger;
- }
-
- public async Task<IEnumerable<User?>> GetAll() =>
- await _userManager.Users.ToListAsync();
-
- public async Task<User?> GetById(int id) =>
- await _userManager.FindByIdAsync(id.ToString());
-
- public async Task CreateUser(CreateUserRequestDto model)
- {
- var user = _mapper.Map<User>(model);
-
- await _userManager.CreateAsync(user, model.Password);
- }
- }
- }
|