Updated migration 18 (fixed)

This commit is contained in:
Adolfo Gómez 2014-01-23 16:18:47 +00:00
parent 3ad2a84d55
commit 5f99877bf7
5 changed files with 26 additions and 7 deletions

View File

@ -71,6 +71,7 @@ class CryptoManager(object):
atfork()
return self._rsa.decrypt(string.decode(CryptoManager.CODEC)).encode('utf-8')
except:
logger.exception('Decripting')
return 'decript error'
def xor(self, s1, s2):

View File

@ -17,15 +17,26 @@ class Migration(DataMigration):
# and orm['appname.ModelName'] for models in other applications.
if not db.dry_run:
# Remove existing secirity values if they exists before "migrating" global ones
orm.Config.objects.filter(section=SECURITY_SECTION,key__in=configKeys).delete()
orm.Config.objects.filter(section=GLOBAL_SECTION,key__in=configKeys).update(section=SECURITY_SECTION)
for k in configKeys:
try:
o = orm.Config.objects.get(section=GLOBAL_SECTION,key=k)
orm.Config.objects.filter(section=SECURITY_SECTION,key=k).delete()
o.section = SECURITY_SECTION
o.save()
except:
pass
def backwards(self, orm):
"Write your backwards methods here."
if not db.dry_run:
# Remove existing global existing values if they exists before "migrating back" security ones
orm.Config.objects.filter(section=GLOBAL_SECTION,key__in=configKeys).delete()
orm.Config.objects.filter(section=SECURITY_SECTION,key__in=configKeys).update(section=GLOBAL_SECTION)
for k in configKeys:
try:
o = orm.Config.objects.get(section=SECURITY_SECTION,key=k)
orm.Config.objects.filter(section=GLOBAL_SECTION,key=k).delete()
o.section = GLOBAL_SECTION
o.save()
except:
pass
models = {
u'uds.authenticator': {

View File

@ -539,6 +539,10 @@ class Authenticator(models.Model):
Raises:
'''
from uds.core.auths import Authenticator as fakeAuth
if self.id is None:
return fakeAuth(self, None, values)
auType = self.getType()
env = self.getEnvironment()
auth = auType(self, env, values)

View File

@ -68,7 +68,7 @@ class BaseForm(forms.Form):
class LoginForm(BaseForm):
user = forms.CharField(label=_('Username'), max_length=64, widget=forms.TextInput())
password = forms.CharField(label=_('Password'), widget=forms.PasswordInput(attrs={'title': _('Password')}), required=False)
authenticator = forms.ChoiceField(label=_('Authenticator'), choices = (), widget=CustomSelect())
authenticator = forms.ChoiceField(label=_('Authenticator'), choices = (), widget=CustomSelect(), required=False)
java = forms.CharField(widget = forms.HiddenInput())
standard = forms.CharField(widget = forms.HiddenInput(), required=False)
nonStandard = forms.CharField(widget = forms.HiddenInput(), required=False)

View File

@ -92,7 +92,10 @@ def login(request, smallName=None):
if form.is_valid():
java = form.cleaned_data['java'] == 'y'
os = OsDetector.getOsFromUA(request.META['HTTP_USER_AGENT'])
authenticator = Authenticator.objects.get(pk=form.cleaned_data['authenticator'])
try:
authenticator = Authenticator.objects.get(pk=form.cleaned_data['authenticator'])
except:
authenticator = Authenticator()
userName = form.cleaned_data['user']
cache = Cache('auth')