Merge pull request #3143 from sbwalker/dev

add ability to get user based on username or email address
This commit is contained in:
Shaun Walker
2023-08-13 08:35:24 -04:00
committed by GitHub
7 changed files with 46 additions and 9 deletions

View File

@ -15,7 +15,6 @@ namespace Oqtane.Services
/// <param name="siteId">ID of a <see cref="Site"/></param>
/// <returns></returns>
Task<User> GetUserAsync(int userId, int siteId);
/// <summary>
/// Get a <see cref="User"/> of a specific site
@ -25,6 +24,15 @@ namespace Oqtane.Services
/// <returns></returns>
Task<User> GetUserAsync(string username, int siteId);
/// <summary>
/// Get a <see cref="User"/> of a specific site
/// </summary>
/// <param name="username">Username / login of a <see cref="User"/></param>
/// <param name="email">email address of a <see cref="User"/></param>
/// <param name="siteId">ID of a <see cref="Site"/></param>
/// <returns></returns>
Task<User> GetUserAsync(string username, string email, int siteId);
/// <summary>
/// Save a user to the Database.
/// The <see cref="User"/> object contains all the information incl. what <see cref="Site"/> it belongs to.

View File

@ -4,6 +4,7 @@ using System.Net.Http;
using System.Threading.Tasks;
using Oqtane.Documentation;
using System.Net;
using System.ComponentModel.DataAnnotations;
namespace Oqtane.Services
{
@ -21,7 +22,12 @@ namespace Oqtane.Services
public async Task<User> GetUserAsync(string username, int siteId)
{
return await GetJsonAsync<User>($"{Apiurl}/name/{username}?siteid={siteId}");
return await GetUserAsync(username, "", siteId);
}
public async Task<User> GetUserAsync(string username, string email, int siteId)
{
return await GetJsonAsync<User>($"{Apiurl}/name/{(!string.IsNullOrEmpty(username) ? username : "-")}/{(!string.IsNullOrEmpty(email) ? email : "-")}/?siteid={siteId}");
}
public async Task<User> AddUserAsync(User user)