优化
This commit is contained in:
@@ -99,7 +99,7 @@ func (uc *SecurityUsecase) Current(ctx context.Context) (*SecurityConfig, error)
|
||||
uc.mu.RUnlock()
|
||||
value, err := uc.repo.SecurityConfig(ctx)
|
||||
if err != nil {
|
||||
// GVA returns its default value together with the database-not-ready
|
||||
// Return the default value together with the database-not-ready
|
||||
// error. Callers such as login/runtime policy consumers intentionally
|
||||
// ignore the error and continue with that default, while the HTTP
|
||||
// settings endpoint still reports the failure.
|
||||
@@ -115,6 +115,13 @@ func (uc *SecurityUsecase) Current(ctx context.Context) (*SecurityConfig, error)
|
||||
return value, nil
|
||||
}
|
||||
|
||||
// Security returns the persisted row for the administration endpoint. Runtime
|
||||
// policy consumers use Current so their hot path remains cached, while the
|
||||
// settings page mirrors the reference behavior and always observes storage.
|
||||
func (uc *SecurityUsecase) Security(ctx context.Context) (*SecurityConfig, error) {
|
||||
return uc.repo.SecurityConfig(ctx)
|
||||
}
|
||||
|
||||
func (uc *SecurityUsecase) ValidatePassword(value *SecurityConfig, password string) error {
|
||||
if value.PwdMinLength > 0 && utf8.RuneCountInString(password) < value.PwdMinLength {
|
||||
return fmt.Errorf("密码长度不能少于 %d 位", value.PwdMinLength)
|
||||
|
||||
Reference in New Issue
Block a user