mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +00:00
Fix various issues with the move to UIDs
This commit is contained in:
@@ -24,7 +24,7 @@ class ServiceUsernameField(forms.CharField):
|
|||||||
def clean(self, request, initial=None):
|
def clean(self, request, initial=None):
|
||||||
field = super(ServiceUsernameField, self).clean(request)
|
field = super(ServiceUsernameField, self).clean(request)
|
||||||
try:
|
try:
|
||||||
acc = ServiceAccount.objects.get(username=field)
|
acc = ServiceAccount.objects.get(service_uid=field)
|
||||||
except ServiceAccount.DoesNotExist:
|
except ServiceAccount.DoesNotExist:
|
||||||
return field
|
return field
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ class ServiceAccount(models.Model):
|
|||||||
password = None
|
password = None
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s: %s (%s)" % (self.service.name, self.user.username, self.username)
|
return "%s: %s (%s)" % (self.service.name, self.user.username, self.service_uid)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
""" Override default save to setup accounts as needed """
|
""" Override default save to setup accounts as needed """
|
||||||
|
|||||||
11
sso/views.py
11
sso/views.py
@@ -8,7 +8,7 @@ from eve_api.api_exceptions import APIAuthException, APINoUserIDException
|
|||||||
from eve_api.api_puller.accounts import import_eve_account
|
from eve_api.api_puller.accounts import import_eve_account
|
||||||
from eve_api.models.api_player import EVEAccount
|
from eve_api.models.api_player import EVEAccount
|
||||||
|
|
||||||
from sso.models import ServiceAccount, SSOUser
|
from sso.models import ServiceAccount, SSOUser, ExistingUser
|
||||||
from sso.forms import EveAPIForm, UserServiceAccountForm, RedditAccountForm
|
from sso.forms import EveAPIForm, UserServiceAccountForm, RedditAccountForm
|
||||||
|
|
||||||
from reddit.models import RedditAccount
|
from reddit.models import RedditAccount
|
||||||
@@ -100,11 +100,14 @@ def service_add(request):
|
|||||||
acc.username = form.cleaned_data['username']
|
acc.username = form.cleaned_data['username']
|
||||||
acc.password = form.cleaned_data['password']
|
acc.password = form.cleaned_data['password']
|
||||||
|
|
||||||
acc.save()
|
try:
|
||||||
|
acc.save()
|
||||||
|
except ExistingUser:
|
||||||
|
pass
|
||||||
return HttpResponseRedirect(reverse('sso.views.profile')) # Redirect after POST
|
return HttpResponseRedirect(reverse('sso.views.profile')) # Redirect after POST
|
||||||
else:
|
else:
|
||||||
defaults = { 'username': request.user.username, 'password': request.user.get_profile().default_service_passwd }
|
#defaults = { 'username': request.user.username, 'password': request.user.get_profile().default_service_passwd }
|
||||||
form = clsform(defaults) # An unbound form
|
form = clsform() # An unbound form
|
||||||
|
|
||||||
return render_to_response('sso/serviceaccount.html', {
|
return render_to_response('sso/serviceaccount.html', {
|
||||||
'form': form,
|
'form': form,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ a new service click the Add Service link</p>
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% for acc in srvaccounts %}
|
{% for acc in srvaccounts %}
|
||||||
<tr><td>{{ acc.service }}</td>
|
<tr><td>{{ acc.service }}</td>
|
||||||
<td>{{ acc.username }}</td>
|
<td>{{ acc.service_uid }}</td>
|
||||||
<td>******</td>
|
<td>******</td>
|
||||||
<td>{{ acc.active }}</td>
|
<td>{{ acc.active }}</td>
|
||||||
<td><a href="/profile/del/service/{{ acc.id }}/">Delete</a>
|
<td><a href="/profile/del/service/{{ acc.id }}/">Delete</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user