From c6aa553f48d1014f651441bbd9e023508d0a819c Mon Sep 17 00:00:00 2001 From: jloup Date: Sun, 13 May 2018 14:10:21 +0100 Subject: Load credentials only when user requests it. --- api/const.go | 3 ++- api/const_string.go | 12 ++++++------ api/market_config.go | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'api') diff --git a/api/const.go b/api/const.go index 1f15c6e..2ad4d61 100644 --- a/api/const.go +++ b/api/const.go @@ -19,6 +19,7 @@ const ( InvalidCredentials InvalidEmail InvalidMarketCredentials + MarketCredentialsNotConfigured IPRestrictedApiKey InvalidOtp InvalidPassword @@ -36,7 +37,7 @@ func StatusToHttpCode(status Status, code ErrorCode) int { } switch code { - case BadRequest, InvalidPassword, InvalidEmail, InvalidMarketCredentials, IPRestrictedApiKey: + case BadRequest, InvalidPassword, InvalidEmail, InvalidMarketCredentials, IPRestrictedApiKey, MarketCredentialsNotConfigured: return http.StatusBadRequest case InvalidCredentials, InvalidOtp: diff --git a/api/const_string.go b/api/const_string.go index 58ed230..5af7574 100644 --- a/api/const_string.go +++ b/api/const_string.go @@ -1,8 +1,8 @@ -// Code generated by "stringer -type=Status,ErrorCode -output const_string.go"; DO NOT EDIT +// Code generated by "stringer -type=Status,ErrorCode -output const_string.go"; DO NOT EDIT. package api -import "fmt" +import "strconv" const _Status_name = "OKNOK" @@ -10,19 +10,19 @@ var _Status_index = [...]uint8{0, 2, 5} func (i Status) String() string { if i >= Status(len(_Status_index)-1) { - return fmt.Sprintf("Status(%d)", i) + return "Status(" + strconv.FormatInt(int64(i), 10) + ")" } return _Status_name[_Status_index[i]:_Status_index[i+1]] } -const _ErrorCode_name = "BadRequestEmailExistsExternalServiceTimeoutInternalErrorInvalidCredentialsInvalidEmailInvalidMarketCredentialsIPRestrictedApiKeyInvalidOtpInvalidPasswordNeedOtpValidationNotAuthorizedNotFoundOtpAlreadySetupOtpNotSetupUserNotConfirmed" +const _ErrorCode_name = "BadRequestEmailExistsExternalServiceTimeoutInternalErrorInvalidCredentialsInvalidEmailInvalidMarketCredentialsMarketCredentialsNotConfiguredIPRestrictedApiKeyInvalidOtpInvalidPasswordNeedOtpValidationNotAuthorizedNotFoundOtpAlreadySetupOtpNotSetupUserNotConfirmed" -var _ErrorCode_index = [...]uint8{0, 10, 21, 43, 56, 74, 86, 110, 128, 138, 153, 170, 183, 191, 206, 217, 233} +var _ErrorCode_index = [...]uint16{0, 10, 21, 43, 56, 74, 86, 110, 140, 158, 168, 183, 200, 213, 221, 236, 247, 263} func (i ErrorCode) String() string { i -= 3 if i >= ErrorCode(len(_ErrorCode_index)-1) { - return fmt.Sprintf("ErrorCode(%d)", i+3) + return "ErrorCode(" + strconv.FormatInt(int64(i+3), 10) + ")" } return _ErrorCode_name[_ErrorCode_index[i]:_ErrorCode_index[i+1]] } diff --git a/api/market_config.go b/api/market_config.go index e7b2341..09eb8a9 100644 --- a/api/market_config.go +++ b/api/market_config.go @@ -76,7 +76,7 @@ func (q TestMarketCredentialsQuery) Run() (interface{}, *Error) { } if config == nil || config.Config["key"] == "" || config.Config["secret"] == "" { - return nil, &Error{InvalidMarketCredentials, "no market credentials", fmt.Errorf("market credentials are empty for marketId '%v'", q.In.Market)} + return nil, &Error{MarketCredentialsNotConfigured, "no market credentials", fmt.Errorf("market credentials are empty for marketId '%v'", q.In.Market)} } resultErr := CallExternalService(fmt.Sprintf("'%s' TestCredentials", q.In.Market), EXTERNAL_SERVICE_TIMEOUT_SECONDS*time.Second, func() error { -- cgit v1.2.3