Skip to content

Commit

Permalink
feat: Json Rpc 컨트롤러에 대부분의 state 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
HyungJu committed May 6, 2024
1 parent 0e5eaa8 commit 5faee53
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions apps/server/src/password-reset/password-reset.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ContextFactory } from './context.factory';
import { RedisContextRepositoryImpl } from './redis-context.repository';
import { StateType } from './password-reset.state';
import {
Body,
JsonRpcController,
Expand Down Expand Up @@ -29,15 +28,31 @@ export class PasswordResetController {
const validation = ResetPasswordRequest.decode(body);
if (isLeft(validation))
throw new DomainException(ErrorCode.VALIDATION_ERROR, validation.left);
const context = this.factory.createInitialState('형주');
return context.requestPasswordChange(validation.right);
}

const context = this.factory.create(StateType.REQUEST_PASSWORD_RESET, {
stateType: StateType.INITIAL.toString(),
memberId: '형주',
requestInfo: null,
secureNoImage: null,
twoWayInfo: null,
});
@JsonRpcMethod('requestSecureNoImage')
async requestSecureNoImage(@Req req: Request) {
const context = await this.repository.findByUserId('형주');
return context.requestSecureNoImage();
}

return context.requestPasswordChange(validation.right);
@JsonRpcMethod('inputSecureNo')
async inputSecureNo(@Body body: { secureNo: string }, @Req req: Request) {
const context = await this.repository.findByUserId('형주');
return context.inputSecureNo(body.secureNo);
}

@JsonRpcMethod('inputSMSCode')
async inputSMSCode(@Body body: { smsCode: string }, @Req req: Request) {
const context = await this.repository.findByUserId('형주');
return context.inputSMSCode(body.smsCode);
}

@JsonRpcMethod('changePassword')
async changePassword(@Req req: Request) {
const context = await this.repository.findByUserId('형주');
return context.changePassword();
}
}

0 comments on commit 5faee53

Please sign in to comment.