Migrate ssh keys and store them in a UserProfile table

This commit is contained in:
Magnus Hagander
2011-11-27 14:44:18 +01:00
parent e363050c75
commit 27fc2a7e3c
7 changed files with 40 additions and 7 deletions

View File

@ -2,6 +2,8 @@ from django.contrib.auth.models import User
from django.contrib.auth.backends import ModelBackend
from django.db import connection
from pgweb.core.models import UserProfile
# Special version of the authentication backend, so we can deal with migration
# of accounts from the old community login system. Once we consider all accounts
# migrated, we can remove this one and use the default backend.
@ -37,6 +39,16 @@ class AuthBackend(ModelBackend):
user.set_password(password)
user.save()
# Create a userprofile if we have to
print "Bleh"
print "\"%s\"" % rows[0][8]
if rows[0][8]:
print "Do something!"
profile = UserProfile(user=user)
profile.sshkey = rows[0][8]
print "Saved it"
profile.save()
# Now delete the user in the old system so nobody can use it
curs.execute('SELECT * FROM community_login_old_delete(%s)', (username.lower(), ))