mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +00:00
Optional setting to disable the auto password generation for Service Accounts
This commit is contained in:
@@ -3,6 +3,7 @@ import re
|
||||
from django import forms
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
import settings
|
||||
from eve_api.models.api_player import EVEAccount, EVEPlayerCharacter
|
||||
from sso.models import ServiceAccount, Service
|
||||
from reddit.models import RedditAccount
|
||||
@@ -36,6 +37,12 @@ def UserServiceAccountForm(user):
|
||||
character = forms.ModelChoiceField(queryset=chars, required=True, empty_label=None)
|
||||
service = forms.ModelChoiceField(queryset=services, required=True, empty_label=None)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ServiceAccountForm, self).__init__(*args, **kwargs)
|
||||
if not settings.GENERATE_SERVICE_PASSWORD:
|
||||
self.password = forms.CharField(widget=forms.PasswordInput, label="Password" )
|
||||
self.fields['password'] = self.password
|
||||
|
||||
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']))
|
||||
|
||||
Reference in New Issue
Block a user