feat(user): 사용자 자기정보 편집과 관리자 재설정 플로우를 연동
- lib/widgets/app_shell.dart에서 내 정보 다이얼로그를 추가하고 UserRepository.updateMe·비밀번호 변경 로직을 연결 - lib/features/masters/user/* 모듈에 phone·forcePasswordChange·passwordUpdatedAt 필드를 반영하고 reset-password/update-me API를 사용 - lib/core/validation/password_rules.dart을 신설해 비밀번호 정책 검증을 공통화하고 신규 위젯·테스트에서 재사용 - doc/stock_approval_system_api_v4.md 등 문서를 users 스펙 개편 내용으로 갱신하고 user_management_plan.md를 추가 - test/widgets/app_shell_test.dart 등에서 자기정보 수정·비밀번호 재설정 시나리오를 검증하고 기존 테스트를 보강
This commit is contained in:
55
lib/core/validation/password_rules.dart
Normal file
55
lib/core/validation/password_rules.dart
Normal file
@@ -0,0 +1,55 @@
|
||||
/// 비밀번호 정책을 검증하기 위한 규칙 모음.
|
||||
class PasswordRules {
|
||||
PasswordRules._();
|
||||
|
||||
/// 허용 최소 길이.
|
||||
static const int minLength = 8;
|
||||
|
||||
/// 허용 최대 길이.
|
||||
static const int maxLength = 24;
|
||||
|
||||
static final RegExp _uppercase = RegExp(r'[A-Z]');
|
||||
static final RegExp _lowercase = RegExp(r'[a-z]');
|
||||
static final RegExp _digit = RegExp(r'[0-9]');
|
||||
static final RegExp _special = RegExp(
|
||||
"[!@#\$%\\^&*()_+\\-={}\\[\\]\\\\|:;\"'<>,.?/~`]",
|
||||
);
|
||||
|
||||
/// 입력이 모든 비밀번호 규칙을 만족하는지 검사한다.
|
||||
static bool isValid(String value) => validate(value).isEmpty;
|
||||
|
||||
/// 비밀번호 정책 위반 항목을 반환한다.
|
||||
static List<PasswordRuleViolation> validate(String value) {
|
||||
final violations = <PasswordRuleViolation>[];
|
||||
final length = value.length;
|
||||
if (length < minLength) {
|
||||
violations.add(PasswordRuleViolation.tooShort);
|
||||
}
|
||||
if (length > maxLength) {
|
||||
violations.add(PasswordRuleViolation.tooLong);
|
||||
}
|
||||
if (!_uppercase.hasMatch(value)) {
|
||||
violations.add(PasswordRuleViolation.missingUppercase);
|
||||
}
|
||||
if (!_lowercase.hasMatch(value)) {
|
||||
violations.add(PasswordRuleViolation.missingLowercase);
|
||||
}
|
||||
if (!_digit.hasMatch(value)) {
|
||||
violations.add(PasswordRuleViolation.missingDigit);
|
||||
}
|
||||
if (!_special.hasMatch(value)) {
|
||||
violations.add(PasswordRuleViolation.missingSpecial);
|
||||
}
|
||||
return violations;
|
||||
}
|
||||
}
|
||||
|
||||
/// 비밀번호 규칙 위반 유형.
|
||||
enum PasswordRuleViolation {
|
||||
tooShort,
|
||||
tooLong,
|
||||
missingUppercase,
|
||||
missingLowercase,
|
||||
missingDigit,
|
||||
missingSpecial,
|
||||
}
|
||||
Reference in New Issue
Block a user