mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 14:52:15 +00:00
Added commit to the base class
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import connections
|
from django.db import connections, transaction
|
||||||
|
|
||||||
def get_api(api):
|
def get_api(api):
|
||||||
|
|
||||||
@@ -82,3 +82,6 @@ class BaseDBService(BaseService):
|
|||||||
self._dbcursor = self.db.cursor()
|
self._dbcursor = self.db.cursor()
|
||||||
return self._dbcursor
|
return self._dbcursor
|
||||||
|
|
||||||
|
def commit(self):
|
||||||
|
transaction.commit_unless_managed(using=self.settings['database_name'])
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class MumbleSQLService(BaseDBService):
|
|||||||
userid = self.dbcursor.fetchone()[0]
|
userid = self.dbcursor.fetchone()[0]
|
||||||
|
|
||||||
self.dbcursor.execute(self.SQL_ADD_USER, [self.settings['server_id'], userid, username, self._gen_pwhash(password)])
|
self.dbcursor.execute(self.SQL_ADD_USER, [self.settings['server_id'], userid, username, self._gen_pwhash(password)])
|
||||||
transaction.commit_unless_managed()
|
self.commit()
|
||||||
return { 'username': username, 'password': password }
|
return { 'username': username, 'password': password }
|
||||||
|
|
||||||
def check_user(self, username):
|
def check_user(self, username):
|
||||||
@@ -67,13 +67,13 @@ class MumbleSQLService(BaseDBService):
|
|||||||
def disable_user(self, uid):
|
def disable_user(self, uid):
|
||||||
""" Disable a user """
|
""" Disable a user """
|
||||||
self.dbcursor.execute(self.SQL_DIS_USER, [uid])
|
self.dbcursor.execute(self.SQL_DIS_USER, [uid])
|
||||||
transaction.commit_unless_managed()
|
self.commit()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def enable_user(self, uid, password):
|
def enable_user(self, uid, password):
|
||||||
""" Enable a user """
|
""" Enable a user """
|
||||||
self.dbcursor.execute(self.SQL_ENABLE_USER, [self._gen_pwhash(password), uid])
|
self.dbcursor.execute(self.SQL_ENABLE_USER, [self._gen_pwhash(password), uid])
|
||||||
transaction.commit_unless_managed()
|
self.commit()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def reset_password(self, uid, password):
|
def reset_password(self, uid, password):
|
||||||
|
|||||||
Reference in New Issue
Block a user