Added basic mumble support

This commit is contained in:
Raynaldo Rivera
2014-10-05 16:16:11 -07:00
parent bf5a5b4bef
commit 89aa4fdcd3
10 changed files with 111 additions and 21 deletions

View File

@@ -1,34 +0,0 @@
from django.conf import settings
from django.db import connections, transaction
from openfire import UserService
class JabberManager():
def __init__(self):
pass
def add_user(self, username, password):
api = UserService(settings.OPENFIRE_ADDRESS, settings.OPENFIRE_SECRET_KEY)
print str(username)
print str(password)
api.add_user(self.__santatize_username(username), str(password))
def delete_user(self, username):
api = UserService(settings.OPENFIRE_ADDRESS, settings.OPENFIRE_SECRET_KEY)
api.delete_user(username, password)
def lock_user(self, username):
api = UserService(settings.OPENFIRE_ADDRESS, settings.OPENFIRE_SECRET_KEY)
api.lock_user(username, password)
def unlock_user(self, username):
api = UserService(settings.OPENFIRE_ADDRESS, settings.OPENFIRE_SECRET_KEY)
api.unlock_user(username, password)
def update_user_pass(self, username, password):
api = UserService(settings.OPENFIRE_ADDRESS, settings.OPENFIRE_SECRET_KEY)
api.update_user(username, password)
def __santatize_username(self, username):
sanatized = username.replace(" ","_")
return sanatized.lower()

View File

@@ -1,61 +0,0 @@
import hashlib
import random
from passlib.apps import phpbb3_context
from django.conf import settings
from django.db import connections, transaction
class Phpbb3Manager():
SQL_ADD_USER = r"INSERT INTO phpbb_users (username, username_clean, user_password, user_email, group_id , user_permissions, user_sig, user_occ, user_interests) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)"
SQL_DIS_USER = r"DELETE FROM phpbb_user_groups where user_id = (SELECT user_id FROM phpbb_users WHERE username = %s)"
SQL_CHECK_USER = r"SELECT user_id from phpbb_users WHERE username = %s"
SQL_ADD_USER_GROUP = r"INSERT INTO phpbb_user_group (group_id, user_id, user_pending) VALUES (%s, %s, %s)"
SQL_GET_GROUP = r"SELECT group_id from phpbb_groups WHERE group_name = %s"
SQL_ADD_GROUP = r"INSERT INTO phpbb_groups (group_name) VALUES (%s)"
def __init__(self):
pass
def _gen_salt(self):
return "%x" % random.randint(0, 2147483647)
def _gen_hash(self, password):
return phpbb3_context.encrypt(password)
def add_user(self, username, password, email, groups):
cursor = connections['phpbb3'].cursor()
""" Add a user """
username_clean = username.lower()
pwhash = self._gen_hash(password)
cursor.execute(self.SQL_ADD_USER, [username, username_clean, pwhash, email, 2, "", "","", ""])
self.update_groups(username,groups)
return { 'username': username, 'password': password }
def update_groups(self, username, groups):
cursor = connections['phpbb3'].cursor()
cursor.execute(self.SQL_CHECK_USER, [username])
row = cursor.fetchone()
userid = row[0]
for group in groups:
cursor.execute(self.SQL_GET_GROUP, [group])
row = cursor.fetchone()
print row
if not row:
cursor.execute(self.SQL_ADD_GROUP, [group])
cursor.execute(self.SQL_GET_GROUP, [group])
row = cursor.fetchone()
cursor.execute(self.SQL_ADD_USER_GROUP, [row[0], userid,0])
def check_user(self, username):
cursor = connections['phpbb3'].cursor()
""" Check if the username exists """
cursor.execute(self.SQL_CHECK_USER, [username])
row = cursor.fetchone()
if row:
return True
return False