mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 12:30:15 +02:00
* Hooks registration, discovery and retrieval module Will discover @hooks.register decorated functions inside the auth_hooks module in any installed django app. * Class to register modular service apps * Register service modules URLs * Example service module * Refactor services into modules Each service type has been split out into its own django app/module. A hook mechanism is provided to register a subclass of the ServiceHook class. The modules then overload functions defined in ServiceHook as required to provide interoperability with alliance auth. Service modules provide their own urls and views for user registration and account management and a partial template to display on the services page. Where possible, new modules should provide their own models for local data storage. * Added menu items hooks and template tags * Added menu item hook for broadcasts * Added str method to ServicesHook * Added exception handling to hook iterators * Refactor mumble migration and table name Upgrading will require `migrate mumble --fake-initial` to be run first and then `migrate mumble` to rename the table. * Refactor teamspeak3 migration and rename table Upgrading will require `migrate teamspeak3 --fake-initial` * Added module models and migrations for refactoring AuthServicesInfo * Migrate AuthServiceInfo fields to service modules models * Added helper for getting a users main character * Added new style celery instance * Changed Discord from AuthServicesInfo to DiscordUser model * Switch celery tasks to staticmethods * Changed Discourse from AuthServicesInfo to DiscourseUser model * Changed IPBoard from AuthServicesInfo to IpboardUser model * Changed Ips4 from AuthServicesInfo to Ips4User model Also added disable service task. This service still needs some love though. Was always missing a deactivate services hook (before refactoring) for reasons I'm unsure of so I'm reluctant to add it without knowing why. * Changed Market from AuthServicesInfo to MarketUser model * Changed Mumble from AuthServicesInfo to MumbleUser model Switched user foreign key to one to one relationship. Removed implicit password change on user exists. Combined regular and blue user creation. * Changed Openfire from AuthServicesInfo to OpenfireUser model * Changed SMF from AuthServicesInfo to SmfUser model Added disable task * Changed Phpbb3 from AuthServicesInfo to Phpbb3User model * Changed XenForo from AuthServicesInfo to XenforoUser model * Changed Teamspeak3 from AuthServicesInfo to Teamspeak3User model * Remove obsolete manager functions * Standardise URL format This will break some callback URLs Discord changes from /discord_callback/ to /discord/callback/ * Removed unnecessary imports * Mirror upstream decorator change * Setup for unit testing * Unit tests for discord service * Added add main character helper * Added Discourse unit tests * Added Ipboard unit tests * Added Ips4 unit tests * Fix naming of market manager, switch to use class methods * Remove unused hook functions * Added market service unit tests * Added corp ticker to add main character helper * Added mumble unit tests * Fix url name and remove namespace * Fix missing return and add missing URL * Added openfire unit tests * Added missing return * Added phpbb3 unit tests * Fix SmfManager naming inconsistency and switch to classmethods * Added smf unit tests * Remove unused functions, Added missing return * Added xenforo unit tests * Added missing return * Fixed reference to old model * Fixed error preventing groups from syncing on reset request * Added teamspeak3 unit tests * Added nose as test runner and some test settings * Added package requirements for running tests * Added unit tests for services signals and tasks * Remove unused tests file * Fix teamspeak3 service signals * Added unit tests for teamspeak3 signals Changed other unit tests setUp to inert signals * Fix password gen and hashing python3 compatibility Fixes #630 Adds unit tests to check the password functions run on both platforms. * Fix unit test to not rely on checking url params * Add Travis CI settings file * Remove default blank values from services models * Added dynamic user model admin actions for syncing service groups * Remove unused search fields * Add hook function for syncing nicknames * Added discord hook for sync nickname * Added user admin model menu actions for sync nickname hook * Remove obsolete code * Rename celery config app to avoid package name clash * Added new style celerybeat schedule configuration periodic_task decorator is depreciated * Added string representations * Added admin pages for services user models * Removed legacy code * Move link discord button to correct template * Remove blank default fields from example model * Disallow empty django setting * Fix typos * Added coverage configuration file * Add coverage and coveralls to travis config Should probably use nose's built in coverage, but this works for now. * Replace AuthServicesInfo get_or_create instances with get Reflects upstream changes to AuthServicesInfo behaviour. * Update mumble user table name * Split out mumble authenticator requirements zeroc-ice seems to cause long build times on travis-ci and isn't required for the core projects functionality or testing.
111 lines
4.9 KiB
Python
111 lines
4.9 KiB
Python
from __future__ import unicode_literals
|
|
|
|
from django.contrib import messages
|
|
from django.contrib.auth.decorators import login_required
|
|
from django.shortcuts import render, redirect
|
|
|
|
from authentication.decorators import members_and_blues
|
|
from services.forms import ServicePasswordForm
|
|
from eveonline.managers import EveManager
|
|
|
|
from .manager import IPBoardManager
|
|
from .tasks import IpboardTasks
|
|
from .models import IpboardUser
|
|
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@login_required
|
|
@members_and_blues()
|
|
def activate_ipboard_forum(request):
|
|
logger.debug("activate_ipboard_forum called by user %s" % request.user)
|
|
character = EveManager.get_main_character(request.user)
|
|
logger.debug("Adding ipboard user for user %s with main character %s" % (request.user, character))
|
|
result = IPBoardManager.add_user(character.character_name, request.user.email)
|
|
if result[0] != "":
|
|
ipboard_user = IpboardUser()
|
|
ipboard_user.user = request.user
|
|
ipboard_user.username = result[0]
|
|
ipboard_user.save()
|
|
logger.debug("Updated authserviceinfo for user %s with ipboard credentials. Updating groups." % request.user)
|
|
IpboardTasks.update_groups.delay(request.user.pk)
|
|
logger.info("Successfully activated ipboard for user %s" % request.user)
|
|
messages.success(request, 'Activated IPBoard account.')
|
|
credentials = {
|
|
'username': result[0],
|
|
'password': result[1],
|
|
}
|
|
return render(request, 'registered/service_credentials.html',
|
|
context={'credentials': credentials, 'service': 'IPBoard'})
|
|
else:
|
|
logger.error("Unsuccessful attempt to activate ipboard for user %s" % request.user)
|
|
messages.error(request, 'An error occurred while processing your IPBoard account.')
|
|
return redirect("auth_services")
|
|
|
|
|
|
@login_required
|
|
@members_and_blues()
|
|
def deactivate_ipboard_forum(request):
|
|
logger.debug("deactivate_ipboard_forum called by user %s" % request.user)
|
|
# false we failed
|
|
if IpboardTasks.delete_user(request.user):
|
|
logger.info("Successfully deactivated ipboard for user %s" % request.user)
|
|
messages.success(request, 'Deactivated IPBoard account.')
|
|
else:
|
|
logger.error("Unsuccessful attempt to deactviate ipboard for user %s" % request.user)
|
|
messages.error(request, 'An error occurred while processing your IPBoard account.')
|
|
return redirect("auth_services")
|
|
|
|
|
|
@login_required
|
|
@members_and_blues()
|
|
def set_ipboard_password(request):
|
|
logger.debug("set_ipboard_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() and IpboardTasks.has_account(request.user):
|
|
password = form.cleaned_data['password']
|
|
logger.debug("Form contains password of length %s" % len(password))
|
|
result = IPBoardManager.update_user_password(request.user.ipboard.username, request.user.email,
|
|
plain_password=password)
|
|
if result != "":
|
|
logger.info("Successfully set IPBoard password for user %s" % request.user)
|
|
messages.success(request, 'Set IPBoard password.')
|
|
else:
|
|
logger.error("Failed to install custom ipboard password for user %s" % request.user)
|
|
messages.error(request, 'An error occurred while processing your IPBoard account.')
|
|
return redirect("auth_services")
|
|
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': 'IPBoard', 'error': error}
|
|
return render(request, 'registered/service_password.html', context=context)
|
|
|
|
|
|
@login_required
|
|
@members_and_blues()
|
|
def reset_ipboard_password(request):
|
|
logger.debug("reset_ipboard_password called by user %s" % request.user)
|
|
if IpboardTasks.has_account(request.user):
|
|
result = IPBoardManager.update_user_password(request.user.ipboard.username, request.user.email)
|
|
if result != "":
|
|
logger.info("Successfully reset ipboard password for user %s" % request.user)
|
|
messages.success(request, 'Reset IPBoard password.')
|
|
credentials = {
|
|
'username': request.user.ipboard.username,
|
|
'password': result,
|
|
}
|
|
return render(request, 'registered/service_credentials.html',
|
|
context={'credentials': credentials, 'service': 'IPBoard'})
|
|
|
|
logger.error("Unsuccessful attempt to reset ipboard password for user %s" % request.user)
|
|
messages.error(request, 'An error occurred while processing your IPBoard account.')
|
|
return redirect("auth_services")
|