issue #41
All checks were successful
Test CI / build (push) Successful in 1m21s

- 비밀번호 초기화 로직 1차 구현(테스트 필요)
This commit is contained in:
geonhee-min
2025-12-02 12:35:45 +09:00
parent 58d092536e
commit 0f0717fc79
25 changed files with 729 additions and 46 deletions

View File

@@ -2,4 +2,36 @@ export class Generator {
static getVerificationCode() {
return Math.random().toString().slice(2, 8);
}
private static getRandomCharacter(string: string) {
return string[Math.floor(Math.random() * string.length)];
}
private static getShuffledString(string: string) {
let arr = string.split('');
for (let i = arr.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[arr[i], arr[j]] = [arr[j], arr[i]];
}
return arr.join('');
}
static getResetPasswordCode() {
const alphabets = 'abcdefghijklmnopqrstuvwxyz';
const numbers = '0123456789';
const specials = '!@#$%^';
const all = alphabets + numbers + specials;
let resetPasswordCode = Generator.getRandomCharacter(alphabets);
let requiredNumber = Generator.getRandomCharacter(numbers);
let requiredSpecial = Generator.getRandomCharacter(specials);
let shuffledRestPart = Generator.getShuffledString(all).slice(0, 5);
let shuffledRestCode = Generator.getShuffledString(requiredNumber + requiredSpecial + shuffledRestPart);
return resetPasswordCode + shuffledRestCode;
}
}