Skip to content

Commit 82cac50

Browse files
committed
cache only successfull auth
1 parent 909432b commit 82cac50

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

internal/services/auth-provider.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ func (a *AuthProvider) LoginVia(ctx context.Context, ip, domain, via string) err
9999
defer resp.Body.Close()
100100
ok := resp.StatusCode == http.StatusOK
101101
if !ok {
102-
a.cacheAllowed.Add(ip, false)
103102
return nil
104103
}
105104

@@ -113,10 +112,11 @@ func (a *AuthProvider) LoginVia(ctx context.Context, ip, domain, via string) err
113112
return err
114113
}
115114
if len(result) == 0 {
116-
a.cacheAllowed.Add(ip, false)
117115
return nil
118116
}
119117
hash := kit.Hash(result[0].Labels["domain"] + result[0].Labels["subscription_provider"] + result[0].Labels["order_issue_id"])
120-
a.cacheAllowed.Add(ip, hash == via)
118+
if hash == via {
119+
a.cacheAllowed.Add(ip, true)
120+
}
121121
return nil
122122
}

0 commit comments

Comments
 (0)