Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api: ๐Ÿ› Sms type ๋ณ€ํ™˜ ์‹œ, ํœด๋จผ ์—๋Ÿฌ ์ œ๊ฑฐ ๋ฐ ์˜ˆ๋ฐฉ #138

Merged
merged 2 commits into from
Jul 25, 2024

Conversation

psychology50
Copy link
Member

์ž‘์—… ์ด์œ 

public enum VerificationType {
    GENERAL("general"),
    OAUTH("oauth"),
    USERNAME("username"),
    PASSWORD("password"),
    PHONE("phone");

    private final String type;

    VerificationType(String type) {
        this.type = type;
    }

    public PhoneCodeKeyType toPhoneVerificationType(Provider provider) {
        return switch (this) {
            case OAUTH -> PhoneCodeKeyType.getOauthSignUpTypeByProvider(provider);
            case USERNAME -> PhoneCodeKeyType.FIND_USERNAME;
            case PASSWORD -> PhoneCodeKeyType.FIND_PASSWORD;
            default -> PhoneCodeKeyType.SIGN_UP;
        };
    }
}
  • ์‚ฌ์šฉ์ž์˜ QueryParam์„ VerificationType์œผ๋กœ ๋ฐ›๊ณ  PhoneCodeKeyType์œผ๋กœ ์น˜ํ™˜ํ•˜๋Š” ๊ณผ์ •์—์„œ phone ๋ณ€ํ™˜ ๋ถ„๊ธฐ ์ฒ˜๋ฆฌ๋ฅผ ๋น ํŠธ๋ฆผ.
  • case ํ•˜๋‚˜ ๋” ์ถ”๊ฐ€ํ•˜๊ณ , default์ธ ๊ฒฝ์šฐ ์˜ˆ์™ธ๋ฅผ ๋˜์ ธ ํ•ด๊ฒฐํ•  ์ˆ˜๋„ ์žˆ์ง€๋งŒ ๋ณด๋‹ค ๊ทผ๋ณธ์ ์ธ ํœด๋จผ ์—๋Ÿฌ ๋ฐœ์ƒ ์›์ธ์„ ์ฐพ์•„์„œ ์ œ๊ฑฐ

์ž‘์—… ์‚ฌํ•ญ

๊ฐœ์ธ์ ์œผ๋กœ switch๋ฌธ์„ ์ข‹์•„ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
์ƒ์ˆ˜๊ฐ€ ์ถ”๊ฐ€๋  ๋•Œ๋งˆ๋‹ค ๊ฐœ๋ฐœ์ž๊ฐ€ case ๋ฌธ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๋ฐฉ์‹์€ ๋ฒˆ๊ฑฐ๋กœ์›€๊ณผ ํœด๋จผ ์—๋Ÿฌ ๊ฐ€๋Šฅ์„ฑ์˜ ์—ฌ์ง€๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

๋”ฐ๋ผ์„œ, ๊ฐ ์ƒ์ˆ˜๋งˆ๋‹ค PhoneCodeKeyType์„ ๋งคํ•‘ํ•˜๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.

public enum VerificationType {
    GENERAL("general", PhoneCodeKeyType.SIGN_UP),
    OAUTH("oauth", null),
    USERNAME("username", PhoneCodeKeyType.FIND_USERNAME),
    PASSWORD("password", PhoneCodeKeyType.FIND_PASSWORD),
    PHONE("phone", PhoneCodeKeyType.PHONE);

    private final String type;
    private final PhoneCodeKeyType phoneCodeKeyType;

    VerificationType(String type, PhoneCodeKeyType phoneCodeKeyType) {
        this.type = type;
        this.phoneCodeKeyType = phoneCodeKeyType;
    }

    public PhoneCodeKeyType toPhoneVerificationType(@Nonnull Provider provider) {
        if (this.equals(OAUTH)) {
            return PhoneCodeKeyType.getOauthSignUpTypeByProvider(provider);
        }

        return phoneCodeKeyType;
    }
}
  • OAuth ์ƒ์ˆ˜์˜ ๊ฒฝ์šฐ ์ผ๋Œ€๋‹ค ๋งคํ•‘์ด ๋˜๊ธฐ ๋•Œ๋ฌธ์—, ์ปดํŒŒ์ผ ์‹œ์ ์—๋Š” ๋น„๊ฒฐ์ •์ ์ผ ์ˆ˜ ๋ฐ–์— ์—†์–ด null์ฒ˜๋ฆฌ๋ฅผ ํ–ˆ์Šต๋‹ˆ๋‹ค.
  • ๊ทธ ์™ธ์—๋Š” ์ผ๋Œ€์ผ๋กœ ๋งคํ•‘๋œ PhoneCodeKeyType์„ ๋ช…์‹œ์ ์œผ๋กœ ํ• ๋‹นํ•˜๋„๋ก ๋งŒ๋“ค์—ˆ์œผ๋ฉฐ, ์žฅ๊ธฐ์ ์œผ๋กœ ๊ฐœ๋ฐœ์ž์˜ ํœด๋จผ ์—๋Ÿฌ๋ฅผ ๋ฐฉ์ง€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ๋˜ํ•œ ๊ณต๊ฐœ ๋ฉ”์„œ๋“œ๋ฅผ ๋‹จ ํ•˜๋‚˜๋งŒ ์™ธ๋ถ€์— ๋…ธ์ถœ์‹œํ‚ด์œผ๋กœ์จ, ํ•ด๋‹น ์—ด๊ฑฐ ํƒ€์ž…์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฐœ๋ฐœ์ž๊ฐ€ ์‹ค์ˆ˜๋ฅผ ํ•  ๊ฒฝ์šฐ ๋˜ํ•œ ์—†๋‹ค๊ณ  ํŒ๋‹จํ•ฉ๋‹ˆ๋‹ค.

๋ฆฌ๋ทฐ์–ด๊ฐ€ ์ค‘์ ์ ์œผ๋กœ ํ™•์ธํ•ด์•ผ ํ•˜๋Š” ๋ถ€๋ถ„

  • null ์ฒ˜๋ฆฌ๋ฅผ ํ•˜๋Š” ๊ฒƒ์ด ๋งž์„์ง€, ๋” ์ข‹์€ ๋ฐฉ๋ฒ•์ด ์žˆ์„๊นŒ์š”?

๋ฐœ๊ฒฌํ•œ ์ด์Šˆ

  • ๋‚ด ์ง€๋Šฅ ์ด์Šˆ..

@psychology50 psychology50 added the fix ๊ธฐ๋Šฅ ์ˆ˜์ • label Jul 25, 2024
@psychology50 psychology50 self-assigned this Jul 25, 2024
@psychology50 psychology50 merged commit 3d0b5d1 into dev Jul 25, 2024
2 checks passed
@psychology50 psychology50 deleted the fix/phone-code-key-type branch July 25, 2024 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix ๊ธฐ๋Šฅ ์ˆ˜์ •
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant