Skip to content

Commit 04b8a33

Browse files
committed
update to/from remote config for web3 solana
1 parent 56aed55 commit 04b8a33

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

pkg/config/auth.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ func (a *auth) ToUpdateAuthConfigBody() v1API.UpdateAuthConfigBody {
304304
a.Email.toAuthConfigBody(&body)
305305
a.Sms.toAuthConfigBody(&body)
306306
a.External.toAuthConfigBody(&body)
307+
a.Web3.toAuthConfigBody(&body)
307308
return body
308309
}
309310

@@ -330,6 +331,7 @@ func (a *auth) FromRemoteAuthConfig(remoteConfig v1API.AuthConfigResponse) {
330331
a.Email.fromAuthConfig(remoteConfig)
331332
a.Sms.fromAuthConfig(remoteConfig)
332333
a.External.fromAuthConfig(remoteConfig)
334+
a.Web3.fromAuthConfig(remoteConfig)
333335
}
334336

335337
func (r rateLimit) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) {
@@ -339,6 +341,7 @@ func (r rateLimit) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) {
339341
body.RateLimitVerify = cast.Ptr(cast.UintToInt(r.TokenVerifications))
340342
// Email rate limit is only updated when SMTP is enabled
341343
body.RateLimitSmsSent = cast.Ptr(cast.UintToInt(r.SmsSent))
344+
body.RateLimitWeb3 = cast.Ptr(cast.UintToInt(r.Web3))
342345
}
343346

344347
func (r *rateLimit) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) {
@@ -348,6 +351,7 @@ func (r *rateLimit) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) {
348351
r.TokenVerifications = cast.IntToUint(cast.Val(remoteConfig.RateLimitVerify, 0))
349352
// Email rate limit is only updated when SMTP is enabled
350353
r.SmsSent = cast.IntToUint(cast.Val(remoteConfig.RateLimitSmsSent, 0))
354+
r.Web3 = cast.IntToUint(cast.Val(remoteConfig.Web3, 0))
351355
}
352356

353357
func (c captcha) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) {
@@ -1149,3 +1153,25 @@ func (a *auth) DiffWithRemote(remoteConfig v1API.AuthConfigResponse) ([]byte, er
11491153
}
11501154
return diff.Diff("remote[auth]", remoteCompare, "local[auth]", currentValue), nil
11511155
}
1156+
1157+
func (w web3) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) {
1158+
w.solana.toAuthConfigBody(body)
1159+
body.RateLimitAnonymousUsers = cast.Ptr(cast.UintToInt(r.AnonymousUsers))
1160+
body.RateLimitTokenRefresh = cast.Ptr(cast.UintToInt(r.TokenRefresh))
1161+
body.RateLimitOtp = cast.Ptr(cast.UintToInt(r.SignInSignUps))
1162+
body.RateLimitVerify = cast.Ptr(cast.UintToInt(r.TokenVerifications))
1163+
// Email rate limit is only updated when SMTP is enabled
1164+
body.RateLimitSmsSent = cast.Ptr(cast.UintToInt(r.SmsSent))
1165+
}
1166+
1167+
func (w *web3) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) {
1168+
w.solana.fromAuthConfig(remoteConfig)
1169+
}
1170+
1171+
func (s solana) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) {
1172+
body.ExternalWeb3SolanaEnabled = s.Enabled
1173+
}
1174+
1175+
func (s *solana) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) {
1176+
s.Enabled = remoteConfig.ExternalWeb3SolanaEnabled
1177+
}

0 commit comments

Comments
 (0)