Class AccountService
Local accounts, devices and access tokens.
Inheritance
AccountService
Assembly: Uniform.Matrix.Server.dll
public sealed class AccountService
Constructors
|
Edit this page
View Source
AccountService(IDbContextFactory<ServerDbContext>, IOptions<ServerOptions>, TimeProvider, DeviceKeyService)
Create the service over the database.
Declaration
public AccountService(IDbContextFactory<ServerDbContext> contexts, IOptions<ServerOptions> options, TimeProvider time, DeviceKeyService keys)
Parameters
Properties
|
Edit this page
View Source
Server name of local user IDs.
Declaration
public string ServerName { get; }
Property Value
Methods
|
Edit this page
View Source
Return the user and device of an access token, or null when unknown; record when the device was last seen.
Declaration
public Task<Requester?> AuthenticateAsync(string token, string? address, CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
Set a new password; with keepDeviceId, logs out every other device.
Declaration
public Task ChangePasswordAsync(string userId, string newPassword, string? keepDeviceId, CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
Return whether password is the password of an active account.
Declaration
public Task<bool> CheckPasswordAsync(string userId, string password, CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
Delete devices of userId with their tokens, pushers, keys and waiting messages; unknown device IDs are ignored.
Declaration
public Task DeleteDevicesAsync(string userId, IReadOnlyCollection<string> deviceIds, CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
Return one device; throw M_NOT_FOUND when the user has no such device.
Declaration
public Task<Device> GetDeviceAsync(string userId, string deviceId, CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
Return the devices of userId.
Declaration
public Task<IReadOnlyList<Device>> GetDevicesAsync(string userId, CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
Return whether localpart is free; throw M_INVALID_USERNAME when it is not valid.
Declaration
public Task<bool> IsAvailableAsync(string localpart, CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
Declaration
public static MatrixErrorException LockedError()
Returns
|
Edit this page
View Source
Log in with a password; throw M_FORBIDDEN for unknown users and wrong passwords alike.
Declaration
public Task<LoginResponse> LoginAsync(string user, string password, string? deviceId, string? deviceName, CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
End every session of userId.
Declaration
public Task LogoutAllAsync(string userId, CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
End the session of requester: its token and device.
Declaration
public Task LogoutAsync(Requester requester, CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
Create an account, and unless inhibitLogin a device with an access token; throw M_USER_IN_USE when taken.
Declaration
public Task<RegisterResponse> RegisterAsync(string? localpart, string? password, string? deviceId, string? deviceName, bool inhibitLogin, bool admin, CancellationToken cancellationToken)
Parameters
| Type |
Name |
Description |
| string |
localpart |
Wanted localpart, or null for a generated one.
|
| string |
password |
Password, or null for an account that cannot log in with one.
|
| string |
deviceId |
Device to create, or null for a generated one.
|
| string |
deviceName |
Display name of the device.
|
| bool |
inhibitLogin |
Whether to create only the account.
|
| bool |
admin |
Whether the user administers the server.
|
| CancellationToken |
cancellationToken |
Cancellation token.
|
Returns
|
Edit this page
View Source
Rename a device; throw M_NOT_FOUND when the user has no such device.
Declaration
public Task RenameDeviceAsync(string userId, string deviceId, string? displayName, CancellationToken cancellationToken)
Parameters
Returns