WIP: user management
This commit is contained in:
parent
a2a5e8dd72
commit
5e5f95f6e0
5 changed files with 7 additions and 239 deletions
|
@ -1,77 +0,0 @@
|
|||
|
||||
// Copyright (C) 2022 FCS Frede's Computer Services.
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||
//
|
||||
|
||||
using Wonky.Entity.DTO;
|
||||
using Wonky.Entity.Views;
|
||||
|
||||
namespace Wonky.Client.HttpInterfaces;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for User handling over http
|
||||
/// </summary>
|
||||
public interface ISystemUserRepositoryGen1
|
||||
{
|
||||
/// <summary>
|
||||
/// Get Advisors (Office)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<UserManagerListView>> GetUsers();
|
||||
|
||||
/// <summary>
|
||||
/// Get Advisor Info for given userId
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
Task<WebUserInfoView> GetAdvisorInfo(string userId);
|
||||
|
||||
/// <summary>
|
||||
/// Update Advisor using userId and updated data
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdateAdvisor(string userId, X_UserUpdateDto model);
|
||||
|
||||
/// <summary>
|
||||
/// Get Administrative Users
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<UserManagerListView>> GetAdminUsers();
|
||||
|
||||
/// <summary>
|
||||
/// Get Admin Info for giver userId
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
Task<X_UserInfoDto> GetAdminUserInfo(string userId);
|
||||
|
||||
/// <summary>
|
||||
/// Update Admin user using userId and updated data
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdateAdminUser(string userId, X_UserUpdateDto model);
|
||||
|
||||
/// <summary>
|
||||
/// Set new user password
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="newPasswd"></param>
|
||||
/// <param name="confirmPasswd"></param>
|
||||
/// <returns></returns>
|
||||
Task ResetUserPassword(string userId, string newPasswd, string confirmPasswd);
|
||||
}
|
|
@ -1,122 +0,0 @@
|
|||
|
||||
// Copyright (C) 2022 FCS Frede's Computer Services.
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||
//
|
||||
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Wonky.Client.HttpInterfaces;
|
||||
using Wonky.Entity.Configuration;
|
||||
using Wonky.Entity.DTO;
|
||||
using Wonky.Entity.Views;
|
||||
|
||||
namespace Wonky.Client.HttpRepository;
|
||||
|
||||
public class SystemUserRepositoryGen1 : ISystemUserRepositoryGen1
|
||||
{
|
||||
private readonly JsonSerializerOptions? _options = new JsonSerializerOptions
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
private readonly NavigationManager _navigation;
|
||||
private ILogger<SystemUserRepositoryGen1> _logger;
|
||||
private readonly HttpClient _client;
|
||||
private readonly ApiConfig _api;
|
||||
|
||||
public SystemUserRepositoryGen1(HttpClient client, ILogger<SystemUserRepositoryGen1> logger,
|
||||
NavigationManager navigation, IOptions<ApiConfig> configuration)
|
||||
{
|
||||
_client = client;
|
||||
_logger = logger;
|
||||
_navigation = navigation;
|
||||
_api = configuration.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Advisors (Office)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<UserManagerListView>> GetUsers()
|
||||
{
|
||||
return await _client.GetFromJsonAsync<List<UserManagerListView>>(_api.OfficeAdvisors);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Advisor Info for given userId
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<WebUserInfoView> GetAdvisorInfo(string userId)
|
||||
{
|
||||
return await _client.GetFromJsonAsync<WebUserInfoView>($"{_api.OfficeAdvisors}/{userId}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update Advisor using userId and updated data
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public async Task UpdateAdvisor(string userId, X_UserUpdateDto model)
|
||||
{
|
||||
await _client.PutAsJsonAsync($"{_api.OfficeAdvisors}/{userId}", model, _options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Administrative Users
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<UserManagerListView>> GetAdminUsers()
|
||||
{
|
||||
return await _client.GetFromJsonAsync<List<UserManagerListView>>(_api.OfficeUsers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Admin Info for giver userId
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<X_UserInfoDto> GetAdminUserInfo(string userId)
|
||||
{
|
||||
return await _client.GetFromJsonAsync<X_UserInfoDto>($"{_api.OfficeUsers}/{userId}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update Admin user using userId and updated data
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public async Task UpdateAdminUser(string userId, X_UserUpdateDto model)
|
||||
{
|
||||
await _client.PutAsJsonAsync($"{_api.OfficeUsers}/{userId}", model, _options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set new user password
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="newPasswd"></param>
|
||||
/// <param name="confirmPasswd"></param>
|
||||
/// <returns></returns>
|
||||
public async Task ResetUserPassword(string userId, string newPasswd, string confirmPasswd)
|
||||
{
|
||||
var passwd = new Dictionary<string, string>
|
||||
{ { "newPassword", newPasswd }, { "confirmPassword", confirmPasswd } };
|
||||
await _client.PostAsJsonAsync($"{_api.UserManagerSetPasswd}/{userId}", passwd, _options);
|
||||
}
|
||||
}
|
6
Wonky.Client/Services/UserInfoService.cs
Normal file
6
Wonky.Client/Services/UserInfoService.cs
Normal file
|
@ -0,0 +1,6 @@
|
|||
namespace Wonky.Client.Services;
|
||||
|
||||
public class UserInfoService
|
||||
{
|
||||
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
|
||||
// Copyright (C) 2022 FCS Frede's Computer Services.
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||
//
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Wonky.Entity.Views;
|
||||
|
||||
public class X_UserInfoView
|
||||
{
|
||||
[JsonPropertyName("advisor")] public string Advisor { get; set; } = "";
|
||||
[JsonPropertyName("companyId")] public string ReferenceId { get; set; } = "";
|
||||
[JsonPropertyName("countryCode")] public string CountryCode { get; set; } = "";
|
||||
[JsonPropertyName("countryName")] public string CountryName { get; set; } = "";
|
||||
[JsonPropertyName("email")] public string Email { get; set; } = "";
|
||||
[JsonPropertyName("fullName")] public string FullName { get; set; } = "";
|
||||
[JsonPropertyName("id")] public string Id { get; set; } = "";
|
||||
[JsonPropertyName("isAdmin")] public bool IsAdmin { get; set; }
|
||||
[JsonPropertyName("isAdvisor")] public bool IsAdvisor { get; set; }
|
||||
[JsonPropertyName("isEDoc")] public bool IsEDoc { get; set; }
|
||||
[JsonPropertyName("isEShop")] public bool IsEShop { get; set; }
|
||||
[JsonPropertyName("isOffice")] public bool IsOffice { get; set; }
|
||||
[JsonPropertyName("isWarehouse")] public bool IsWareHouse { get; set; }
|
||||
[JsonPropertyName("isSupervisor")] public bool IsSupervisor { get; set; }
|
||||
[JsonPropertyName("phoneNumber")] public string PhoneNumber { get; set; } = "";
|
||||
[JsonPropertyName("roles")] public string Roles { get; set; } = "";
|
||||
}
|
|
@ -18,7 +18,7 @@ using System.Text.Json.Serialization;
|
|||
|
||||
namespace Wonky.Entity.Views;
|
||||
|
||||
public class WebUserInfoView
|
||||
public class X_WebUserInfoView
|
||||
{
|
||||
[JsonPropertyName("userId")] public string UserId { get; set; } = "";
|
||||
[JsonPropertyName("salesRep")] public string Advisor { get; set; } = "";
|
Loading…
Reference in a new issue