OAuth: fix duplicate devices

This commit is contained in:
andig 2025-11-16 15:25:22 +01:00
parent dca1a7b8e3
commit daa26bf726

View file

@ -106,7 +106,7 @@ func NewOauth(ctx context.Context, name, device string, oc *oauth2.Config, opts
// reuse instance
if instance := getInstance(subject); instance != nil {
if device != "" {
if device != "" && !slices.Contains(instance.devices, device) {
instance.devices = append(instance.devices, device)
}
return instance, nil
@ -126,14 +126,14 @@ func NewOauth(ctx context.Context, name, device string, oc *oauth2.Config, opts
name: name,
}
if device != "" && !slices.Contains(o.devices, device) {
o.devices = append(o.devices, device)
}
for _, opt := range opts {
opt(o)
}
if device != "" {
o.devices = []string{device}
}
// load token from db
var token oauth2.Token
if settings.Exists(o.subject) {