From a398623d0ff1112dc7e8fa9f1c4485135cc2c1f3 Mon Sep 17 00:00:00 2001 From: donggyu Date: Wed, 31 May 2023 11:43:32 +0900 Subject: [PATCH 1/4] minor fix: change grafana endpoint url --- internal/usecase/stack.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/usecase/stack.go b/internal/usecase/stack.go index 903baaf8..fcf0e2ac 100644 --- a/internal/usecase/stack.go +++ b/internal/usecase/stack.go @@ -166,14 +166,19 @@ func (u *StackUsecase) Get(ctx context.Context, stackId domain.StackId) (out dom out.PrimaryCluster = true } - for _, appGroup := range appGroups { + appGroupsInPrimaryCluster, err := u.appGroupRepo.Fetch(domain.ClusterId(organization.PrimaryClusterId)) + if err != nil { + return out, err + } + + for _, appGroup := range appGroupsInPrimaryCluster { if appGroup.AppGroupType == domain.AppGroupType_LMA { applications, err := u.appGroupRepo.GetApplications(appGroup.ID, domain.ApplicationType_GRAFANA) if err != nil { return out, err } if len(applications) > 0 { - out.GrafanaUrl = applications[0].Endpoint + out.GrafanaUrl = applications[0].Endpoint + "/d/tks-kubernetes/tks-kubernetes-view-cluster-global?var-taco_cluster=" + cluster.ID.String() + "&kiosk" } } } From 395dc7f54756f9de73fd4b1a68ff6ea3b6196d02 Mon Sep 17 00:00:00 2001 From: donggyu Date: Wed, 31 May 2023 17:50:23 +0900 Subject: [PATCH 2/4] minor fix: add auth error code --- internal/delivery/http/auth.go | 3 +-- internal/delivery/http/user.go | 6 +----- internal/usecase/auth.go | 32 ++++++++++++++++---------------- internal/usecase/user.go | 23 +++++++++++++---------- pkg/httpErrors/errorCode.go | 4 ++++ 5 files changed, 35 insertions(+), 33 deletions(-) diff --git a/internal/delivery/http/auth.go b/internal/delivery/http/auth.go index be1f268f..fbc44e15 100644 --- a/internal/delivery/http/auth.go +++ b/internal/delivery/http/auth.go @@ -53,8 +53,7 @@ func (h *AuthHandler) Login(w http.ResponseWriter, r *http.Request) { user, err := h.usecase.Login(input.AccountId, input.Password, input.OrganizationId) if err != nil { log.ErrorfWithContext(r.Context(), "error is :%s(%T)", err.Error(), err) - - ErrorJSON(w, r, httpErrors.NewBadRequestError(err, "", "")) + ErrorJSON(w, r, err) return } diff --git a/internal/delivery/http/user.go b/internal/delivery/http/user.go index 6b73764e..21ba0960 100644 --- a/internal/delivery/http/user.go +++ b/internal/delivery/http/user.go @@ -392,11 +392,7 @@ func (u UserHandler) UpdateMyProfile(w http.ResponseWriter, r *http.Request) { err = u.usecase.ValidateAccount(requestUserInfo.GetUserId(), input.Password, requestUserInfo.GetOrganizationId()) if err != nil { log.ErrorfWithContext(r.Context(), "error is :%s(%T)", err.Error(), err) - if strings.Contains(err.Error(), "Invalid user credentials") { - ErrorJSON(w, r, httpErrors.NewUnauthorizedError(err, "A_INVALID_USER_CREDENTIAL", "")) - return - } - ErrorJSON(w, r, httpErrors.NewBadRequestError(err, "", "")) + ErrorJSON(w, r, httpErrors.NewBadRequestError(err, "A_INVALID_ID_PASSWORD", "")) return } diff --git a/internal/usecase/auth.go b/internal/usecase/auth.go index e6c71e33..1ee11729 100644 --- a/internal/usecase/auth.go +++ b/internal/usecase/auth.go @@ -109,10 +109,10 @@ func (u *AuthUsecase) Login(accountId string, password string, organizationId st // Authentication with DB user, err := u.userRepository.Get(accountId, organizationId) if err != nil { - return domain.User{}, httpErrors.NewUnauthorizedError(err, "", "") + return domain.User{}, httpErrors.NewBadRequestError(err, "A_INVALID_ID_PASSWORD", "") } if !helper.CheckPasswordHash(user.Password, password) { - return domain.User{}, httpErrors.NewUnauthorizedError(fmt.Errorf("Mismatch password"), "", "") + return domain.User{}, httpErrors.NewBadRequestError(fmt.Errorf("Mismatch password"), "A_INVALID_ID_PASSWORD", "") } var accountToken *domain.User // Authentication with Keycloak @@ -123,7 +123,7 @@ func (u *AuthUsecase) Login(accountId string, password string, organizationId st } if err != nil { //TODO: implement not found handling - return domain.User{}, httpErrors.NewUnauthorizedError(err, "", "") + return domain.User{}, httpErrors.NewBadRequestError(err, "A_INVALID_ID_PASSWORD", "") } // Insert token @@ -148,7 +148,7 @@ func (u *AuthUsecase) FindId(code string, email string, userName string, organiz users, err := u.userRepository.List(u.userRepository.OrganizationFilter(organizationId), u.userRepository.NameFilter(userName), u.userRepository.EmailFilter(email)) if err != nil && users == nil { - return "", httpErrors.NewBadRequestError(err, "", "") + return "", httpErrors.NewBadRequestError(err, "A_NO_USER", "") } if err != nil { return "", httpErrors.NewInternalServerError(err, "", "") @@ -159,13 +159,13 @@ func (u *AuthUsecase) FindId(code string, email string, userName string, organiz } emailCode, err := u.authRepository.GetEmailCode(userUuid) if err != nil { - return "", httpErrors.NewBadRequestError(err, "", "") + return "", httpErrors.NewInternalServerError(err, "", "") } - if !u.isValidEmailCode(emailCode) { - return "", httpErrors.NewBadRequestError(fmt.Errorf("invalid code"), "", "") + if !u.isExpiredEmailCode(emailCode) { + return "", httpErrors.NewBadRequestError(fmt.Errorf("expired code"), "A_EXPIRED_CODE", "") } if emailCode.Code != code { - return "", httpErrors.NewBadRequestError(fmt.Errorf("invalid code"), "", "") + return "", httpErrors.NewBadRequestError(fmt.Errorf("invalid code"), "A_MISMATCH_CODE", "") } if err := u.authRepository.DeleteEmailCode(userUuid); err != nil { return "", httpErrors.NewInternalServerError(err, "", "") @@ -179,7 +179,7 @@ func (u *AuthUsecase) FindPassword(code string, accountId string, email string, u.userRepository.AccountIdFilter(accountId), u.userRepository.NameFilter(userName), u.userRepository.EmailFilter(email)) if err != nil && users == nil { - return httpErrors.NewBadRequestError(err, "", "") + return httpErrors.NewBadRequestError(err, "A_NO_USER", "") } if err != nil { return httpErrors.NewInternalServerError(err, "", "") @@ -191,19 +191,19 @@ func (u *AuthUsecase) FindPassword(code string, accountId string, email string, } emailCode, err := u.authRepository.GetEmailCode(userUuid) if err != nil { - return httpErrors.NewBadRequestError(err, "", "") + return httpErrors.NewInternalServerError(err, "", "") } - if !u.isValidEmailCode(emailCode) { - return httpErrors.NewBadRequestError(fmt.Errorf("invalid code"), "", "") + if !u.isExpiredEmailCode(emailCode) { + return httpErrors.NewBadRequestError(fmt.Errorf("expired code"), "A_EXPIRED_CODE", "") } if emailCode.Code != code { - return httpErrors.NewBadRequestError(fmt.Errorf("invalid code"), "", "") + return httpErrors.NewBadRequestError(fmt.Errorf("invalid code"), "A_MISMATCH_CODE", "") } randomPassword := helper.GenerateRandomString(passwordLength) originUser, err := u.kc.GetUser(organizationId, accountId) if err != nil { - return err + return httpErrors.NewInternalServerError(err, "", "") } originUser.Credentials = &[]gocloak.CredentialRepresentation{ { @@ -247,7 +247,7 @@ func (u *AuthUsecase) VerifyIdentity(accountId string, email string, userName st u.userRepository.EmailFilter(email)) } if err != nil && users == nil { - return httpErrors.NewBadRequestError(err, "", "") + return httpErrors.NewBadRequestError(err, "A_NO_USER", "") } if err != nil { return httpErrors.NewInternalServerError(err, "", "") @@ -300,7 +300,7 @@ func (u *AuthUsecase) SingleSignIn(organizationId, accountId, password string) ( return cookies, nil } -func (u *AuthUsecase) isValidEmailCode(code repository.CacheEmailCode) bool { +func (u *AuthUsecase) isExpiredEmailCode(code repository.CacheEmailCode) bool { return !helper.IsDurationExpired(code.UpdatedAt, internal.EmailCodeExpireTime) } diff --git a/internal/usecase/user.go b/internal/usecase/user.go index 7090dcd6..5d234cf4 100644 --- a/internal/usecase/user.go +++ b/internal/usecase/user.go @@ -54,7 +54,7 @@ func (u *UserUsecase) RenewalPasswordExpiredTime(ctx context.Context, userId uui user, err := u.userRepository.GetByUuid(userId) if err != nil { if _, status := httpErrors.ErrorResponse(err); status != http.StatusNotFound { - return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "", "") + return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "A_NO_USER", "") } return httpErrors.NewInternalServerError(err, "", "") } @@ -72,7 +72,7 @@ func (u *UserUsecase) RenewalPasswordExpiredTimeByAccountId(ctx context.Context, user, err := u.userRepository.Get(accountId, organizationId) if err != nil { if _, status := httpErrors.ErrorResponse(err); status != http.StatusNotFound { - return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "", "") + return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "A_NO_USER", "") } return httpErrors.NewInternalServerError(err, "", "") } @@ -87,13 +87,13 @@ func (u *UserUsecase) ResetPassword(userId uuid.UUID) error { user, err := u.userRepository.GetByUuid(userId) if err != nil { if _, status := httpErrors.ErrorResponse(err); status == http.StatusNotFound { - return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "", "") + return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "A_NO_USER", "") } } userInKeycloak, err := u.kc.GetUser(user.Organization.ID, user.AccountId) if err != nil { if _, status := httpErrors.ErrorResponse(err); status == http.StatusNotFound { - return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "", "") + return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "A_NO_USER", "") } return httpErrors.NewInternalServerError(err, "", "") } @@ -128,7 +128,7 @@ func (u *UserUsecase) ResetPasswordByAccountId(accountId string, organizationId user, err := u.userRepository.Get(accountId, organizationId) if err != nil { if _, status := httpErrors.ErrorResponse(err); status == http.StatusNotFound { - return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "", "") + return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "A_NO_USER", "") } return httpErrors.NewInternalServerError(err, "", "") } @@ -142,10 +142,13 @@ func (u *UserUsecase) ResetPasswordByAccountId(accountId string, organizationId func (u *UserUsecase) ValidateAccount(userId uuid.UUID, password string, organizationId string) error { user, err := u.userRepository.GetByUuid(userId) if err != nil { - return err + return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "A_NO_USER", "") } _, err = u.kc.Login(user.AccountId, password, organizationId) - return err + if err != nil { + return httpErrors.NewBadRequestError(fmt.Errorf("invalid authentication"), "A_INVALID_ID_PASSWORD", "") + } + return nil } func (u *UserUsecase) ValidateAccountByAccountId(accountId string, password string, organizationId string) error { @@ -273,10 +276,10 @@ func (u *UserUsecase) CreateAdmin(orgainzationId string, email string) (*domain. func (u *UserUsecase) UpdatePasswordByAccountId(ctx context.Context, accountId string, originPassword string, newPassword string, organizationId string) error { if originPassword == newPassword { - return httpErrors.NewBadRequestError(fmt.Errorf("new password is same with origin password"), "", "") + return httpErrors.NewBadRequestError(fmt.Errorf("new password is same with origin password"), "A_SAME_OLD_PASSWORD", "") } if _, err := u.kc.Login(accountId, originPassword, organizationId); err != nil { - return httpErrors.NewBadRequestError(fmt.Errorf("invalid origin password"), "", "") + return httpErrors.NewBadRequestError(fmt.Errorf("invalid origin password"), "A_INVALID_ID_PASSWORD", "") } originUser, err := u.kc.GetUser(organizationId, accountId) if err != nil { @@ -331,7 +334,7 @@ func (u *UserUsecase) Get(userId uuid.UUID) (*domain.User, error) { user, err := u.userRepository.GetByUuid(userId) if err != nil { if _, status := httpErrors.ErrorResponse(err); status == http.StatusNotFound { - return nil, httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "", "") + return nil, httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "A_NO_USER", "") } return nil, err } diff --git a/pkg/httpErrors/errorCode.go b/pkg/httpErrors/errorCode.go index 9d88fbe7..640007cc 100644 --- a/pkg/httpErrors/errorCode.go +++ b/pkg/httpErrors/errorCode.go @@ -15,12 +15,16 @@ var errorMap = map[ErrorCode]string{ "C_INVALID_ASA_TASK_ID": "유효하지 않은 테스크 아이디입니다. 테스크 아이디를 확인하세요.", // Auth + "A_INVALID_ID_PASSWORD": "아이디 또는 비밀번호가 일치하지 않습니다.", + "A_SAME_OLD_PASSWORD": "기존 비밀번호와 동일합니다.", "A_INVALID_TOKEN": "사용자 토큰 오류", "A_INVALID_USER_CREDENTIAL": "비밀번호가 일치하지 않습니다.", "A_INVALID_ORIGIN_PASSWORD": "기존 비밀번호가 일치하지 않습니다.", "A_MISMATCH_PASSWORD": "비밀번호가 일치하지 않습니다.", "A_MISMATCH_CODE": "인증번호가 일치하지 않습니다.", "A_NO_SESSION": "세션 정보를 찾을 수 없습니다.", + "A_NO_USER": "해당 사용자 정보를 찾을 수 없습니다.", + "A_EXPIRED_CODE": "인증번호가 만료되었습니다.", // CloudAccount "CA_INVALID_CLIENT_TOKEN_ID": "유효하지 않은 토큰입니다. AccessKeyId, SecretAccessKey, SessionToken 을 확인후 다시 입력하세요.", From 393efa50b8f7bc89fb3d0c4f14074eff578beea7 Mon Sep 17 00:00:00 2001 From: donggyu Date: Wed, 31 May 2023 17:53:57 +0900 Subject: [PATCH 3/4] minor fix: change email format for org creation --- internal/aws/ses/ses.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/aws/ses/ses.go b/internal/aws/ses/ses.go index d2610e19..f1cce3a4 100644 --- a/internal/aws/ses/ses.go +++ b/internal/aws/ses/ses.go @@ -121,11 +121,13 @@ func SendEmailForGeneratingOrganization(client *awsSes.Client, organizationId st targetEmailAddress string, userAccountId string, randomPassword string) error { subject := "[TKS] 조직이 생성되었습니다." body := "조직이 생성되었습니다. \n" + - "조직 ID: " + organizationId + "\n" + - "조직 이름: " + organizationName + "\n\n" + - "아래 관리자 계정 정보로 로그인 후 사용바랍니다.\n" + - "관리자 ID: " + userAccountId + "\n" + - "관리자 이름: admin\n" + + "조직코드: " + organizationId + "\n" + + "이름: " + organizationName + "\n" + + "관리자 아이디: " + userAccountId + "\n" + + "관리자 이름: admin\n\n" + + "아래 관리자 계정 정보로 로그인 후 사용하시기 바랍니다.\n" + + "조직코드: " + organizationId + "\n" + + "아이디: " + userAccountId + "\n" + "비밀번호: " + randomPassword + "\n\n" + thanksContent From 3b271315414328f80a73614c6a189428c7a3678f Mon Sep 17 00:00:00 2001 From: donggyu Date: Wed, 31 May 2023 18:18:44 +0900 Subject: [PATCH 4/4] minor fix: change auth error code --- internal/delivery/http/user.go | 2 +- internal/usecase/auth.go | 12 ++++++------ internal/usecase/user.go | 18 +++++++++--------- pkg/httpErrors/errorCode.go | 7 +++++-- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/internal/delivery/http/user.go b/internal/delivery/http/user.go index 21ba0960..39e2f1d6 100644 --- a/internal/delivery/http/user.go +++ b/internal/delivery/http/user.go @@ -392,7 +392,7 @@ func (u UserHandler) UpdateMyProfile(w http.ResponseWriter, r *http.Request) { err = u.usecase.ValidateAccount(requestUserInfo.GetUserId(), input.Password, requestUserInfo.GetOrganizationId()) if err != nil { log.ErrorfWithContext(r.Context(), "error is :%s(%T)", err.Error(), err) - ErrorJSON(w, r, httpErrors.NewBadRequestError(err, "A_INVALID_ID_PASSWORD", "")) + ErrorJSON(w, r, err) return } diff --git a/internal/usecase/auth.go b/internal/usecase/auth.go index 1ee11729..1f4801b7 100644 --- a/internal/usecase/auth.go +++ b/internal/usecase/auth.go @@ -109,10 +109,10 @@ func (u *AuthUsecase) Login(accountId string, password string, organizationId st // Authentication with DB user, err := u.userRepository.Get(accountId, organizationId) if err != nil { - return domain.User{}, httpErrors.NewBadRequestError(err, "A_INVALID_ID_PASSWORD", "") + return domain.User{}, httpErrors.NewBadRequestError(err, "A_INVALID_ID", "") } if !helper.CheckPasswordHash(user.Password, password) { - return domain.User{}, httpErrors.NewBadRequestError(fmt.Errorf("Mismatch password"), "A_INVALID_ID_PASSWORD", "") + return domain.User{}, httpErrors.NewBadRequestError(fmt.Errorf("Mismatch password"), "A_INVALID_PASSWORD", "") } var accountToken *domain.User // Authentication with Keycloak @@ -123,7 +123,7 @@ func (u *AuthUsecase) Login(accountId string, password string, organizationId st } if err != nil { //TODO: implement not found handling - return domain.User{}, httpErrors.NewBadRequestError(err, "A_INVALID_ID_PASSWORD", "") + return domain.User{}, err } // Insert token @@ -148,7 +148,7 @@ func (u *AuthUsecase) FindId(code string, email string, userName string, organiz users, err := u.userRepository.List(u.userRepository.OrganizationFilter(organizationId), u.userRepository.NameFilter(userName), u.userRepository.EmailFilter(email)) if err != nil && users == nil { - return "", httpErrors.NewBadRequestError(err, "A_NO_USER", "") + return "", httpErrors.NewBadRequestError(err, "A_INVALID_ID", "") } if err != nil { return "", httpErrors.NewInternalServerError(err, "", "") @@ -179,7 +179,7 @@ func (u *AuthUsecase) FindPassword(code string, accountId string, email string, u.userRepository.AccountIdFilter(accountId), u.userRepository.NameFilter(userName), u.userRepository.EmailFilter(email)) if err != nil && users == nil { - return httpErrors.NewBadRequestError(err, "A_NO_USER", "") + return httpErrors.NewBadRequestError(err, "A_INVALID_ID", "") } if err != nil { return httpErrors.NewInternalServerError(err, "", "") @@ -247,7 +247,7 @@ func (u *AuthUsecase) VerifyIdentity(accountId string, email string, userName st u.userRepository.EmailFilter(email)) } if err != nil && users == nil { - return httpErrors.NewBadRequestError(err, "A_NO_USER", "") + return httpErrors.NewBadRequestError(err, "A_INVALID_ID", "") } if err != nil { return httpErrors.NewInternalServerError(err, "", "") diff --git a/internal/usecase/user.go b/internal/usecase/user.go index 5d234cf4..87d2a6f9 100644 --- a/internal/usecase/user.go +++ b/internal/usecase/user.go @@ -54,7 +54,7 @@ func (u *UserUsecase) RenewalPasswordExpiredTime(ctx context.Context, userId uui user, err := u.userRepository.GetByUuid(userId) if err != nil { if _, status := httpErrors.ErrorResponse(err); status != http.StatusNotFound { - return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "A_NO_USER", "") + return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "U_NO_USER", "") } return httpErrors.NewInternalServerError(err, "", "") } @@ -72,7 +72,7 @@ func (u *UserUsecase) RenewalPasswordExpiredTimeByAccountId(ctx context.Context, user, err := u.userRepository.Get(accountId, organizationId) if err != nil { if _, status := httpErrors.ErrorResponse(err); status != http.StatusNotFound { - return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "A_NO_USER", "") + return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "U_NO_USER", "") } return httpErrors.NewInternalServerError(err, "", "") } @@ -87,13 +87,13 @@ func (u *UserUsecase) ResetPassword(userId uuid.UUID) error { user, err := u.userRepository.GetByUuid(userId) if err != nil { if _, status := httpErrors.ErrorResponse(err); status == http.StatusNotFound { - return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "A_NO_USER", "") + return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "U_NO_USER", "") } } userInKeycloak, err := u.kc.GetUser(user.Organization.ID, user.AccountId) if err != nil { if _, status := httpErrors.ErrorResponse(err); status == http.StatusNotFound { - return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "A_NO_USER", "") + return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "U_NO_USER", "") } return httpErrors.NewInternalServerError(err, "", "") } @@ -128,7 +128,7 @@ func (u *UserUsecase) ResetPasswordByAccountId(accountId string, organizationId user, err := u.userRepository.Get(accountId, organizationId) if err != nil { if _, status := httpErrors.ErrorResponse(err); status == http.StatusNotFound { - return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "A_NO_USER", "") + return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "U_NO_USER", "") } return httpErrors.NewInternalServerError(err, "", "") } @@ -142,11 +142,11 @@ func (u *UserUsecase) ResetPasswordByAccountId(accountId string, organizationId func (u *UserUsecase) ValidateAccount(userId uuid.UUID, password string, organizationId string) error { user, err := u.userRepository.GetByUuid(userId) if err != nil { - return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "A_NO_USER", "") + return httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "U_NO_USER", "") } _, err = u.kc.Login(user.AccountId, password, organizationId) if err != nil { - return httpErrors.NewBadRequestError(fmt.Errorf("invalid authentication"), "A_INVALID_ID_PASSWORD", "") + return httpErrors.NewBadRequestError(fmt.Errorf("invalid password"), "A_INVALID_PASSWORD", "") } return nil } @@ -279,7 +279,7 @@ func (u *UserUsecase) UpdatePasswordByAccountId(ctx context.Context, accountId s return httpErrors.NewBadRequestError(fmt.Errorf("new password is same with origin password"), "A_SAME_OLD_PASSWORD", "") } if _, err := u.kc.Login(accountId, originPassword, organizationId); err != nil { - return httpErrors.NewBadRequestError(fmt.Errorf("invalid origin password"), "A_INVALID_ID_PASSWORD", "") + return httpErrors.NewBadRequestError(fmt.Errorf("invalid origin password"), "A_INVALID_PASSWORD", "") } originUser, err := u.kc.GetUser(organizationId, accountId) if err != nil { @@ -334,7 +334,7 @@ func (u *UserUsecase) Get(userId uuid.UUID) (*domain.User, error) { user, err := u.userRepository.GetByUuid(userId) if err != nil { if _, status := httpErrors.ErrorResponse(err); status == http.StatusNotFound { - return nil, httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "A_NO_USER", "") + return nil, httpErrors.NewBadRequestError(fmt.Errorf("user not found"), "U_NO_USER", "") } return nil, err } diff --git a/pkg/httpErrors/errorCode.go b/pkg/httpErrors/errorCode.go index 640007cc..817f994b 100644 --- a/pkg/httpErrors/errorCode.go +++ b/pkg/httpErrors/errorCode.go @@ -15,7 +15,8 @@ var errorMap = map[ErrorCode]string{ "C_INVALID_ASA_TASK_ID": "유효하지 않은 테스크 아이디입니다. 테스크 아이디를 확인하세요.", // Auth - "A_INVALID_ID_PASSWORD": "아이디 또는 비밀번호가 일치하지 않습니다.", + "A_INVALID_ID": "아이디가 존재하지 않습니다.", + "A_INVALID_PASSWORD": "비밀번호가 일치하지 않습니다.", "A_SAME_OLD_PASSWORD": "기존 비밀번호와 동일합니다.", "A_INVALID_TOKEN": "사용자 토큰 오류", "A_INVALID_USER_CREDENTIAL": "비밀번호가 일치하지 않습니다.", @@ -23,9 +24,11 @@ var errorMap = map[ErrorCode]string{ "A_MISMATCH_PASSWORD": "비밀번호가 일치하지 않습니다.", "A_MISMATCH_CODE": "인증번호가 일치하지 않습니다.", "A_NO_SESSION": "세션 정보를 찾을 수 없습니다.", - "A_NO_USER": "해당 사용자 정보를 찾을 수 없습니다.", "A_EXPIRED_CODE": "인증번호가 만료되었습니다.", + // User + "U_NO_USER": "해당 사용자 정보를 찾을 수 없습니다.", + // CloudAccount "CA_INVALID_CLIENT_TOKEN_ID": "유효하지 않은 토큰입니다. AccessKeyId, SecretAccessKey, SessionToken 을 확인후 다시 입력하세요.", "CA_INVALID_CLOUD_ACCOUNT_NAME": "유효하지 않은 클라우드계정 이름입니다. 클라우드계정 이름을 확인하세요.",