Skip to content

Commit

Permalink
feat: 비밀번호 변경 실패시 예외 throw
Browse files Browse the repository at this point in the history
  • Loading branch information
HyungJu committed May 6, 2024
1 parent 6fdaa93 commit db46766
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,18 @@ export class Mapper {
};
}
} else {
throw new Error();
if (response.data.resRegistrationStatus == '0') {
return {
type: 'PasswordChangeFailed',
userId: response.data.resLoginId,
result: response.data.resResultDesc,
};
} else {
return {
type: 'PasswordChanged',
userId: response.data.resLoginId,
};
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ export type CodefSMSResponse = t.TypeOf<typeof CodefSMSResponse>;

export const CodefPasswordChangedResponse = CodefResponse(
t.type({
userId: t.string,
resLoginId: t.string,
resRegistrationStatus: t.string,
resResultDesc: t.string,
})
);

Expand Down
17 changes: 12 additions & 5 deletions apps/server/src/nip/strategies/resetPassword/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ export type NipSecureNoResponse = NipResetPasswordBaseResponse<'SecureNo'> & {

export type NipSMSResponse = NipResetPasswordBaseResponse<'SMS'>;

export type PasswordChangedResponse =
NipResetPasswordBaseResponse<'PasswordChanged'> & {
userId: string;
};
export type NipPasswordChangedResponse = {
type: 'PasswordChanged';
userId: string;
};

export type NipPasswordChangeFailedResponse = {
type: 'PasswordChangeFailed';
userId?: string;
result: string;
};

export type NipResetPasswordResponse =
| NipSecureNoResponse
| NipSMSResponse
| PasswordChangedResponse;
| NipPasswordChangedResponse
| NipPasswordChangeFailedResponse;
5 changes: 5 additions & 0 deletions apps/server/src/password-reset/states/SMSState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Injectable } from '@nestjs/common';

import { NipService } from '../../nip/nip.service';
import { ResetPasswordRequest } from '../types/reset-password.request';
import { DomainException } from '../../exception/domain-exception';
import { ErrorCode } from '../../exception/error';

@Injectable()
export class SMSState extends PasswordResetState {
Expand Down Expand Up @@ -31,6 +33,9 @@ export class SMSState extends PasswordResetState {
twoWayInfo: this.context.data.twoWayInfo,
});

if (response.type == 'PasswordChangeFailed') {
throw new DomainException(ErrorCode.CODEF_ERROR, response.result);
}
return true;
}
}

0 comments on commit db46766

Please sign in to comment.