aboutsummaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorjloup <jloup@jloup.work>2018-05-13 14:10:21 +0100
committerjloup <jloup@jloup.work>2018-05-13 14:10:21 +0100
commitc6aa553f48d1014f651441bbd9e023508d0a819c (patch)
treebb9af139ba3d8d4c9cc74114473e03eaef0d9004 /api
parenta7873be28f3bcda36dd9fc54df238738c4c2b998 (diff)
downloadFront-c6aa553f48d1014f651441bbd9e023508d0a819c.tar.gz
Front-c6aa553f48d1014f651441bbd9e023508d0a819c.tar.zst
Front-c6aa553f48d1014f651441bbd9e023508d0a819c.zip
Load credentials only when user requests it.
Diffstat (limited to 'api')
-rw-r--r--api/const.go3
-rw-r--r--api/const_string.go12
-rw-r--r--api/market_config.go2
3 files changed, 9 insertions, 8 deletions
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 (
19 InvalidCredentials 19 InvalidCredentials
20 InvalidEmail 20 InvalidEmail
21 InvalidMarketCredentials 21 InvalidMarketCredentials
22 MarketCredentialsNotConfigured
22 IPRestrictedApiKey 23 IPRestrictedApiKey
23 InvalidOtp 24 InvalidOtp
24 InvalidPassword 25 InvalidPassword
@@ -36,7 +37,7 @@ func StatusToHttpCode(status Status, code ErrorCode) int {
36 } 37 }
37 38
38 switch code { 39 switch code {
39 case BadRequest, InvalidPassword, InvalidEmail, InvalidMarketCredentials, IPRestrictedApiKey: 40 case BadRequest, InvalidPassword, InvalidEmail, InvalidMarketCredentials, IPRestrictedApiKey, MarketCredentialsNotConfigured:
40 return http.StatusBadRequest 41 return http.StatusBadRequest
41 42
42 case InvalidCredentials, InvalidOtp: 43 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 @@
1// Code generated by "stringer -type=Status,ErrorCode -output const_string.go"; DO NOT EDIT 1// Code generated by "stringer -type=Status,ErrorCode -output const_string.go"; DO NOT EDIT.
2 2
3package api 3package api
4 4
5import "fmt" 5import "strconv"
6 6
7const _Status_name = "OKNOK" 7const _Status_name = "OKNOK"
8 8
@@ -10,19 +10,19 @@ var _Status_index = [...]uint8{0, 2, 5}
10 10
11func (i Status) String() string { 11func (i Status) String() string {
12 if i >= Status(len(_Status_index)-1) { 12 if i >= Status(len(_Status_index)-1) {
13 return fmt.Sprintf("Status(%d)", i) 13 return "Status(" + strconv.FormatInt(int64(i), 10) + ")"
14 } 14 }
15 return _Status_name[_Status_index[i]:_Status_index[i+1]] 15 return _Status_name[_Status_index[i]:_Status_index[i+1]]
16} 16}
17 17
18const _ErrorCode_name = "BadRequestEmailExistsExternalServiceTimeoutInternalErrorInvalidCredentialsInvalidEmailInvalidMarketCredentialsIPRestrictedApiKeyInvalidOtpInvalidPasswordNeedOtpValidationNotAuthorizedNotFoundOtpAlreadySetupOtpNotSetupUserNotConfirmed" 18const _ErrorCode_name = "BadRequestEmailExistsExternalServiceTimeoutInternalErrorInvalidCredentialsInvalidEmailInvalidMarketCredentialsMarketCredentialsNotConfiguredIPRestrictedApiKeyInvalidOtpInvalidPasswordNeedOtpValidationNotAuthorizedNotFoundOtpAlreadySetupOtpNotSetupUserNotConfirmed"
19 19
20var _ErrorCode_index = [...]uint8{0, 10, 21, 43, 56, 74, 86, 110, 128, 138, 153, 170, 183, 191, 206, 217, 233} 20var _ErrorCode_index = [...]uint16{0, 10, 21, 43, 56, 74, 86, 110, 140, 158, 168, 183, 200, 213, 221, 236, 247, 263}
21 21
22func (i ErrorCode) String() string { 22func (i ErrorCode) String() string {
23 i -= 3 23 i -= 3
24 if i >= ErrorCode(len(_ErrorCode_index)-1) { 24 if i >= ErrorCode(len(_ErrorCode_index)-1) {
25 return fmt.Sprintf("ErrorCode(%d)", i+3) 25 return "ErrorCode(" + strconv.FormatInt(int64(i+3), 10) + ")"
26 } 26 }
27 return _ErrorCode_name[_ErrorCode_index[i]:_ErrorCode_index[i+1]] 27 return _ErrorCode_name[_ErrorCode_index[i]:_ErrorCode_index[i+1]]
28} 28}
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) {
76 } 76 }
77 77
78 if config == nil || config.Config["key"] == "" || config.Config["secret"] == "" { 78 if config == nil || config.Config["key"] == "" || config.Config["secret"] == "" {
79 return nil, &Error{InvalidMarketCredentials, "no market credentials", fmt.Errorf("market credentials are empty for marketId '%v'", q.In.Market)} 79 return nil, &Error{MarketCredentialsNotConfigured, "no market credentials", fmt.Errorf("market credentials are empty for marketId '%v'", q.In.Market)}
80 } 80 }
81 81
82 resultErr := CallExternalService(fmt.Sprintf("'%s' TestCredentials", q.In.Market), EXTERNAL_SERVICE_TIMEOUT_SECONDS*time.Second, func() error { 82 resultErr := CallExternalService(fmt.Sprintf("'%s' TestCredentials", q.In.Market), EXTERNAL_SERVICE_TIMEOUT_SECONDS*time.Second, func() error {