Skip to content
Open
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
5c0b606
consolidation of authentication settings
ntuthukomsane Nov 18, 2025
e69fd3e
shesha authentication settings - latest
ntuthukomsane Dec 8, 2025
c61ab10
Merge branch 'main' of https://github.com/ntuthukomsane-boxfusion/she…
ntuthukomsane Dec 8, 2025
2c55894
Merge branch 'shesha-io:main' into ntuthuko/consolidate-authenticatio…
ntuthukomsane-boxfusion Dec 8, 2025
05bd124
Merge branch 'shesha-io:main' into ntuthuko/consolidate-authenticatio…
ntuthukomsane-boxfusion Dec 8, 2025
6318512
Merge branch 'shesha-io:main' into ntuthuko/consolidate-authenticatio…
ntuthukomsane-boxfusion Dec 8, 2025
5203870
remove unnecessary migration
ntuthukomsane Dec 9, 2025
e161ee6
Merge branch 'ntuthuko/consolidate-authentication-settings' of https:…
ntuthukomsane Dec 9, 2025
ec4852d
resolve conflicts
ntuthukomsane Dec 9, 2025
8f55ab7
remove commented code
ntuthukomsane Dec 9, 2025
dc7f3a4
Update shesha-core/src/Shesha.Framework/Configuration/Security/Fronte…
ntuthukomsane-boxfusion Dec 9, 2025
e9fe134
Update shesha-core/src/Shesha.Framework/Configuration/Security/Fronte…
ntuthukomsane-boxfusion Dec 9, 2025
26c55cd
Update shesha-core/src/Shesha.Framework/Configuration/Security/Fronte…
ntuthukomsane-boxfusion Dec 9, 2025
950bced
Update shesha-core/src/Shesha.Application/Authorization/Settings/Dto/…
ntuthukomsane-boxfusion Dec 9, 2025
b29eff5
Merge branch 'shesha-io:main' into ntuthuko/consolidate-authenticatio…
ntuthukomsane-boxfusion Dec 9, 2025
d715901
Merge branch 'main' of https://github.com/ntuthukomsane-boxfusion/she…
ntuthukomsane Dec 9, 2025
74723f7
Merge branch 'ntuthuko/consolidate-authentication-settings' of https:…
ntuthukomsane Dec 9, 2025
ab40775
authorization dto
ntuthukomsane Dec 9, 2025
b9b168d
resolve AuthorizationSettingsAppService comments
ntuthukomsane Dec 9, 2025
09ba80c
Merge branch 'shesha-io:main' into ntuthuko/consolidate-authenticatio…
ntuthukomsane-boxfusion Dec 9, 2025
810e045
Merge branch 'main' of https://github.com/ntuthukomsane-boxfusion/she…
ntuthukomsane Dec 9, 2025
207c740
Merge branch 'ntuthuko/consolidate-authentication-settings' of https:…
ntuthukomsane Dec 9, 2025
69cbae0
resolve code rabbit comments
ntuthukomsane Dec 9, 2025
1f6c12d
resolve authorization app service comments
ntuthukomsane Dec 9, 2025
e542efc
Merge branch 'shesha-io:main' into ntuthuko/consolidate-authenticatio…
ntuthukomsane-boxfusion Dec 9, 2025
31297eb
Update shesha-core/src/Shesha.Application/Authorization/Settings/Auth…
ntuthukomsane-boxfusion Dec 9, 2025
ababb1c
fix auto mapper
ntuthukomsane Dec 9, 2025
d628295
Merge branch 'ntuthuko/consolidate-authentication-settings' of https:…
ntuthukomsane Dec 9, 2025
ebd6f3b
Update shesha-core/src/Shesha.Application/Authorization/Settings/Auth…
ntuthukomsane-boxfusion Dec 9, 2025
f128401
Merge branch 'shesha-io:main' into ntuthuko/consolidate-authenticatio…
ntuthukomsane-boxfusion Dec 11, 2025
3d00301
Merge branch 'shesha-io:main' into ntuthuko/consolidate-authenticatio…
ntuthukomsane-boxfusion Dec 11, 2025
cec5d2b
package shaconfigs as one file
ntuthukomsane Dec 11, 2025
dd84682
Merge branch 'ntuthuko/consolidate-authentication-settings' of https:…
ntuthukomsane Dec 11, 2025
624fcab
Merge branch 'shesha-io:main' into ntuthuko/consolidate-authenticatio…
ntuthukomsane-boxfusion Dec 15, 2025
105d7a2
Merge branch 'shesha-io:main' into ntuthuko/consolidate-authenticatio…
ntuthukomsane-boxfusion Dec 15, 2025
e2ef484
migrate old authentication settings and fix mapping profile
ntuthukomsane Dec 15, 2025
bb05aac
Merge branch 'ntuthuko/consolidate-authentication-settings' of https:…
ntuthukomsane Dec 15, 2025
b4a197f
resolve code rabbit comments
ntuthukomsane Dec 15, 2025
d07dc07
Merge branch 'shesha-io:main' into ntuthuko/consolidate-authenticatio…
ntuthukomsane-boxfusion Dec 15, 2025
c8d162c
Shesha.Security
ntuthukomsane Dec 15, 2025
942ac0b
Merge branch 'ntuthuko/consolidate-authentication-settings' of https:…
ntuthukomsane Dec 15, 2025
622cc51
add condition for postgres migration
ntuthukomsane Dec 15, 2025
1ab63f5
Update shesha-core/src/Shesha.Framework/Migrations/M20251215130900.cs
ntuthukomsane-boxfusion Dec 15, 2025
2d8075a
postgres migration fix
ntuthukomsane Dec 15, 2025
06fbf6e
Merge branch 'ntuthuko/consolidate-authentication-settings' of https:…
ntuthukomsane Dec 15, 2025
5122f3b
Merge branch 'main' of https://github.com/ntuthukomsane-boxfusion/she…
ntuthukomsane Jan 30, 2026
b5e70a0
Merge branch 'main' of https://github.com/ntuthukomsane-boxfusion/she…
ntuthukomsane Feb 2, 2026
71b10cb
fix app settings
ntuthukomsane Feb 2, 2026
068279d
bing back package.json
ntuthukomsane Feb 2, 2026
72a84fd
updated form configurations
ntuthukomsane Feb 3, 2026
51fe80f
Merge branch 'main' into ntuthuko/consolidate-authentication-settings
ntuthukomsane Feb 4, 2026
8e5024e
throw user-friendly errors on CompleteRegistration
ntuthukomsane Feb 4, 2026
332502a
avoid throwing infrastructure exceptions on HandleAllowedDomainsAsync
ntuthukomsane Feb 4, 2026
2db4e66
make ValidateUserPasswordResetMethod async and update the callers
ntuthukomsane Feb 4, 2026
4496451
make the default case of HandleCreationMode throw a user-friendly exc…
ntuthukomsane Feb 4, 2026
91f02e6
Adding a guard before calling Activator.CreateInstance
ntuthukomsane Feb 4, 2026
30f6698
remove duplicated comments
ntuthukomsane Feb 4, 2026
0bf379e
Merge branch 'shesha-io:main' into ntuthuko/consolidate-authenticatio…
ntuthukomsane-boxfusion Feb 4, 2026
43f2b91
Merge branch 'shesha-io:main' into ntuthuko/consolidate-authenticatio…
ntuthukomsane-boxfusion Feb 4, 2026
24b4628
Merge branch 'shesha-io:main' into ntuthuko/consolidate-authenticatio…
ntuthukomsane-boxfusion Feb 5, 2026
a9bfd2a
Merge branch 'shesha-io:main' into ntuthuko/consolidate-authenticatio…
ntuthukomsane-boxfusion Feb 8, 2026
aae489b
Update shesha-core/src/Shesha.Application/UserManagements/UserManagem…
ntuthukomsane-boxfusion Feb 8, 2026
49b6def
Update shesha-core/src/Shesha.Framework/Configuration/FrontendApplica…
ntuthukomsane-boxfusion Feb 8, 2026
a3a6d77
fix code rabbit comments
ntuthukomsane Feb 8, 2026
3766711
resolve comments
ntuthukomsane Feb 8, 2026
0ce6810
Merge branch 'main' into ntuthuko/consolidate-authentication-settings
ntuthukomsane Feb 11, 2026
2572326
remove background image
ntuthukomsane Feb 11, 2026
98fa8fc
Update shesha-core/src/Shesha.Framework/Configuration/Security/Fronte…
ntuthukomsane-boxfusion Feb 11, 2026
22da986
Update shesha-core/src/Shesha.Application/UserManagements/UserManagem…
ntuthukomsane-boxfusion Feb 11, 2026
1db727b
resolve exception errors
ntuthukomsane Feb 11, 2026
24fa6ff
Merge branch 'ntuthuko/consolidate-authentication-settings' of https:…
ntuthukomsane Feb 11, 2026
ae75f31
Update shesha-core/src/Shesha.Framework/Configuration/FrontendApplica…
ntuthukomsane-boxfusion Feb 11, 2026
5f04f07
Update shesha-core/src/Shesha.Framework/Authorization/Users/UserManag…
ntuthukomsane-boxfusion Feb 11, 2026
a81981e
re-order migration items
ntuthukomsane Feb 11, 2026
90b6bb0
Merge branch 'ntuthuko/consolidate-authentication-settings' of https:…
ntuthukomsane Feb 11, 2026
22d1bda
merge from main
ntuthukomsane Feb 15, 2026
f44f83e
resolve comments
ntuthukomsane Feb 16, 2026
10d4866
Merge branch 'shesha-io:main' into ntuthuko/consolidate-authenticatio…
ntuthukomsane-boxfusion Feb 20, 2026
7c1add0
resolve comments on pr
ntuthukomsane Feb 21, 2026
4e2eac5
Remove unused commented code
ntuthukomsane Feb 22, 2026
dc153ff
Merge branch 'shesha-io:main' into ntuthuko/consolidate-authenticatio…
ntuthukomsane-boxfusion Feb 23, 2026
0c986be
Merge branch 'shesha-io:main' into ntuthuko/consolidate-authenticatio…
ntuthukomsane-boxfusion Feb 25, 2026
f6eb3a2
resolve comments: Remove settings that are not related to user manage…
ntuthukomsane Feb 25, 2026
22117dc
Merge branch 'ntuthuko/consolidate-authentication-settings' of https:…
ntuthukomsane Feb 25, 2026
79050ed
resolve conflicts
ntuthukomsane Feb 25, 2026
4f58f28
resolve conflicts
ntuthukomsane Feb 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,78 +1,108 @@
using Abp.Application.Services;
using Shesha.Authorization.Settings.Dto;
using Shesha.Configuration;
using Shesha.Configuration.Security;
using System;
using System;
using System.Threading.Tasks;
using Abp.Application.Services;
using Shesha.Authorization.Settings.Dto;
using Shesha.Configuration.Security.Frontend;

namespace Shesha.Authorization.Settings
{
[Obsolete("To be removed, is used for backward compatibility only")]
public class AuthorizationSettingsAppService: ApplicationService
{
private readonly IPasswordComplexitySettings _passwordComplexitySettings;
private readonly ISecuritySettings _securitySettings;
private readonly IUserManagementSettings _userManagementSettings;

public AuthorizationSettingsAppService(IPasswordComplexitySettings passwordComplexitySettings, ISecuritySettings securitySettings)
public AuthorizationSettingsAppService(IUserManagementSettings userManagementSettings)
{
_passwordComplexitySettings = passwordComplexitySettings;
_securitySettings = securitySettings;
_userManagementSettings = userManagementSettings;
}

public async Task UpdateSettingsAsync(AuthorizationSettingsDto dto)
{
//Lockout
await _securitySettings.UserLockOutEnabled.SetValueAsync(dto.IsLockoutEnabled);
await _securitySettings.DefaultAccountLockoutSeconds.SetValueAsync(dto.DefaultAccountLockoutSeconds);
await _securitySettings.MaxFailedAccessAttemptsBeforeLockout.SetValueAsync(dto.MaxFailedAccessAttemptsBeforeLockout);
await _securitySettings.SecuritySettings.SetValueAsync(new SecuritySettings
{
AutoLogoffTimeout = dto.AutoLogoffTimeout,
var existingSettings = await _userManagementSettings.DefaultAuthentication.GetValueAsync();
if (existingSettings == null)
{
existingSettings = new DefaultAuthenticationSettings();
}

// Default Authentication
await _userManagementSettings.DefaultAuthentication.SetValueAsync(new DefaultAuthenticationSettings
{
// Preserve existing OTP and registration settings
RequireOtpVerification = existingSettings.RequireOtpVerification,
AllowLocalUsernamePasswordAuth = existingSettings.AllowLocalUsernamePasswordAuth,
UseDefaultRegistrationForm = existingSettings.UseDefaultRegistrationForm,
UserEmailAsUsername = existingSettings.UserEmailAsUsername,
CustomRegistrationForm = existingSettings.CustomRegistrationForm,
SupportedVerificationMethods = existingSettings.SupportedVerificationMethods,
PasswordLength = existingSettings.PasswordLength,
Alphabet = existingSettings.Alphabet,
DefaultLifetime = existingSettings.DefaultLifetime,
IgnoreOtpValidation = existingSettings.IgnoreOtpValidation,
DefaultSubjectTemplate = existingSettings.DefaultSubjectTemplate,
DefaultBodyTemplate = existingSettings.DefaultBodyTemplate,
DefaultEmailSubjectTemplate = existingSettings.DefaultEmailSubjectTemplate,
DefaultEmailBodyTemplate = existingSettings.DefaultEmailBodyTemplate,

// Lockout settings from DTO
UserLockOutEnabled = dto.IsLockoutEnabled,
DefaultAccountLockoutSeconds = dto.DefaultAccountLockoutSeconds,
MaxFailedAccessAttemptsBeforeLockout = dto.MaxFailedAccessAttemptsBeforeLockout,

// Password complexity from DTO
RequireDigit = dto.RequireDigit,
RequireLowercase = dto.RequireLowercase,
RequireNonAlphanumeric = dto.RequireNonAlphanumeric,
RequireUppercase = dto.RequireUppercase,
RequiredLength = dto.RequiredLength,

// Password reset
// Password reset settings from DTO
UseResetPasswordViaEmailLink = dto.ResetPasswordWithEmailLinkIsSupported,
ResetPasswordEmailLinkLifetime = dto.ResetPasswordWithEmailLinkExpiryDelay,

UseResetPasswordViaSmsOtp = dto.ResetPasswordWithSmsOtpIsSupported,
ResetPasswordSmsOtpLifetime = dto.ResetPasswordWithSmsOtpExpiryDelay,

UseResetPasswordViaSecurityQuestions = dto.ResetPasswordWithSecurityQuestionsIsSupported,
ResetPasswordViaSecurityQuestionsNumQuestionsAllowed = dto.ResetPasswordWithSecurityQuestionsNumQuestionsAllowed
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.

//Password complexity
await _passwordComplexitySettings.RequireDigit.SetValueAsync(dto.RequireDigit);
await _passwordComplexitySettings.RequireLowercase.SetValueAsync(dto.RequireLowercase);
await _passwordComplexitySettings.RequireNonAlphanumeric.SetValueAsync(dto.RequireNonAlphanumeric);
await _passwordComplexitySettings.RequireUppercase.SetValueAsync(dto.RequireUppercase);
await _passwordComplexitySettings.RequiredLength.SetValueAsync(dto.RequiredLength);
// General Frontend Security Settings
var generalSettings = await _userManagementSettings.GeneralFrontendSecuritySettings.GetValueAsync()
?? new GeneralFrontendSecuritySettings();

generalSettings.AutoLogoffAfterInactivity = dto.AutoLogoffAfterInactivity;
generalSettings.AutoLogoffTimeout = dto.AutoLogoffTimeout;

await _userManagementSettings.GeneralFrontendSecuritySettings.SetValueAsync(generalSettings);
}

public async Task<AuthorizationSettingsDto> GetSettingsAsync()
{
var settings = await _securitySettings.SecuritySettings.GetValueAsync();
var defaultAuthSettings = await _userManagementSettings.DefaultAuthentication.GetValueAsync();
var generalFrontendSettings = await _userManagementSettings.GeneralFrontendSecuritySettings.GetValueAsync();
var dto = new AuthorizationSettingsDto();

//Lockout
dto.IsLockoutEnabled = await _securitySettings.UserLockOutEnabled.GetValueOrNullAsync();
dto.DefaultAccountLockoutSeconds = await _securitySettings.DefaultAccountLockoutSeconds.GetValueOrNullAsync();
dto.MaxFailedAccessAttemptsBeforeLockout = await _securitySettings.MaxFailedAccessAttemptsBeforeLockout.GetValueOrNullAsync();
dto.AutoLogoffTimeout = settings.AutoLogoffTimeout;
dto.IsLockoutEnabled = defaultAuthSettings.UserLockOutEnabled;
dto.DefaultAccountLockoutSeconds = defaultAuthSettings.DefaultAccountLockoutSeconds;
dto.MaxFailedAccessAttemptsBeforeLockout = defaultAuthSettings.MaxFailedAccessAttemptsBeforeLockout;

//Password complexity
dto.RequireDigit = await _passwordComplexitySettings.RequireDigit.GetValueOrNullAsync();
dto.RequireLowercase = await _passwordComplexitySettings.RequireLowercase.GetValueOrNullAsync();
dto.RequireNonAlphanumeric = await _passwordComplexitySettings.RequireNonAlphanumeric.GetValueOrNullAsync();
dto.RequireUppercase = await _passwordComplexitySettings.RequireUppercase.GetValueOrNullAsync();
dto.RequiredLength = await _passwordComplexitySettings.RequiredLength.GetValueOrNullAsync();
dto.RequireDigit = defaultAuthSettings.RequireDigit;
dto.RequireLowercase = defaultAuthSettings.RequireLowercase;
dto.RequireNonAlphanumeric = defaultAuthSettings.RequireNonAlphanumeric;
dto.RequireUppercase = defaultAuthSettings.RequireUppercase;
dto.RequiredLength = defaultAuthSettings.RequiredLength;

// Password reset
dto.ResetPasswordWithEmailLinkIsSupported = settings.UseResetPasswordViaEmailLink;
dto.ResetPasswordWithEmailLinkExpiryDelay = settings.ResetPasswordEmailLinkLifetime;
dto.ResetPasswordWithSmsOtpIsSupported = settings.UseResetPasswordViaSmsOtp;
dto.ResetPasswordWithSmsOtpExpiryDelay = settings.ResetPasswordSmsOtpLifetime;
dto.ResetPasswordWithSecurityQuestionsIsSupported = settings.UseResetPasswordViaSecurityQuestions;
dto.ResetPasswordWithSecurityQuestionsNumQuestionsAllowed = settings.ResetPasswordViaSecurityQuestionsNumQuestionsAllowed;
dto.ResetPasswordWithEmailLinkIsSupported = defaultAuthSettings.UseResetPasswordViaEmailLink;
dto.ResetPasswordWithEmailLinkExpiryDelay = defaultAuthSettings.ResetPasswordEmailLinkLifetime;
dto.ResetPasswordWithSmsOtpIsSupported = defaultAuthSettings.UseResetPasswordViaSmsOtp;
dto.ResetPasswordWithSmsOtpExpiryDelay = defaultAuthSettings.ResetPasswordSmsOtpLifetime;
dto.ResetPasswordWithSecurityQuestionsIsSupported = defaultAuthSettings.UseResetPasswordViaSecurityQuestions;
dto.ResetPasswordWithSecurityQuestionsNumQuestionsAllowed = defaultAuthSettings.ResetPasswordViaSecurityQuestionsNumQuestionsAllowed;

// General
dto.AutoLogoffAfterInactivity = generalFrontendSettings.AutoLogoffAfterInactivity;
dto.AutoLogoffTimeout = generalFrontendSettings.AutoLogoffTimeout;
Comment thread
ntuthukomsane-boxfusion marked this conversation as resolved.
Outdated

return dto;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Shesha.Authorization.Settings.Dto
using System.ComponentModel.DataAnnotations;

namespace Shesha.Authorization.Settings.Dto
{
/// <summary>
/// Authorization options
Expand All @@ -9,7 +11,7 @@ public class AuthorizationSettingsDto
/// Lockout enabled (default value for new users)
/// </summary>
public bool IsLockoutEnabled { get; set; }

/// <summary>
/// Lockout time in seconds
/// </summary>
Expand All @@ -22,34 +24,46 @@ public class AuthorizationSettingsDto


/// <summary>
/// Passwords: require digits
/// Require digit in passwords
/// </summary>
[Display(Name = "Require digit")]
public bool RequireDigit { get; set; }

/// <summary>
/// Passwords: require lower case character
/// </summary>
[Display(Name = "Require lowercase")]
public bool RequireLowercase { get; set; }

/// <summary>
/// Passwords: non alphanumeric character
/// </summary>
[Display(Name = "Require non alphanumeric")]
public bool RequireNonAlphanumeric { get; set; }

/// <summary>
/// Passwords: require upper case character
/// </summary>
[Display(Name = "Require uppercase")]
public bool RequireUppercase { get; set; }

/// <summary>
/// Passwords: min length
/// </summary>
[Display(Name = "Required length")]
public int RequiredLength { get; set; }

/// <summary>
/// Auto logoff timeout (in case of user inactivity). Set to 0 to disable
/// </summary>
[Display(Name = "Auto logoff timeout (in case of user inactivity). Set to 0 to disable")]
public int AutoLogoffTimeout { get; set; }

/// <summary>
/// Auto logoff timeout after inactivity
/// </summary>
public bool AutoLogoffAfterInactivity { get; set; }

/// <summary>
/// Allow users to reset passwords with reset link sent to their emails.
/// </summary>
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ public FrontEndAppTag(IFrontendSettings frontendSettings, string appKey)
_appKey = appKey;
}

public string? PublicUrl
public FrontendApplicationRedirectsSettings? PublicUrl
{
get
{
var value = _frontendSettings.PublicUrl.GetValueOrNull(new Settings.SettingManagementContext { AppKey = _appKey });
var value = _frontendSettings.FrontendApplicationRedirectsSettings.GetValueOrNull(new Settings.SettingManagementContext { AppKey = _appKey });
return value;
}
}
Expand Down

This file was deleted.

This file was deleted.

15 changes: 8 additions & 7 deletions shesha-core/src/Shesha.Application/Otp/OtpAppService.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
using Abp.Dependency;
using System.Threading.Tasks;
using Abp.Dependency;
using Microsoft.AspNetCore.Mvc;
using Shesha.Configuration.Security.Frontend;
using Shesha.Otp.Configuration;
using Shesha.Otp.Dto;
using System.Threading.Tasks;

namespace Shesha.Otp
{
public class OtpAppService : SheshaAppServiceBase, IOtpAppService, ITransientDependency
{
private readonly IOtpSettings _otpSettings;
private readonly IUserManagementSettings _userManagementSettings;
private readonly IOtpManager _otpManager;


public OtpAppService(IOtpManager otpManager, IOtpSettings otpSettings)
public OtpAppService(IOtpManager otpManager, IUserManagementSettings userManagementSettings)
{
_otpManager = otpManager;
_otpSettings = otpSettings;
_userManagementSettings = userManagementSettings;
}

/// <summary>
Expand Down Expand Up @@ -47,7 +48,7 @@ public async Task<IVerifyPinResponse> VerifyPinAsync(VerifyPinInput input)
[HttpPost]
public async Task<bool> UpdateSettingsAsync(OtpSettingsDto input)
{
await _otpSettings.OneTimePins.SetValueAsync(new OtpSettings
await _userManagementSettings.DefaultAuthentication.SetValueAsync(new DefaultAuthenticationSettings
{
PasswordLength = input.PasswordLength,
Alphabet = input.Alphabet,
Expand All @@ -64,7 +65,7 @@ await _otpSettings.OneTimePins.SetValueAsync(new OtpSettings
[HttpGet]
public async Task<OtpSettingsDto> GetSettingsAsync()
{
var emailSettings = await _otpSettings.OneTimePins.GetValueAsync();
var emailSettings = await _userManagementSettings.DefaultAuthentication.GetValueAsync();

var settings = new OtpSettingsDto
{
Expand Down
24 changes: 13 additions & 11 deletions shesha-core/src/Shesha.Application/Otp/OtpGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
using Abp.Dependency;
using Shesha.Otp.Configuration;
using System;
using System;
using System.Text;
using Abp.Dependency;
using Shesha.Configuration.Security.Frontend;

namespace Shesha.Otp
{
public class OtpGenerator: IOtpGenerator, ITransientDependency
{
private readonly IOtpSettings _settings;
private readonly IUserManagementSettings _userManagementSettings;

public OtpGenerator(IOtpSettings settings)
public OtpGenerator(IUserManagementSettings userManagementSettings)
{
_settings = settings;
_userManagementSettings = userManagementSettings;
}

public string GeneratePin()
{
var random = new Random();
var password = string.Empty;
var password = new StringBuilder();

var alphabet = _settings.OneTimePins.GetValue().Alphabet;
var passwordLength = _settings.OneTimePins.GetValue().PasswordLength;
var authSettings = _userManagementSettings.DefaultAuthentication.GetValue();
var alphabet = authSettings.Alphabet;
var passwordLength = authSettings.PasswordLength;

for (int i = 0; i < passwordLength; i++)
{
password += alphabet[random.Next(alphabet.Length)];
password.Append(alphabet[random.Next(alphabet.Length)]);
}

return password;
return password.ToString();
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
}
}
Loading