示例#1
0
def set_ips4_password(request):
    logger.debug("set_ips4_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 = Ips4Manager.update_custom_password(authinfo.ips4_username, plain_password=password)
            member_id = Ips4Manager.get_user_id(authinfo.ips4_username)
            if result != "":
                AuthServicesInfoManager.update_user_ips4_info(authinfo.ips4_username, result, member_id, request.user)
                logger.info("Succesfully reset IPS4 password for user %s" % request.user)
                return HttpResponseRedirect("/services/")
            else:
                logger.error("Failed to install custom IPS4 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': 'IPS4', 'error': error}
    return render_to_response('registered/service_password.html', context, context_instance=RequestContext(request))
示例#2
0
def deactivate_ips4(request):
    logger.debug("deactivate_ips4 called by user %s" % request.user)
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = Ips4Manager.delete_user(authinfo.ips4_id)
    if result != "":
        AuthServicesInfoManager.update_user_ips4_info("", "", "", request.user)
        logger.info("Succesfully deactivated IPS4 for user %s" % request.user)
        return HttpResponseRedirect("/services/")
    logger.error("Unsuccesful attempt to deactivate IPS4 for user %s" % request.user)
    return HttpResponseRedirect("/dashboard")
示例#3
0
def reset_ips4_password(request):
    logger.debug("reset_ips4_password called by user %s" % request.user)
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = Ips4Manager.update_user_password(authinfo.ips4_username)
    member_id = Ips4Manager.get_user_id(authinfo.ips4_username)
    # false we failed
    if result != "":
        AuthServicesInfoManager.update_user_ips4_info(authinfo.ips4_username, result, member_id, request.user)
        logger.info("Succesfully reset IPS4 password for user %s" % request.user)
        return HttpResponseRedirect("/services/")
    logger.error("Unsuccessful attempt to reset IPS4 password for user %s" % request.user)
    return HttpResponseRedirect("/dashboard")
示例#4
0
def activate_ips4(request):
    logger.debug("activate_ips4 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 IPS4 user for user %s with main character %s" % (request.user, character))
    result = Ips4Manager.add_user(character.character_name, request.user.email)
    # if empty we failed
    if result[0] != "":
        AuthServicesInfoManager.update_user_ips4_info(result[0], result[1], result[2], request.user)
        logger.debug("Updated authserviceinfo for user %s with IPS4 credentials." % request.user)
        #update_ips4_groups.delay(request.user.pk)
        logger.info("Succesfully activated IPS4 for user %s" % request.user)
        return HttpResponseRedirect("/services/")
    logger.error("Unsuccesful attempt to activate IPS4 for user %s" % request.user)
    return HttpResponseRedirect("/dashboard")