-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathServiceCollectionExtension.cs
More file actions
35 lines (31 loc) · 1.22 KB
/
ServiceCollectionExtension.cs
File metadata and controls
35 lines (31 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/
using Microsoft.Extensions.DependencyInjection;
namespace BootstrapBlazor.Components;
/// <summary>
/// BootstrapBlazor service extensions
/// </summary>
public static class ServiceCollectionExtension
{
/// <summary>
/// Inject <see cref="ITotpService"/> service extension method.
/// </summary>
/// <param name="services"></param>
/// <param name="configOptions"></param>
/// <returns></returns>
public static IServiceCollection AddBootstrapBlazorTotpService(this IServiceCollection services, Action<
OtpOptions>? configOptions = null)
{
services.AddSingleton<ITotpService, DefaultTotpService>();
services.Configure<OtpOptions>(options =>
{
configOptions?.Invoke(options);
options.AccountName ??= "BootstrapBlazor";
options.UserName ??= "Simulator";
options.IssuerName ??= options.AccountName;
options.SecretKey ??= "OMM2LVLFX6QJHMYI";
});
return services;
}
}