mirror of
https://github.com/nikdoof/test-auth.git
synced 2026-01-30 16:08:14 +00:00
Fixed a issue with duplicate services appearing to people in corps and alliances with perms
This commit is contained in:
18
sso/forms.py
18
sso/forms.py
@@ -33,8 +33,10 @@ class EveAPIForm(forms.Form):
|
|||||||
def UserServiceAccountForm(user):
|
def UserServiceAccountForm(user):
|
||||||
""" Generate a Service Account form based on the user's permissions """
|
""" Generate a Service Account form based on the user's permissions """
|
||||||
|
|
||||||
services = Service.objects.filter(groups__in=user.groups.all()).exclude(id__in=ServiceAccount.objects.filter(user=user).values('service'))
|
services = Service.objects.filter(groups__in=user.groups.all()).exclude(id__in=ServiceAccount.objects.filter(user=user).values('service')).distinct()
|
||||||
chars = EVEPlayerCharacter.objects.filter(corporation__group__in=user.groups.all(),eveaccount__user=user)
|
chars = EVEPlayerCharacter.objects.filter(eveaccount__user=user)
|
||||||
|
|
||||||
|
print len(services)
|
||||||
|
|
||||||
class ServiceAccountForm(forms.Form):
|
class ServiceAccountForm(forms.Form):
|
||||||
""" Service Account Form """
|
""" Service Account Form """
|
||||||
@@ -49,8 +51,16 @@ def UserServiceAccountForm(user):
|
|||||||
self.fields['password'] = self.password
|
self.fields['password'] = self.password
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
if not self.cleaned_data['character'].corporation.group in self.cleaned_data['service'].groups.all():
|
|
||||||
raise forms.ValidationError("%s is not in a corporation allowed to access %s" % (self.cleaned_data['character'].name, self.cleaned_data['service']))
|
corp_group = self.cleaned_data['character'].corporation.group
|
||||||
|
if self.cleaned_data['character'].corporation.alliance:
|
||||||
|
alliance_group = self.cleaned_data['character'].corporation.alliance.group
|
||||||
|
else:
|
||||||
|
alliance_group = None
|
||||||
|
service_groups = self.cleaned_data['service'].groups.all()
|
||||||
|
|
||||||
|
if not (corp_group in service_groups or alliance_group in service_groups):
|
||||||
|
raise forms.ValidationError("%s is not in a corporation or alliance allowed to register for %s" % (self.cleaned_data['character'].name, self.cleaned_data['service']))
|
||||||
|
|
||||||
return self.cleaned_data
|
return self.cleaned_data
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user