Ejemplo n.º 1
0
def activate_discord(request):
    logger.debug("activate_discord called by user %s" % request.user)
    success = False
    if request.method == 'POST':
        logger.debug("Received POST request with form.")
        form = DiscordForm(request.POST)
        logger.debug("Form is valid: %s" % form.is_valid())
        if form.is_valid():
            email = form.cleaned_data['email']
            logger.debug("Form contains email address beginning with %s" % email[0:3])
            password = form.cleaned_data['password']
            try:
                user_id = DiscordManager.add_user(email, password, request.user)
                logger.debug("Received discord uid %s" % user_id)
                if user_id != "":
                    AuthServicesInfoManager.update_user_discord_info(user_id, request.user)
                    logger.debug("Updated discord id %s for user %s" % (user_id, request.user))
                    update_discord_groups(request.user)
                    logger.debug("Updated discord groups for user %s." % request.user)
                    success = True
                    logger.info("Succesfully activated discord for user %s" % request.user)
                    return HttpResponseRedirect("/services/")
            except:
                logger.exception("An unhandled exception has occured.", exc_info=True)
                pass
    else:
        logger.debug("Request is not type POST - providing empty form.")
        form = DiscordForm()

    logger.debug("Rendering form for user %s with success %s" % (request.user, success))
    context = {'form': form, 'success': success}
    return render_to_response('registered/discord.html', context, context_instance=RequestContext(request))
Ejemplo n.º 2
0
def activate_discord(request):
    logger.debug("activate_discord called by user %s" % request.user)
    success = False
    if request.method == 'POST':
        logger.debug("Received POST request with form.")
        form = DiscordForm(request.POST)
        logger.debug("Form is valid: %s" % form.is_valid())
        if form.is_valid():
            email = form.cleaned_data['email']
            logger.debug("Form contains email address beginning with %s" %
                         email[0:3])
            password = form.cleaned_data['password']
            logger.debug("Form contains password of length %s" % len(password))
            try:
                user_id = DiscordManager.add_user(email, password,
                                                  request.user)
                logger.debug("Received discord uid %s" % user_id)
                if user_id != "":
                    AuthServicesInfoManager.update_user_discord_info(
                        user_id, request.user)
                    logger.debug("Updated discord id %s for user %s" %
                                 (user_id, request.user))
                    update_discord_groups(request.user)
                    logger.debug("Updated discord groups for user %s." %
                                 request.user)
                    success = True
                    logger.info("Succesfully activated discord for user %s" %
                                request.user)
                    return HttpResponseRedirect("/services/")
            except:
                logger.exception("An unhandled exception has occured.")
                pass
    else:
        logger.debug("Request is not type POST - providing empty form.")
        form = DiscordForm()

    logger.debug("Rendering form for user %s with success %s" %
                 (request.user, success))
    context = {'form': form, 'success': success}
    return render_to_response('registered/discord.html',
                              context,
                              context_instance=RequestContext(request))
Ejemplo n.º 3
0
def activate_discord(request):
    success = False
    if request.method == 'POST':
        form = DiscordForm(request.POST)
        if form.is_valid():
            email = form.cleaned_data['email']
            password = form.cleaned_data['password']
            try:
                user_id = DiscordManager.add_user(email, password)
                AuthServicesInfoManager.update_user_discord_info(user_id, request.user)
                update_discord_groups(request.user)
                success = True
                return HttpResponseRedirect("/services/")
            except:
                pass
    else:
        form = DiscordForm()

    context = {'form': form, 'success': success}
    return render_to_response('registered/discord.html', context, context_instance=RequestContext(request))