mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +00:00
Add User on the Service API now returns a dict of values
This commit is contained in:
@@ -239,9 +239,11 @@ class ServiceAccount(models.Model):
|
|||||||
break
|
break
|
||||||
|
|
||||||
reddit = RedditAccount.objects.filter(user=self.user)
|
reddit = RedditAccount.objects.filter(user=self.user)
|
||||||
self.service_uid = api.add_user(self.username, self.password, user=self.user, character=self.character, eveapi=eveapi, reddit=reddit)
|
d = api.add_user(self.username, self.password, user=self.user, character=self.character, eveapi=eveapi, reddit=reddit)
|
||||||
if not self.service_uid:
|
if not d:
|
||||||
raise ServiceError('Error occured while trying to create the Service Account, please try again later')
|
raise ServiceError('Error occured while trying to create the Service Account, please try again later')
|
||||||
|
else:
|
||||||
|
self.service_uid = d['username']
|
||||||
else:
|
else:
|
||||||
raise ExistingUser('Username %s has already been took' % self.username)
|
raise ExistingUser('Username %s has already been took' % self.username)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ class BaseService():
|
|||||||
'provide_login': False }
|
'provide_login': False }
|
||||||
|
|
||||||
def add_user(self, username, password, **kwargs):
|
def add_user(self, username, password, **kwargs):
|
||||||
""" Add a user, returns a UID for that user """
|
""" Add a user, returns a dict for that user """
|
||||||
return username
|
return { 'username': username, 'password': password }
|
||||||
|
|
||||||
def check_user(self, username):
|
def check_user(self, username):
|
||||||
""" Check if the username exists """
|
""" Check if the username exists """
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class JabberService(BaseService):
|
|||||||
uid = "%s@%s" % (username.lower(), self.settings['jabber_server'])
|
uid = "%s@%s" % (username.lower(), self.settings['jabber_server'])
|
||||||
if 'user' in kwargs:
|
if 'user' in kwargs:
|
||||||
self.update_groups(uid, kwargs['user'].groups.all())
|
self.update_groups(uid, kwargs['user'].groups.all())
|
||||||
return uid
|
return { 'username': uid, 'password': password }
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class MiningBuddyService(BaseDBService):
|
|||||||
self.dbcursor.execute(self.SQL_ADD_API, [userid, int(time.time()), kwargs['eveapi'].api_user_id, kwargs['eveapi'].api_key, kwargs['character'].id])
|
self.dbcursor.execute(self.SQL_ADD_API, [userid, int(time.time()), kwargs['eveapi'].api_user_id, kwargs['eveapi'].api_key, kwargs['character'].id])
|
||||||
self.db.connection.commit()
|
self.db.connection.commit()
|
||||||
|
|
||||||
return self._clean_username(username)
|
return { 'username': self._clean_username(username), 'password': password }
|
||||||
|
|
||||||
def check_user(self, username):
|
def check_user(self, username):
|
||||||
""" Check if the username exists """
|
""" Check if the username exists """
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class MumbleService(BaseService):
|
|||||||
|
|
||||||
if self.raw_add_user(username, kwargs['user'].email, password):
|
if self.raw_add_user(username, kwargs['user'].email, password):
|
||||||
self.update_groups(username, kwargs['user'].groups.all())
|
self.update_groups(username, kwargs['user'].groups.all())
|
||||||
return username
|
return { 'username': username, 'password': password }
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class PhpBBService(BaseDBService):
|
|||||||
self._db.connection.commit()
|
self._db.connection.commit()
|
||||||
|
|
||||||
self.update_groups(username)
|
self.update_groups(username)
|
||||||
return username
|
return { 'username': username, 'password': password }
|
||||||
|
|
||||||
def update_groups(self, username):
|
def update_groups(self, username):
|
||||||
self._dbcursor.execute(self.SQL_CHECK_USER, [self._clean_username(username)])
|
self._dbcursor.execute(self.SQL_CHECK_USER, [self._clean_username(username)])
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class POSTrackerService(BaseDBService):
|
|||||||
|
|
||||||
self.dbcursor.execute(self.SQL_ADD_USER, [eveid, username, "%s%s" % (salt, pwhash) , email])
|
self.dbcursor.execute(self.SQL_ADD_USER, [eveid, username, "%s%s" % (salt, pwhash) , email])
|
||||||
self.db.connection.commit()
|
self.db.connection.commit()
|
||||||
return username
|
return { 'username': username, 'password': password }
|
||||||
|
|
||||||
def check_user(self, username):
|
def check_user(self, username):
|
||||||
""" Check if the username exists """
|
""" Check if the username exists """
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class QMSService(BaseDBService):
|
|||||||
pwhash, salt, cert = self._gen_pwhash(password)
|
pwhash, salt, cert = self._gen_pwhash(password)
|
||||||
self.dbcursor.execute(self.SQL_ADD_USER, [username, username, pwhash, salt, email, cert])
|
self.dbcursor.execute(self.SQL_ADD_USER, [username, username, pwhash, salt, email, cert])
|
||||||
self.db.connection.commit()
|
self.db.connection.commit()
|
||||||
return username
|
return { 'username': username, 'password': password }
|
||||||
|
|
||||||
def check_user(self, username):
|
def check_user(self, username):
|
||||||
""" Check if the username exists """
|
""" Check if the username exists """
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class MediawikiService(BaseDBService):
|
|||||||
pwhash = self._gen_mw_hash(password)
|
pwhash = self._gen_mw_hash(password)
|
||||||
self.dbcursor.execute(self.SQL_ADD_USER, [self._clean_username(username), pwhash, email, self.default_options])
|
self.dbcursor.execute(self.SQL_ADD_USER, [self._clean_username(username), pwhash, email, self.default_options])
|
||||||
self.db.connection.commit()
|
self.db.connection.commit()
|
||||||
return self._clean_username(username)
|
return { 'username': self._clean_username(username), 'password': password }
|
||||||
|
|
||||||
def check_user(self, username):
|
def check_user(self, username):
|
||||||
""" Check if the username exists """
|
""" Check if the username exists """
|
||||||
|
|||||||
Reference in New Issue
Block a user