Пример #1
0
def set_seat_password(request):
    logger.debug("set_seat_password called by user %s" % request.user)
    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 SeatTasks.has_account(request.user):
            password = form.cleaned_data['password']
            logger.debug("Form contains password of length %s" % len(password))
            result = SeatManager.update_user_password(request.user.seat.username,
                                                      request.user.email,
                                                      plain_password=password)
            if result:
                messages.add_message(request, messages.SUCCESS,
                                     _('Successfully set your %(service)s password.') % SERVICE_NAME)
                logger.info("Succesfully reset SeAT password for user %s" % request.user)
                return redirect("services:services")
            else:
                messages.add_message(request, messages.ERROR,
                                     _('Failed to set your %(service)s password, please contact your administrator.') %
                                     SERVICE_NAME)
                logger.error("Failed to install custom SeAT password for user %s" % request.user)
        else:
            messages.add_message(request, messages.ERROR, _('Invalid password.'))
            logger.error("Invalid SeAT 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': 'SeAT'}
    return render(request, 'services/service_password.html', context)
Пример #2
0
def set_forum_password(request):
    logger.debug("set_forum_password called by user %s" % request.user)
    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 Phpbb3Tasks.has_account(request.user):
            password = form.cleaned_data['password']
            logger.debug("Form contains password of length %s" % len(password))
            character = request.user.profile.main_character
            result = Phpbb3Manager.update_user_password(request.user.phpbb3.username, character.character_id,
                                                        password=password)
            if result != "":
                logger.info("Successfully set forum password for user %s" % request.user)
                messages.success(request, 'Set forum password.')
            else:
                logger.error("Failed to install custom forum password for user %s" % request.user)
                messages.error(request, 'An error occurred while processing your forum account.')
            return redirect("services: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': 'Forum'}
    return render(request, 'services/service_password.html', context=context)
Пример #3
0
def set_market_password(request):
    logger.debug("set_market_password called by user %s" % request.user)
    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 MarketTasks.has_account(request.user):
            password = form.cleaned_data['password']
            logger.debug("Form contains password of length %s" % len(password))
            result = MarketManager.update_custom_password(
                request.user.market.username, password)
            if result != "":
                logger.info("Successfully reset market password for user %s" %
                            request.user)
                messages.success(request, 'Set Alliance Market password.')
            else:
                logger.error(
                    "Failed to install custom market password for user %s" %
                    request.user)
                messages.error(
                    request,
                    'An error occurred while processing your Alliance Market account.'
                )
            return redirect("services: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': 'Market'}
    return render(request, 'services/service_password.html', context=context)
Пример #4
0
def set_xenforo_password(request):
    logger.debug("set_xenforo_password called by user %s" % request.user)
    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 XenforoTasks.has_account(request.user):
            password = form.cleaned_data['password']
            logger.debug("Form contains password of length %s" % len(password))
            result = XenForoManager.update_user_password(
                request.user.xenforo.username, password)
            if result['response']['status_code'] == 200:
                logger.info("Successfully reset XenForo password for user %s" %
                            request.user)
                messages.success(request, 'Changed XenForo password.')
            else:
                logger.error(
                    "Failed to install custom XenForo password for user %s" %
                    request.user)
                messages.error(
                    request,
                    'An error occurred while processing your XenForo account.')
            return redirect('services: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': 'Forum'}
    return render(request, 'services/service_password.html', context=context)
Пример #5
0
def set_smf_password(request):
    logger.debug("set_smf_password called by user %s" % request.user)
    if request.method == 'POST':
        logger.debug("Received POST request with form.")
        form = ServicePasswordForm(request.POST)
        logger.debug("Form is valid: %s" % form.is_valid())
        character = request.user.profile.main_character
        if form.is_valid() and SmfTasks.has_account(
                request.user) and character is not None:
            password = form.cleaned_data['password']
            logger.debug("Form contains password of length %s" % len(password))
            result = SmfManager.update_user_password(request.user.smf.username,
                                                     character.character_id,
                                                     password=password)
            if result != "":
                logger.info("Successfully set smf password for user %s" %
                            request.user)
                messages.success(request, 'Set SMF password.')
            else:
                logger.error(
                    "Failed to install custom smf password for user %s" %
                    request.user)
                messages.error(
                    request,
                    'An error occurred while processing your SMF account.')
            return redirect("services: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': 'SMF'}
    return render(request, 'services/service_password.html', context=context)
Пример #6
0
def set_ips4_password(request):
    logger.debug("set_ips4_password called by user %s" % request.user)
    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 Ips4Tasks.has_account(request.user):
            password = form.cleaned_data['password']
            logger.debug("Form contains password of length %s" % len(password))
            result = Ips4Manager.update_custom_password(request.user.ips4.username, plain_password=password)
            if result != "":
                logger.info("Successfully set IPS4 password for user %s" % request.user)
                messages.success(request, 'Set IPSuite4 password.')
            else:
                logger.error("Failed to install custom IPS4 password for user %s" % request.user)
                messages.error(request, 'An error occurred while processing your IPSuite4 account.')
            return redirect('services: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': 'IPS4'}
    return render(request, 'services/service_password.html', context=context)
Пример #7
0
def set_xenforo_password(request):
    logger.debug("set_xenforo_password called by user %s" % request.user)
    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 XenforoTasks.has_account(request.user):
            password = form.cleaned_data['password']
            logger.debug("Form contains password of length %s" % len(password))
            result = XenForoManager.update_user_password(request.user.xenforo.username, password)
            if result['response']['status_code'] == 200:
                logger.info("Successfully reset XenForo password for user %s" % request.user)
                messages.success(request, 'Changed XenForo password.')
            else:
                logger.error("Failed to install custom XenForo password for user %s" % request.user)
                messages.error(request, 'An error occurred while processing your XenForo account.')
            return redirect('services: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': 'Forum'}
    return render(request, 'services/service_password.html', context=context)
Пример #8
0
def set_password(request):
    logger.debug("set_wikijs_password called by user %s" % request.user)
    if request.method == 'POST':
        logger.debug("Received POST request with form.")
        form = ServicePasswordForm(request.POST)
        logger.debug("Form is valid: %s" % form.is_valid())
        character = request.user.profile.main_character
        if form.is_valid() and WikiJSManager.user_has_account(
                request.user) and character is not None:
            password = form.cleaned_data['password']
            logger.debug("Form contains password of length %s" % len(password))
            try:
                result = WikiJSManager()._update_password(
                    request.user.wikijs.uid, password)
                if result:
                    logger.info(
                        "Successfully set Wiki.JS password for user %s" %
                        request.user)
                    messages.success(request, _('Set Wiki.JS password.'))
                else:
                    logger.error(
                        "Failed to install custom Wiki.JS password for user %s"
                        % request.user)
                    messages.error(
                        request,
                        _('An error occurred while processing your Wiki.JS account.'
                          ))
                    return redirect("services:services")
            except Exception as e:
                logger.error(
                    "Failed to install custom Wiki.JS password for user %s" %
                    request.user,
                    exc_info=1)
                messages.error(
                    request,
                    _('An error occurred while processing your Wiki.JS account.'
                      ))
            return redirect("services: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': 'Wiki.JS'}
    return render(request, 'services/service_password.html', context=context)
Пример #9
0
def set_seat_password(request):
    logger.debug("set_seat_password called by user %s" % request.user)
    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 SeatTasks.has_account(request.user):
            password = form.cleaned_data['password']
            logger.debug("Form contains password of length %s" % len(password))
            result = SeatManager.update_user_password(
                request.user.seat.username,
                request.user.email,
                plain_password=password)
            if result:
                messages.add_message(
                    request, messages.SUCCESS,
                    _('Successfully set your %(service)s password.') %
                    SERVICE_NAME)
                logger.info("Succesfully reset SeAT password for user %s" %
                            request.user)
                return redirect("services:services")
            else:
                messages.add_message(
                    request, messages.ERROR,
                    _('Failed to set your %(service)s password, please contact your administrator.'
                      ) % SERVICE_NAME)
                logger.error(
                    "Failed to install custom SeAT password for user %s" %
                    request.user)
        else:
            messages.add_message(request, messages.ERROR,
                                 _('Invalid password.'))
            logger.error("Invalid SeAT 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': 'SeAT'}
    return render(request, 'services/service_password.html', context)