add passkey and login management to User Management
This commit is contained in:
@ -147,17 +147,6 @@ namespace Oqtane.Services
|
||||
/// <returns></returns>
|
||||
Task<string> GetPersonalAccessTokenAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Link an external login with a local user account
|
||||
/// </summary>
|
||||
/// <param name="user">The <see cref="User"/> we're verifying</param>
|
||||
/// <param name="token">A Hash value in the URL which verifies this user got the e-mail (containing this token)</param>
|
||||
/// <param name="type">External Login provider type</param>
|
||||
/// <param name="key">External Login provider key</param>
|
||||
/// <param name="name">External Login provider display name</param>
|
||||
/// <returns></returns>
|
||||
Task<User> LinkUserAsync(User user, string token, string type, string key, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Get password requirements for site
|
||||
/// </summary>
|
||||
@ -177,8 +166,9 @@ namespace Oqtane.Services
|
||||
/// <summary>
|
||||
/// Get passkeys for a user
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<UserPasskey>> GetPasskeysAsync();
|
||||
Task<List<UserPasskey>> GetPasskeysAsync(int userId);
|
||||
|
||||
/// <summary>
|
||||
/// Update a user passkey
|
||||
@ -190,23 +180,37 @@ namespace Oqtane.Services
|
||||
/// <summary>
|
||||
/// Delete a user passkey
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="credentialId"></param>
|
||||
/// <returns></returns>
|
||||
Task DeletePasskeyAsync(byte[] credentialId);
|
||||
Task DeletePasskeyAsync(int userId, byte[] credentialId);
|
||||
|
||||
/// <summary>
|
||||
/// Get logins for a user
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<UserLogin>> GetLoginsAsync();
|
||||
Task<List<UserLogin>> GetLoginsAsync(int userId);
|
||||
|
||||
/// <summary>
|
||||
/// Link an external login with a local user account
|
||||
/// </summary>
|
||||
/// <param name="user">The <see cref="User"/> we're verifying</param>
|
||||
/// <param name="token">A Hash value in the URL which verifies this user got the e-mail (containing this token)</param>
|
||||
/// <param name="type">External Login provider type</param>
|
||||
/// <param name="key">External Login provider key</param>
|
||||
/// <param name="name">External Login provider display name</param>
|
||||
/// <returns></returns>
|
||||
Task<User> AddLoginAsync(User user, string token, string type, string key, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Delete a user login
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="provider"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
Task DeleteLoginAsync(string provider, string key);
|
||||
Task DeleteLoginAsync(int userId, string provider, string key);
|
||||
}
|
||||
|
||||
[PrivateApi("Don't show in the documentation, as everything should use the Interface")]
|
||||
@ -253,7 +257,7 @@ namespace Oqtane.Services
|
||||
|
||||
public async Task<User> LoginUserAsync(User user, bool setCookie, bool isPersistent)
|
||||
{
|
||||
return await PostJsonAsync<User>($"{Apiurl}/login?setcookie={setCookie}&persistent={isPersistent}", user);
|
||||
return await PostJsonAsync<User>($"{Apiurl}/signin?setcookie={setCookie}&persistent={isPersistent}", user);
|
||||
}
|
||||
|
||||
public async Task LogoutUserAsync(User user)
|
||||
@ -306,11 +310,6 @@ namespace Oqtane.Services
|
||||
return await GetStringAsync($"{Apiurl}/personalaccesstoken");
|
||||
}
|
||||
|
||||
public async Task<User> LinkUserAsync(User user, string token, string type, string key, string name)
|
||||
{
|
||||
return await PostJsonAsync<User>($"{Apiurl}/link?token={token}&type={type}&key={key}&name={name}", user);
|
||||
}
|
||||
|
||||
public async Task<string> GetPasswordRequirementsAsync(int siteId)
|
||||
{
|
||||
var requirements = await GetJsonAsync<Dictionary<string, string>>($"{Apiurl}/passwordrequirements/{siteId}");
|
||||
@ -338,9 +337,9 @@ namespace Oqtane.Services
|
||||
return await PostJsonAsync<Dictionary<string, string>>($"{Apiurl}/import?siteid={siteId}&fileid={fileId}¬ify={notify}", null);
|
||||
}
|
||||
|
||||
public async Task<List<UserPasskey>> GetPasskeysAsync()
|
||||
public async Task<List<UserPasskey>> GetPasskeysAsync(int userId)
|
||||
{
|
||||
return await GetJsonAsync<List<UserPasskey>>($"{Apiurl}/passkey");
|
||||
return await GetJsonAsync<List<UserPasskey>>($"{Apiurl}/passkey?id={userId}");
|
||||
}
|
||||
|
||||
public async Task<UserPasskey> UpdatePasskeyAsync(UserPasskey passkey)
|
||||
@ -348,19 +347,24 @@ namespace Oqtane.Services
|
||||
return await PutJsonAsync<UserPasskey>($"{Apiurl}/passkey", passkey);
|
||||
}
|
||||
|
||||
public async Task DeletePasskeyAsync(byte[] credentialId)
|
||||
public async Task DeletePasskeyAsync(int userId, byte[] credentialId)
|
||||
{
|
||||
await DeleteAsync($"{Apiurl}/passkey?id={Base64Url.EncodeToString(credentialId)}");
|
||||
await DeleteAsync($"{Apiurl}/passkey?id={userId}&credential={Base64Url.EncodeToString(credentialId)}");
|
||||
}
|
||||
|
||||
public async Task<List<UserLogin>> GetLoginsAsync()
|
||||
public async Task<List<UserLogin>> GetLoginsAsync(int userId)
|
||||
{
|
||||
return await GetJsonAsync<List<UserLogin>>($"{Apiurl}/login");
|
||||
return await GetJsonAsync<List<UserLogin>>($"{Apiurl}/login?id={userId}");
|
||||
}
|
||||
|
||||
public async Task DeleteLoginAsync(string provider, string key)
|
||||
public async Task<User> AddLoginAsync(User user, string token, string type, string key, string name)
|
||||
{
|
||||
await DeleteAsync($"{Apiurl}/login?provider={provider}&key={key}");
|
||||
return await PostJsonAsync<User>($"{Apiurl}/login?token={token}&type={type}&key={key}&name={name}", user);
|
||||
}
|
||||
|
||||
public async Task DeleteLoginAsync(int userId, string provider, string key)
|
||||
{
|
||||
await DeleteAsync($"{Apiurl}/login?id={userId}&provider={provider}&key={key}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user