mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-15 15:30:16 +02:00
Evernus Alliance Market Integration (#369)
* Added SMF Forum Support * removed comment * Fixed bugs. * removed unused SQL statement * Fixed Grammer in debug code * Fixed Null Bug * Update operationmanagement.html * fixed bug * fixed error * Users now show up on the posts correctly * Evernus Alliance Market Integration * removed duplicate function * empty string handling
This commit is contained in:
parent
cfe0e23430
commit
6f8e478baf
@ -107,6 +107,7 @@ DATABASES = {
|
|||||||
'HOST': os.environ.get('AA_DB_IPS4_HOST', '127.0.0.1'),
|
'HOST': os.environ.get('AA_DB_IPS4_HOST', '127.0.0.1'),
|
||||||
'PORT': os.environ.get('AA_DB_IPS4_PORT', '3306'),
|
'PORT': os.environ.get('AA_DB_IPS4_PORT', '3306'),
|
||||||
},
|
},
|
||||||
|
|
||||||
'smf': {
|
'smf': {
|
||||||
'ENGINE': 'django.db.backends.mysql',
|
'ENGINE': 'django.db.backends.mysql',
|
||||||
'NAME': 'alliance_smf',
|
'NAME': 'alliance_smf',
|
||||||
@ -114,6 +115,15 @@ DATABASES = {
|
|||||||
'PASSWORD': os.environ.get('AA_DB_SMF_PASSWORD', 'password'),
|
'PASSWORD': os.environ.get('AA_DB_SMF_PASSWORD', 'password'),
|
||||||
'HOST': os.environ.get('AA_DB_SMF_HOST', '127.0.0.1'),
|
'HOST': os.environ.get('AA_DB_SMF_HOST', '127.0.0.1'),
|
||||||
'PORT': os.environ.get('AA_DB_SMF_PORT', '3306'),
|
'PORT': os.environ.get('AA_DB_SMF_PORT', '3306'),
|
||||||
|
},
|
||||||
|
|
||||||
|
'market': {
|
||||||
|
'ENGINE': 'django.db.backends.mysql',
|
||||||
|
'NAME': 'alliance_market',
|
||||||
|
'USER': os.environ.get('AA_DB_MARKET_USER', 'allianceserver'),
|
||||||
|
'PASSWORD': os.environ.get('AA_DB_MARKET_PASSWORD', 'password'),
|
||||||
|
'HOST': os.environ.get('AA_DB_MARKET_HOST', '127.0.0.1'),
|
||||||
|
'PORT': os.environ.get('AA_DB_MARKET_PORT', '3306'),
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -246,6 +256,7 @@ BLUE_ALLIANCE_GROUPS = 'True' == os.environ.get('AA_BLUE_ALLIANCE_GROUPS', 'Fals
|
|||||||
# ENABLE_AUTH_DISCORD - Enable Discord support in the auth for auth'd members
|
# ENABLE_AUTH_DISCORD - Enable Discord support in the auth for auth'd members
|
||||||
# ENABLE_AUTH_IPS4 - Enable IPS4 support in the auth for auth'd members
|
# ENABLE_AUTH_IPS4 - Enable IPS4 support in the auth for auth'd members
|
||||||
# ENABLE_AUTH_SMF - Enable SMF forum support in the auth for auth'd members
|
# ENABLE_AUTH_SMF - Enable SMF forum support in the auth for auth'd members
|
||||||
|
# ENABLE_AUTH_MARKET = Enable Alliance Market support in auth for auth'd members
|
||||||
#########################
|
#########################
|
||||||
ENABLE_AUTH_FORUM = 'True' == os.environ.get('AA_ENABLE_AUTH_FORUM', 'False')
|
ENABLE_AUTH_FORUM = 'True' == os.environ.get('AA_ENABLE_AUTH_FORUM', 'False')
|
||||||
ENABLE_AUTH_JABBER = 'True' == os.environ.get('AA_ENABLE_AUTH_JABBER', 'False')
|
ENABLE_AUTH_JABBER = 'True' == os.environ.get('AA_ENABLE_AUTH_JABBER', 'False')
|
||||||
@ -255,6 +266,7 @@ ENABLE_AUTH_TEAMSPEAK3 = 'True' == os.environ.get('AA_ENABLE_AUTH_TEAMSPEAK3', '
|
|||||||
ENABLE_AUTH_DISCORD = 'True' == os.environ.get('AA_ENABLE_AUTH_DISCORD', 'False')
|
ENABLE_AUTH_DISCORD = 'True' == os.environ.get('AA_ENABLE_AUTH_DISCORD', 'False')
|
||||||
ENABLE_AUTH_IPS4 = 'True' == os.environ.get('AA_ENABLE_AUTH_IPS4', 'False')
|
ENABLE_AUTH_IPS4 = 'True' == os.environ.get('AA_ENABLE_AUTH_IPS4', 'False')
|
||||||
ENABLE_AUTH_SMF = 'True' == os.environ.get('AA_ENABLE_AUTH_SMF', 'False')
|
ENABLE_AUTH_SMF = 'True' == os.environ.get('AA_ENABLE_AUTH_SMF', 'False')
|
||||||
|
ENABLE_AUTH_MARKET = 'True' == os.environ.get('AA_ENABLE_AUTH_MARKET', 'False')
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
# Blue service Setup
|
# Blue service Setup
|
||||||
@ -267,6 +279,7 @@ ENABLE_AUTH_SMF = 'True' == os.environ.get('AA_ENABLE_AUTH_SMF', 'False')
|
|||||||
# ENABLE_BLUE_DISCORD - Enable Discord support in the auth for blues
|
# ENABLE_BLUE_DISCORD - Enable Discord support in the auth for blues
|
||||||
# ENABLE_BLUE_IPS4 - Enable IPS4 forum support in the auth for blues
|
# ENABLE_BLUE_IPS4 - Enable IPS4 forum support in the auth for blues
|
||||||
# ENABLE_BLUE_SMF - Enable SMF forum support in the auth for blues
|
# ENABLE_BLUE_SMF - Enable SMF forum support in the auth for blues
|
||||||
|
# ENABLE_BLUE_MARKET - Enable Alliance Market in the auth for blues
|
||||||
#####################
|
#####################
|
||||||
BLUE_STANDING = float(os.environ.get('AA_BLUE_STANDING', '5.0'))
|
BLUE_STANDING = float(os.environ.get('AA_BLUE_STANDING', '5.0'))
|
||||||
ENABLE_BLUE_FORUM = 'True' == os.environ.get('AA_ENABLE_BLUE_FORUM', 'False')
|
ENABLE_BLUE_FORUM = 'True' == os.environ.get('AA_ENABLE_BLUE_FORUM', 'False')
|
||||||
@ -277,6 +290,7 @@ ENABLE_BLUE_TEAMSPEAK3 = 'True' == os.environ.get('AA_ENABLE_BLUE_TEAMSPEAK3', '
|
|||||||
ENABLE_BLUE_DISCORD = 'True' == os.environ.get('AA_ENABLE_BLUE_DISCORD', 'False')
|
ENABLE_BLUE_DISCORD = 'True' == os.environ.get('AA_ENABLE_BLUE_DISCORD', 'False')
|
||||||
ENABLE_BLUE_IPS4 = 'True' == os.environ.get('AA_ENABLE_BLUE_IPS4', 'False')
|
ENABLE_BLUE_IPS4 = 'True' == os.environ.get('AA_ENABLE_BLUE_IPS4', 'False')
|
||||||
ENABLE_BLUE_SMF = 'True' == os.environ.get('AA_ENABLE_BLUE_SMF', 'False')
|
ENABLE_BLUE_SMF = 'True' == os.environ.get('AA_ENABLE_BLUE_SMF', 'False')
|
||||||
|
ENABLE_BLUE_MARKET = 'True' == os.environ.get('AA_ENABLE_BLUE_MARKET', 'False')
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
# Corp Configuration
|
# Corp Configuration
|
||||||
@ -314,6 +328,11 @@ MEMBER_API_ACCOUNT = 'True' == os.environ.get('AA_MEMBER_API_ACCOUNT', 'True')
|
|||||||
BLUE_API_MASK = os.environ.get('AA_BLUE_API_MASK', 8388608)
|
BLUE_API_MASK = os.environ.get('AA_BLUE_API_MASK', 8388608)
|
||||||
BLUE_API_ACCOUNT = 'True' == os.environ.get('AA_BLUE_API_ACCOUNT', 'False')
|
BLUE_API_ACCOUNT = 'True' == os.environ.get('AA_BLUE_API_ACCOUNT', 'False')
|
||||||
|
|
||||||
|
#####################
|
||||||
|
# Alliance Market
|
||||||
|
#####################
|
||||||
|
MARKET_URL = os.environ.get('AA_MARKET_URL', 'http://yourdomain.com/market')
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
# HR Configuration
|
# HR Configuration
|
||||||
#####################
|
#####################
|
||||||
|
@ -153,6 +153,13 @@ urlpatterns = patterns('',
|
|||||||
name='auth_reset_smf_password'),
|
name='auth_reset_smf_password'),
|
||||||
url(r'^set_smf_password/$', 'services.views.set_smf_password', name='auth_set_smf_password'),
|
url(r'^set_smf_password/$', 'services.views.set_smf_password', name='auth_set_smf_password'),
|
||||||
|
|
||||||
|
# Alliance Market Control
|
||||||
|
url(r'^activate_market/$', 'services.views.activate_market', name='auth_activate_market'),
|
||||||
|
url(r'^deactivate_market/$', 'services.views.deactivate_market', name='auth_deactivate_market'),
|
||||||
|
url(r'^reset_market_password/$', 'services.views.reset_market_password',
|
||||||
|
name='auth_reset_market_password'),
|
||||||
|
url(r'^set_market_password/$', 'services.views.set_market_password', name='auth_set_market_password'),
|
||||||
|
|
||||||
# Tools
|
# Tools
|
||||||
url(r'^tool/fleet_formatter_tool/$', 'services.views.fleet_formatter_view',
|
url(r'^tool/fleet_formatter_tool/$', 'services.views.fleet_formatter_view',
|
||||||
name='auth_fleet_format_tool_view'),
|
name='auth_fleet_format_tool_view'),
|
||||||
|
@ -146,3 +146,15 @@ class AuthServicesInfoManager:
|
|||||||
logger.info("Updated user %s smf info in authservicesinfo model." % user)
|
logger.info("Updated user %s smf info in authservicesinfo model." % user)
|
||||||
else:
|
else:
|
||||||
logger.error("Failed to update user %s smf info: user does not exist." % user)
|
logger.error("Failed to update user %s smf info: user does not exist." % user)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def update_user_market_info(username, password, user):
|
||||||
|
if User.objects.filter(username=user.username).exists():
|
||||||
|
logger.debug("Updating user %s market info: username %s" % (user, username))
|
||||||
|
authserviceinfo = AuthServicesInfoManager.__get_or_create(user)
|
||||||
|
authserviceinfo.market_username = username
|
||||||
|
authserviceinfo.market_password = password
|
||||||
|
authserviceinfo.save(update_fields=['market_username', 'market_password'])
|
||||||
|
logger.info("Updated user %s market info in authservicesinfo model." % user)
|
||||||
|
else:
|
||||||
|
logger.error("Failed to update user %s market info: user does not exist." % user)
|
||||||
|
@ -19,6 +19,8 @@ class AuthServicesInfo(models.Model):
|
|||||||
ips4_id = models.CharField(max_length=254, blank=True, default="")
|
ips4_id = models.CharField(max_length=254, blank=True, default="")
|
||||||
smf_username = models.CharField(max_length=254, blank=True, default="")
|
smf_username = models.CharField(max_length=254, blank=True, default="")
|
||||||
smf_password = models.CharField(max_length=254, blank=True, default="")
|
smf_password = models.CharField(max_length=254, blank=True, default="")
|
||||||
|
market_username = models.CharField(max_length=254, blank=True, default="")
|
||||||
|
market_password = models.CharField(max_length=254, blank=True, default="")
|
||||||
main_char_id = models.CharField(max_length=64, blank=True, default="")
|
main_char_id = models.CharField(max_length=64, blank=True, default="")
|
||||||
is_blue = models.BooleanField(default=False)
|
is_blue = models.BooleanField(default=False)
|
||||||
user = models.ForeignKey(User)
|
user = models.ForeignKey(User)
|
||||||
|
145
services/managers/market_manager.py
Normal file
145
services/managers/market_manager.py
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
import logging
|
||||||
|
from django.conf import settings
|
||||||
|
import requests
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.db import connections
|
||||||
|
from passlib.hash import bcrypt
|
||||||
|
## requires yum install libffi-devel and pip install bcrypt
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class marketManager:
|
||||||
|
|
||||||
|
SQL_ADD_USER = r"INSERT INTO fos_user (username, username_canonical, email, email_canonical, enabled, salt, password," \
|
||||||
|
r"locked, expired, roles, credentials_expired, characterid, characterName)" \
|
||||||
|
r"VALUES (%s, %s, %s, %s, 1,%s, %s, 0, 0, 'a:0:{}', 0, %s, %s) "
|
||||||
|
SQL_GET_USER_ID = r"SELECT id FROM fos_user WHERE username = %s"
|
||||||
|
SQL_DISABLE_USER = r"UPDATE fos_user SET enabled = '0' WHERE username = %s"
|
||||||
|
SQL_ENABLE_USER = r"UPDATE fos_user SET enabled = '1' WHERE username = %s"
|
||||||
|
SQL_UPDATE_PASSWORD = r"UPDATE fos_user SET password = %s, salt = %s WHERE username = %s"
|
||||||
|
SQL_CHECK_EMAIL = r"SELECT email FROM fos_user WHERE email = %s"
|
||||||
|
SQL_CHECK_USERNAME = r"SELECT username FROM fos_user WHERE username = %s"
|
||||||
|
SQL_UPDATE_USER = r"UPDATE fos_user SET password = %s, salt = %s, enabled = '1' WHERE username = %s"
|
||||||
|
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def __santatize_username(username):
|
||||||
|
sanatized = username.replace(" ", "_")
|
||||||
|
sanatized = sanatized.replace("'", "")
|
||||||
|
return sanatized.lower()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def __generate_random_pass():
|
||||||
|
return os.urandom(8).encode('hex')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def check_username(username):
|
||||||
|
logger.debug("Checking alliance market username %s" % username)
|
||||||
|
cursor = connections['market'].cursor()
|
||||||
|
cursor.execute(marketManager.SQL_CHECK_USERNAME, [marketManager.__santatize_username(username)])
|
||||||
|
row = cursor.fetchone()
|
||||||
|
if row:
|
||||||
|
logger.debug("Found user %s on alliance market" % username)
|
||||||
|
return True
|
||||||
|
logger.debug("User %s not found on alliance market" % username)
|
||||||
|
return False
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def check_user_email(username, email):
|
||||||
|
logger.debug("Checking if alliance market email exists for user %s" % username)
|
||||||
|
cursor = connections['market'].cursor()
|
||||||
|
cursor.execute(marketManager.SQL_CHECK_EMAIL, [email])
|
||||||
|
row = cursor.fetchone()
|
||||||
|
if row:
|
||||||
|
logger.debug("Found user %s email address on alliance market" % username)
|
||||||
|
return True
|
||||||
|
logger.debug("User %s email address not found on alliance market" % username)
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def add_user(username, email, characterid, charactername):
|
||||||
|
logger.debug("Adding new market user %s" % username)
|
||||||
|
plain_password = marketManager.__generate_random_pass()
|
||||||
|
hash = bcrypt.encrypt(plain_password, rounds=13)
|
||||||
|
hash_result = hash
|
||||||
|
rounds_striped = hash_result.strip('$2a$13$')
|
||||||
|
salt = rounds_striped[:22]
|
||||||
|
username_clean = marketManager.__santatize_username(username)
|
||||||
|
if marketManager.check_username(username)== False:
|
||||||
|
if marketManager.check_user_email(username, email) == False:
|
||||||
|
try:
|
||||||
|
logger.debug("Adding user %s to alliance market" % username)
|
||||||
|
cursor = connections['market'].cursor()
|
||||||
|
cursor.execute(marketManager.SQL_ADD_USER, [username_clean, username_clean, email, email, salt,
|
||||||
|
hash, characterid, charactername])
|
||||||
|
return username_clean, plain_password
|
||||||
|
except:
|
||||||
|
logger.debug("Unsuccessful attempt to add market user %s" % username)
|
||||||
|
return "", ""
|
||||||
|
else:
|
||||||
|
logger.debug("Alliance market email %s already exists Updating instead" % email)
|
||||||
|
username_clean, password = marketManager.update_user_info(username)
|
||||||
|
return username_clean, password
|
||||||
|
else:
|
||||||
|
logger.debug("Alliance market username %s already exists Updating instead" % username)
|
||||||
|
username_clean, password = marketManager.update_user_info(username)
|
||||||
|
return username_clean, password
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def disable_user(username):
|
||||||
|
logger.debug("Disabling alliance market user %s " % username)
|
||||||
|
cursor = connections['market'].cursor()
|
||||||
|
cursor.execute(marketManager.SQL_DISABLE_USER, [username])
|
||||||
|
return True
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def update_custom_password(username, plain_password):
|
||||||
|
logger.debug("Updating alliance market user %s password" % username)
|
||||||
|
if marketManager.check_username(username):
|
||||||
|
username_clean = marketManager.__santatize_username(username)
|
||||||
|
hash = bcrypt.encrypt(plain_password, rounds=13)
|
||||||
|
hash_result = hash
|
||||||
|
rounds_striped = hash_result.strip('$2a$13$')
|
||||||
|
salt = rounds_striped[:22]
|
||||||
|
cursor = connections['market'].cursor()
|
||||||
|
cursor.execute(marketManager.SQL_UPDATE_PASSWORD, [hash, salt, username_clean])
|
||||||
|
return plain_password
|
||||||
|
else:
|
||||||
|
logger.error("Unable to update alliance market user %s password" % username)
|
||||||
|
return ""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def update_user_password(username):
|
||||||
|
logger.debug("Updating alliance market user %s password" % username)
|
||||||
|
if marketManager.check_username(username):
|
||||||
|
username_clean = marketManager.__santatize_username(username)
|
||||||
|
plain_password = marketManager.__generate_random_pass()
|
||||||
|
hash = bcrypt.encrypt(plain_password, rounds=13)
|
||||||
|
hash_result = hash
|
||||||
|
rounds_striped = hash_result.strip('$2a$13$')
|
||||||
|
salt = rounds_striped[:22]
|
||||||
|
cursor = connections['market'].cursor()
|
||||||
|
cursor.execute(marketManager.SQL_UPDATE_PASSWORD, [hash, salt, username_clean])
|
||||||
|
return plain_password
|
||||||
|
else:
|
||||||
|
logger.error("Unable to update alliance market user %s password" % username)
|
||||||
|
return ""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def update_user_info(username):
|
||||||
|
logger.debug("Updating alliance market user %s" % username)
|
||||||
|
try:
|
||||||
|
username_clean = marketManager.__santatize_username(username)
|
||||||
|
plain_password = marketManager.__generate_random_pass()
|
||||||
|
hash = bcrypt.encrypt(plain_password, rounds=13)
|
||||||
|
hash_result = hash
|
||||||
|
rounds_striped = hash_result.strip('$2a$13$')
|
||||||
|
salt = rounds_striped[:22]
|
||||||
|
cursor = connections['market'].cursor()
|
||||||
|
cursor.execute(marketManager.SQL_UPDATE_USER, [hash, salt, username_clean])
|
||||||
|
return username_clean, plain_password
|
||||||
|
except:
|
||||||
|
logger.debug("Alliance market update user failed for %s" % username)
|
||||||
|
return "", ""
|
@ -16,6 +16,7 @@ from managers.teamspeak3_manager import Teamspeak3Manager
|
|||||||
from managers.discord_manager import DiscordManager
|
from managers.discord_manager import DiscordManager
|
||||||
from managers.ips4_manager import Ips4Manager
|
from managers.ips4_manager import Ips4Manager
|
||||||
from managers.smf_manager import smfManager
|
from managers.smf_manager import smfManager
|
||||||
|
from managers.market_manager import marketManager
|
||||||
from authentication.managers import AuthServicesInfoManager
|
from authentication.managers import AuthServicesInfoManager
|
||||||
from eveonline.managers import EveManager
|
from eveonline.managers import EveManager
|
||||||
from celerytask.tasks import update_jabber_groups
|
from celerytask.tasks import update_jabber_groups
|
||||||
@ -763,5 +764,84 @@ def set_smf_password(request):
|
|||||||
form = ServicePasswordForm()
|
form = ServicePasswordForm()
|
||||||
|
|
||||||
logger.debug("Rendering form for user %s" % request.user)
|
logger.debug("Rendering form for user %s" % request.user)
|
||||||
context = {'form': form, 'service': 'Forum'}
|
context = {'form': form, 'service': 'SMF'}
|
||||||
return render_to_response('registered/service_password.html', context, context_instance=RequestContext(request))
|
return render_to_response('registered/service_password.html', context, context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@user_passes_test(service_blue_alliance_test)
|
||||||
|
def activate_market(request):
|
||||||
|
logger.debug("activate_market called by user %s" % request.user)
|
||||||
|
authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
|
||||||
|
# Valid now we get the main characters
|
||||||
|
character = EveManager.get_character_by_id(authinfo.main_char_id)
|
||||||
|
logger.debug("Adding market user for user %s with main character %s" % (request.user, character))
|
||||||
|
result = marketManager.add_user(character.character_name, request.user.email, authinfo.main_char_id, character.character_name)
|
||||||
|
# if empty we failed
|
||||||
|
if result[0] != "":
|
||||||
|
AuthServicesInfoManager.update_user_market_info(result[0], result[1], request.user)
|
||||||
|
logger.debug("Updated authserviceinfo for user %s with market credentials." % request.user)
|
||||||
|
logger.info("Succesfully activated market for user %s" % request.user)
|
||||||
|
return HttpResponseRedirect("/services/")
|
||||||
|
logger.error("Unsuccesful attempt to activate market for user %s" % request.user)
|
||||||
|
return HttpResponseRedirect("/dashboard")
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@user_passes_test(service_blue_alliance_test)
|
||||||
|
def deactivate_market(request):
|
||||||
|
logger.debug("deactivate_market called by user %s" % request.user)
|
||||||
|
authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
|
||||||
|
result = marketManager.disable_user(authinfo.market_username)
|
||||||
|
# false we failed
|
||||||
|
if result:
|
||||||
|
AuthServicesInfoManager.update_user_market_info("", "", request.user)
|
||||||
|
logger.info("Succesfully deactivated market for user %s" % request.user)
|
||||||
|
return HttpResponseRedirect("/services/")
|
||||||
|
logger.error("Unsuccesful attempt to activate market for user %s" % request.user)
|
||||||
|
return HttpResponseRedirect("/dashboard")
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@user_passes_test(service_blue_alliance_test)
|
||||||
|
def reset_market_password(request):
|
||||||
|
logger.debug("reset_market_password called by user %s" % request.user)
|
||||||
|
authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
|
||||||
|
result = marketManager.update_user_password(authinfo.market_username)
|
||||||
|
# false we failed
|
||||||
|
if result != "":
|
||||||
|
AuthServicesInfoManager.update_user_market_info(authinfo.market_username, result, request.user)
|
||||||
|
logger.info("Succesfully reset market password for user %s" % request.user)
|
||||||
|
return HttpResponseRedirect("/services/")
|
||||||
|
logger.error("Unsuccessful attempt to reset market password for user %s" % request.user)
|
||||||
|
return HttpResponseRedirect("/dashboard")
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@user_passes_test(service_blue_alliance_test)
|
||||||
|
def set_market_password(request):
|
||||||
|
logger.debug("set_market_password called by user %s" % request.user)
|
||||||
|
error = None
|
||||||
|
if request.method == 'POST':
|
||||||
|
logger.debug("Received POST request with form.")
|
||||||
|
form = ServicePasswordForm(request.POST)
|
||||||
|
logger.debug("Form is valid: %s" % form.is_valid())
|
||||||
|
if form.is_valid():
|
||||||
|
password = form.cleaned_data['password']
|
||||||
|
logger.debug("Form contains password of length %s" % len(password))
|
||||||
|
authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
|
||||||
|
result = marketManager.update_custom_password(authinfo.market_username, password)
|
||||||
|
if result != "":
|
||||||
|
AuthServicesInfoManager.update_user_market_info(authinfo.market_username, result, request.user)
|
||||||
|
logger.info("Succesfully reset market password for user %s" % request.user)
|
||||||
|
return HttpResponseRedirect("/services/")
|
||||||
|
else:
|
||||||
|
logger.error("Failed to install custom market password for user %s" % request.user)
|
||||||
|
error = "Failed to install custom password."
|
||||||
|
else:
|
||||||
|
error = "Invalid password provided"
|
||||||
|
else:
|
||||||
|
logger.debug("Request is not type POST - providing empty form.")
|
||||||
|
form = ServicePasswordForm()
|
||||||
|
|
||||||
|
logger.debug("Rendering form for user %s" % request.user)
|
||||||
|
context = {'form': form, 'service': 'Market'}
|
||||||
|
return render_to_response('registered/service_password.html', context, context_instance=RequestContext(request))
|
@ -99,6 +99,33 @@
|
|||||||
{% endifequal %}
|
{% endifequal %}
|
||||||
</td>
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if ENABLE_BLUE_MARKET %}
|
||||||
|
<td class="text-center">Alliance Market</td>
|
||||||
|
<td class="text-center">{{ authinfo.market_username }}</td>
|
||||||
|
<td class="text-center">{{ authinfo.market_password }}</td>
|
||||||
|
<td class="text-center"><a href="{{ MARKET_URL }}">{{ MARKET_URL }}</a></td>
|
||||||
|
<td class="text-center">
|
||||||
|
{% ifequal authinfo.market_username "" %}
|
||||||
|
<a href="{% url 'auth_activate_market' %}">
|
||||||
|
<button type="button" class="btn btn-warning"><span
|
||||||
|
class="glyphicon glyphicon-ok"></span></button>
|
||||||
|
</a>
|
||||||
|
{% else %}
|
||||||
|
<a href="{% url 'auth_set_market_password' %}">
|
||||||
|
<button type="button" class="btn btn-warning"><span
|
||||||
|
class="glyphicon glyphicon-pencil"></span></button>
|
||||||
|
</a>
|
||||||
|
<a href="{% url 'auth_reset_market_password' %}">
|
||||||
|
<button type="button" class="btn btn-primary"><span
|
||||||
|
class="glyphicon glyphicon-refresh"></span></button>
|
||||||
|
</a>
|
||||||
|
<a href="{% url 'auth_deactivate_market' %}">
|
||||||
|
<button type="button" class="btn btn-danger"><span
|
||||||
|
class="glyphicon glyphicon-remove"></span></button>
|
||||||
|
</a>
|
||||||
|
{% endifequal %}
|
||||||
|
</td>
|
||||||
|
{% endif %}
|
||||||
{% if ENABLE_BLUE_JABBER %}
|
{% if ENABLE_BLUE_JABBER %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="text-center">Jabber</td>
|
<td class="text-center">Jabber</td>
|
||||||
@ -343,6 +370,33 @@
|
|||||||
{% endifequal %}
|
{% endifequal %}
|
||||||
</td>
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if ENABLE_AUTH_MARKET %}
|
||||||
|
<td class="text-center">Alliance Market</td>
|
||||||
|
<td class="text-center">{{ authinfo.market_username }}</td>
|
||||||
|
<td class="text-center">{{ authinfo.market_password }}</td>
|
||||||
|
<td class="text-center"><a href="{{ MARKET_URL }}">{{ MARKET_URL }}</a></td>
|
||||||
|
<td class="text-center">
|
||||||
|
{% ifequal authinfo.market_username "" %}
|
||||||
|
<a href="{% url 'auth_activate_market' %}">
|
||||||
|
<button type="button" class="btn btn-warning"><span
|
||||||
|
class="glyphicon glyphicon-ok"></span></button>
|
||||||
|
</a>
|
||||||
|
{% else %}
|
||||||
|
<a href="{% url 'auth_set_market_password' %}">
|
||||||
|
<button type="button" class="btn btn-warning"><span
|
||||||
|
class="glyphicon glyphicon-pencil"></span></button>
|
||||||
|
</a>
|
||||||
|
<a href="{% url 'auth_reset_market_password' %}">
|
||||||
|
<button type="button" class="btn btn-primary"><span
|
||||||
|
class="glyphicon glyphicon-refresh"></span></button>
|
||||||
|
</a>
|
||||||
|
<a href="{% url 'auth_deactivate_market' %}">
|
||||||
|
<button type="button" class="btn btn-danger"><span
|
||||||
|
class="glyphicon glyphicon-remove"></span></button>
|
||||||
|
</a>
|
||||||
|
{% endifequal %}
|
||||||
|
</td>
|
||||||
|
{% endif %}
|
||||||
{% if ENABLE_AUTH_JABBER %}
|
{% if ENABLE_AUTH_JABBER %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="text-center">Jabber</td>
|
<td class="text-center">Jabber</td>
|
||||||
|
@ -39,6 +39,7 @@ def domain_url(request):
|
|||||||
'ENABLE_AUTH_DISCORD': settings.ENABLE_AUTH_DISCORD,
|
'ENABLE_AUTH_DISCORD': settings.ENABLE_AUTH_DISCORD,
|
||||||
'ENABLE_AUTH_IPS4': settings.ENABLE_AUTH_IPS4,
|
'ENABLE_AUTH_IPS4': settings.ENABLE_AUTH_IPS4,
|
||||||
'ENABLE_AUTH_SMF': settings.ENABLE_AUTH_SMF,
|
'ENABLE_AUTH_SMF': settings.ENABLE_AUTH_SMF,
|
||||||
|
'ENABLE_AUTH_MARKET': settings.ENABLE_AUTH_MARKET,
|
||||||
'ENABLE_BLUE_JABBER': settings.ENABLE_BLUE_JABBER,
|
'ENABLE_BLUE_JABBER': settings.ENABLE_BLUE_JABBER,
|
||||||
'ENABLE_BLUE_FORUM': settings.ENABLE_BLUE_FORUM,
|
'ENABLE_BLUE_FORUM': settings.ENABLE_BLUE_FORUM,
|
||||||
'ENABLE_BLUE_MUMBLE': settings.ENABLE_BLUE_MUMBLE,
|
'ENABLE_BLUE_MUMBLE': settings.ENABLE_BLUE_MUMBLE,
|
||||||
@ -47,11 +48,13 @@ def domain_url(request):
|
|||||||
'ENABLE_BLUE_DISCORD': settings.ENABLE_BLUE_DISCORD,
|
'ENABLE_BLUE_DISCORD': settings.ENABLE_BLUE_DISCORD,
|
||||||
'ENABLE_BLUE_IPS4': settings.ENABLE_BLUE_IPS4,
|
'ENABLE_BLUE_IPS4': settings.ENABLE_BLUE_IPS4,
|
||||||
'ENABLE_BLUE_SMF': settings.ENABLE_BLUE_SMF,
|
'ENABLE_BLUE_SMF': settings.ENABLE_BLUE_SMF,
|
||||||
|
'ENABLE_BLUE_MARKET': settings.ENABLE_BLUE_MARKET,
|
||||||
'TEAMSPEAK3_PUBLIC_URL': settings.TEAMSPEAK3_PUBLIC_URL,
|
'TEAMSPEAK3_PUBLIC_URL': settings.TEAMSPEAK3_PUBLIC_URL,
|
||||||
'JACK_KNIFE_URL': settings.JACK_KNIFE_URL,
|
'JACK_KNIFE_URL': settings.JACK_KNIFE_URL,
|
||||||
'DISCORD_SERVER_ID': settings.DISCORD_SERVER_ID,
|
'DISCORD_SERVER_ID': settings.DISCORD_SERVER_ID,
|
||||||
'KILLBOARD_URL': settings.KILLBOARD_URL,
|
'KILLBOARD_URL': settings.KILLBOARD_URL,
|
||||||
'IPS4_URL': settings.IPS4_URL,
|
'IPS4_URL': settings.IPS4_URL,
|
||||||
'SMF_URL': settings.SMF_URL,
|
'SMF_URL': settings.SMF_URL,
|
||||||
|
'MARKET_URL': settings.MARKET_URL,
|
||||||
'EXTERNAL_MEDIA_URL': settings.EXTERNAL_MEDIA_URL,
|
'EXTERNAL_MEDIA_URL': settings.EXTERNAL_MEDIA_URL,
|
||||||
'CURRENT_UTC_TIME': timezone.now()}
|
'CURRENT_UTC_TIME': timezone.now()}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user