View Source
Class TwoFactorLoginService
Service handling 2FA logins.
Inheritance
System.Object
Assembly: Umbraco.Core.dll
Syntax
public class TwoFactorLoginService : ITwoFactorLoginService, IService
Constructors
View Source
TwoFactorLoginService(ITwoFactorLoginRepository, ICoreScopeProvider, IEnumerable<ITwoFactorProvider>, IOptions<IdentityOptions>, IOptions<BackOfficeIdentityOptions>, ILogger<TwoFactorLoginService>)
Declaration
public TwoFactorLoginService(ITwoFactorLoginRepository twoFactorLoginRepository, ICoreScopeProvider scopeProvider, IEnumerable<ITwoFactorProvider> twoFactorSetupGenerators, IOptions<IdentityOptions> identityOptions, IOptions<BackOfficeIdentityOptions> backOfficeIdentityOptions, ILogger<TwoFactorLoginService> logger)
Parameters
Methods
View Source
DeleteUserLoginsAsync(Guid)
Deletes all user logins - normally used when a member is deleted.
Declaration
public async Task DeleteUserLoginsAsync(Guid userOrMemberKey)
Parameters
Type |
Name |
Description |
Guid |
userOrMemberKey |
|
Returns
View Source
DisableAsync(Guid, String)
Disables the 2FA provider with the specified provider name for the specified user or member.
Declaration
public async Task<bool> DisableAsync(Guid userOrMemberKey, string providerName)
Parameters
Type |
Name |
Description |
Guid |
userOrMemberKey |
|
System.String |
providerName |
|
Returns
Type |
Description |
Task<System.Boolean> |
|
View Source
DisableWithCodeAsync(String, Guid, String)
Declaration
public async Task<bool> DisableWithCodeAsync(string providerName, Guid userOrMemberKey, string code)
Parameters
Type |
Name |
Description |
System.String |
providerName |
|
Guid |
userOrMemberKey |
|
System.String |
code |
|
Returns
Type |
Description |
Task<System.Boolean> |
|
View Source
GenerateSecret()
Generates a new random unique secret.
Declaration
protected virtual string GenerateSecret()
Returns
Type |
Description |
System.String |
The random secret
|
View Source
GetAllProviderNames()
Gets all registered providers names.
Declaration
public IEnumerable<string> GetAllProviderNames()
Returns
Type |
Description |
IEnumerable<System.String> |
|
View Source
GetEnabledTwoFactorProviderNamesAsync(Guid)
Gets all the enabled 2FA providers for the user or member with the specified key.
Declaration
public async Task<IEnumerable<string>> GetEnabledTwoFactorProviderNamesAsync(Guid userOrMemberKey)
Parameters
Type |
Name |
Description |
Guid |
userOrMemberKey |
|
Returns
Type |
Description |
Task<IEnumerable<System.String>> |
|
View Source
GetSecretForUserAndProviderAsync(Guid, String)
Gets the secret for user or member and a specific provider.
Declaration
public async Task<string> GetSecretForUserAndProviderAsync(Guid userOrMemberKey, string providerName)
Parameters
Type |
Name |
Description |
Guid |
userOrMemberKey |
|
System.String |
providerName |
|
Returns
Type |
Description |
Task<System.String> |
|
View Source
GetSetupInfoAsync(Guid, String)
Gets the setup info for a specific user or member and a specific provider.
Declaration
public async Task<object> GetSetupInfoAsync(Guid userOrMemberKey, string providerName)
Parameters
Type |
Name |
Description |
Guid |
userOrMemberKey |
|
System.String |
providerName |
|
Returns
Type |
Description |
Task<System.Object> |
|
View Source
IsTwoFactorEnabledAsync(Guid)
Checks whether 2FA is enabled for the user or member with the specified key.
Declaration
public async Task<bool> IsTwoFactorEnabledAsync(Guid userOrMemberKey)
Parameters
Type |
Name |
Description |
Guid |
userOrMemberKey |
|
Returns
Type |
Description |
Task<System.Boolean> |
|
View Source
SaveAsync(TwoFactorLogin)
Saves the 2FA login information.
Declaration
public Task SaveAsync(TwoFactorLogin twoFactorLogin)
Parameters
Returns
View Source
ValidateAndSaveAsync(String, Guid, String, String)
Declaration
public async Task<bool> ValidateAndSaveAsync(string providerName, Guid userOrMemberKey, string secret, string code)
Parameters
Type |
Name |
Description |
System.String |
providerName |
|
Guid |
userOrMemberKey |
|
System.String |
secret |
|
System.String |
code |
|
Returns
Type |
Description |
Task<System.Boolean> |
|
View Source
ValidateTwoFactorSetup(String, String, String)
Validates the setup of the provider using the secret and code.
Declaration
public bool ValidateTwoFactorSetup(string providerName, string secret, string code)
Parameters
Type |
Name |
Description |
System.String |
providerName |
|
System.String |
secret |
|
System.String |
code |
|
Returns
Type |
Description |
System.Boolean |
|