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)
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 = EveManager.get_main_character(request.user) 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("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': 'Forum'} return render(request, 'registered/service_password.html', context=context)
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("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': 'Market'} return render(request, 'registered/service_password.html', context=context)
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('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': 'Forum'} return render(request, 'registered/service_password.html', context=context)
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("auth_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, 'registered/service_password.html', context)
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: logger.info("Succesfully reset SeAT password for user %s" % request.user) return redirect("auth_services") else: logger.error( "Failed to install custom SeAT password for user %s" % request.user) else: 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, 'registered/service_password.html', context)
def set_forum_password(request): logger.debug("set_forum_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(EVECharacter.objects.get(user=request.user).user_id) char_id = EVECharacter.objects.get(user=request.user).user_id result = Phpbb3Manager.update_user_password(authinfo.forum_username, authinfo.char_id, password=password) if result != "": AuthServicesInfoManager.update_user_forum_info(authinfo.forum_username, result, char_id) logger.info("Succesfully reset forum password for user %s" % request.user) return HttpResponseRedirect("/services/") else: logger.error("Failed to install custom forum 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': 'Forum'} return render_to_response('registered/services/service_password.html', context, context_instance=RequestContext(request))
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 = EveManager.get_main_character(request.user) 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("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': 'SMF'} return render(request, 'registered/service_password.html', context=context)
def mumble_password(request, mumble_id): logger.debug("mumble_password called by user %s for mumble_id %s" % (request.user, mumble_id)) m = get_object_or_404(MumbleService, pk=mumble_id) try: if request.method == "POST": form = ServicePasswordForm(request.POST) if form.is_valid(): password = form.cleaned_data['password'] credentials = m.set_password(request.user, password) return render(request, 'registered/services/credentials.html', context={ 'credentials': credentials, 'next': 'mumble_list' }) else: form = ServicePasswordForm() return render(request, 'public/form.html', context={ 'title': m.name, 'form': form, 'button_text': 'Submit' }) except services.errors.UserNotActiveError: logger.warn( "Unable to deactivate user %s mumble %s - user does not have account on service" % (request.user, m)) return rediect('mumble_list')
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('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': 'IPS4'} return render(request, 'registered/service_password.html', context=context)
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('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': 'Forum'} return render(request, 'registered/service_password.html', context=context)
def mumble_password(request, mumble_id): logger.debug("mumble_password called by user %s for mumble_id %s" % (request.user, mumble_id)) m = get_object_or_404(MumbleService, pk=mumble_id) try: if request.method == "POST": form = ServicePasswordForm(request.POST) if form.is_valid(): password = form.cleaned_data['password'] credentials = m.set_password(request.user, password) return render(request, 'registered/services/credentials.html', context={'credentials':credentials, 'next': 'mumble_list'}) else: form = ServicePasswordForm() return render(request, 'public/form.html', context={'title': m.name, 'form': form, 'button_text':'Submit'}) except services.errors.UserNotActiveError: logger.warn("Unable to deactivate user %s mumble %s - user does not have account on service" % (request.user, m)) return rediect('mumble_list')