Ejemplo n.º 1
0
def logout(request):
    log_out(request)
    milestones = MileStone.objects.all()
    advantage_links = AdvantageLink.objects.filter(advantage_id=1)
    slides = Slide.objects.all()

    if request.user.is_authenticated():
        logout = True
        try:
            user_id = request.user.id
            username = request.user.username
            first_name = request.user.first_name
            last_name = request.user.last_name
            profile_image_path = ''
        except Exception as R:
            log = Logger(log='WE GOT SOME ERROR' + str(R))
            log.save()
            user_id = -1
            username = ''
            first_name = ''
            last_name = ''
            profile_image_path = ''

    else:
        user_id = -1
        logout = False
        username = ''
        first_name = ''
        last_name = ''
        profile_image_path = ''

    return HttpResponseRedirect('/')
Ejemplo n.º 2
0
def logout(request):
    log_out(request)
    return_to = urlencode({'returnTo': request.build_absolute_uri('/')})
    logout_url = 'https://%s/v2/logout?client_id=%s&%s' % \
                 (settings.SOCIAL_AUTH_AUTH0_DOMAIN,
                  settings.SOCIAL_AUTH_AUTH0_KEY, return_to)
    return HttpResponseRedirect(logout_url)
Ejemplo n.º 3
0
def logout(request):
    """
    View to log the current user out and go back to the login screen.
    """
    # logs the current user out.
    log_out(request)
    return HttpResponseRedirect(reverse('blog:login'))
Ejemplo n.º 4
0
def logout(request):
    log_out(request)
    return_to = urlencode({"returnTo": request.build_absolute_uri("/")})
    logout_url = "https://{}/v2/logout?client_id={}&{}".format(
        settings.SOCIAL_AUTH_AUTH0_DOMAIN, settings.SOCIAL_AUTH_AUTH0_KEY, return_to,
    )
    return HttpResponseRedirect(logout_url)
Ejemplo n.º 5
0
def logout(request):
    """
    Function to logout
    """

    log_out(request)
    return HttpResponseRedirect("/login")
Ejemplo n.º 6
0
def logout(request):
    """Logout the user
    """
    mp = Mixpanel("a28ae260bcb8356ddcbb5658e35cb787")
    
    log_out(request)
    return HttpResponseRedirect('/')
Ejemplo n.º 7
0
def logout(request):
    log_out(request)
    return_to = urlencode({'returnTo': request.build_absolute_uri('/')})
    logout_url = f"https://{settings.SOCIAL_AUTH_AUTH0_DOMAIN}/v2/logout" \
                 f"?client_id={settings.SOCIAL_AUTH_AUTH0_KEY}&{return_to}"

    return HttpResponseRedirect(logout_url)
Ejemplo n.º 8
0
 def get(self, request, *args, **kwargs):
     # Si el usuario no estaba autenticado, no tiene sentido desloguearse
     if request.user.is_authenticated == False:
         return redirect('/')
     # Si estaba autenticado, hago el logout y redirecciono a la vista index
     log_out(request)
     return redirect('/')
Ejemplo n.º 9
0
def logout(request):
    log_out(request)
    domain = settings.SOCIAL_AUTH_AUTH0_DOMAIN
    client_id = settings.SOCIAL_AUTH_AUTH0_KEY
    return_to = request.build_absolute_uri('/')
    return HttpResponseRedirect(
        f'https://{domain}/v2/logout?client_id={client_id}&returnTo={return_to}'
    )
Ejemplo n.º 10
0
def logout(request):
    log_out(request)
    response = redirect('home')
    # this cookie forces other tabs to logout immediately
    response.set_cookie('loggedout', True, 3)
    if 'myguid' in request.COOKIES:
        response.delete_cookie(key='myguid', domain='.my.jobs')
    return response
Ejemplo n.º 11
0
def logout(request):
    log_out(request)
    response = redirect('home')
    # this cookie forces other tabs to logout immediately
    response.set_cookie('loggedout', True, 3)
    if 'myguid' in request.COOKIES:
        response.delete_cookie(key='myguid', domain='.my.jobs')
    return response
Ejemplo n.º 12
0
def logout_page(request):
	log_out(request)
	form = LoginForm(request.POST)
	context = {
		"title": "Login Here ",
		"form": form, 
	}
	return render(request,"accounts/login.html",context)
Ejemplo n.º 13
0
def logout(request):
    print("This is Logout method")
    del request.session['userdata']
    log_out(request)
    return_to = urlencode(
        {'returnTo': request.build_absolute_uri('/college/home/')})
    logout_url = 'https://%s/v2/logout?client_id=%s&%s' % \
                 (settings.SOCIAL_AUTH_AUTH0_DOMAIN, settings.SOCIAL_AUTH_AUTH0_KEY, return_to)
    return HttpResponseRedirect(logout_url)
Ejemplo n.º 14
0
def logout(request):
    log_out(request)
    return_to = urlencode({"returnTo": request.build_absolute_uri("/")})
    logout_url = "https://%s/v2/logout?client_id=%s&%s" % (
        settings.SOCIAL_AUTH_AUTH0_DOMAIN,
        settings.SOCIAL_AUTH_AUTH0_KEY,
        return_to,
    )
    return redirect(logout_url)
Ejemplo n.º 15
0
def logout(request):
    """
    La funcion del logout ya se encarga de redireccionar al menu de inicio de sesion
    una vez que el usuario haya presionado el boton de logout.
    Por lo tanto la configuracion hecha hace que HttpResponseRedirect retorne la ruta de inicio.
    """
    log_out(request)
    return_to = urlencode({'returnTo': request.build_absolute_uri('/')})
    logout_url = 'https://%s/v2/logout?client_id=%s&%s' % \
                 (settings.SOCIAL_AUTH_AUTH0_DOMAIN, settings.SOCIAL_AUTH_AUTH0_KEY, return_to)
    return HttpResponseRedirect(logout_url)
Ejemplo n.º 16
0
def logout(request):
    """ Logout function

    This function renders login.html with a farewell message
    """
    if not request.user.is_authenticated:
        print("not authenticated")
        return render(request, 'login.html', status=401)
    else:
        log_out(request)
    context = {'message': "Vous avez été déconnecté."}
    return render(request, 'login.html', context=context)
Ejemplo n.º 17
0
def delete_account(request):
    """
    A method used during JPMorgan demo that allows us to delete/recreate accounts
    on the fly
    """
    ubanks = request.user.userbank.all()
    for ubank in ubanks:
        ubank.delete()
    user = request.user
    log_out(request)
    user.delete()
    return HttpResponse("Account succesfully deleted")
Ejemplo n.º 18
0
def logout(request):
    log_out(request)
    params = {
        'client_id': settings.AUTH0_CLIENT_ID,
        'return_to': request.build_absolute_uri(reverse('index')),
    }
    logout_url = requests.Request(
        'GET',
        f'https://{settings.AUTH0_DOMAIN}/v2/logout',
        params=params,
    ).prepare().url
    messages.success(
        request,
        "You Have Been Logged Out!",
    )
    return redirect(logout_url)
Ejemplo n.º 19
0
def logout(request):
    #custom logout for admin accounts when testing in dev-mode:
    #if request.user.is_staff:
    #    log_out(request)
    #    return render(request, "index.html")

    #auth0 logout
    log_out(request)
    return_to = urlencode({"returnTo": request.build_absolute_uri("/")})
    logout_url = "https://{}/v2/logout?client_id={}&{}".format(
        settings.SOCIAL_AUTH_AUTH0_DOMAIN,
        settings.SOCIAL_AUTH_AUTH0_KEY,
        return_to,
    )

    return HttpResponseRedirect(logout_url)
Ejemplo n.º 20
0
def reset_password(sender, instance, request, email, password, **kwargs):
    user = User.objects.get(email=email)
    mess = 'Your password has been successfully reset.'

    try:
        profile = ProfileMetaProp.objects.get(pk=1)
        FROM = 'Grinberg & Segal <{}>'.format(profile.from_email)
        USER = profile.user_name
        PASSWORD = profile.password
        PORT = profile.smtp_port
        SERVER = profile.smtp_server
        TO = email
        #contstruct the message
        BODY = '<html><body><strong>USERNAME</strong> %s' % user.username
        BODY += '</strong><br/><strong>EMAIL</strong> %s' % user.email
        BODY += '</strong><br/><strong>MESSAGE</strong> %s' % mess
        BODY += '</strong><br/><strong>YOUR PASSWORD HAS BEEN UPDATED. </strong>'
        BODY += '</body></html>'
        SUBJECT = 'Password reset notification for %s' % user.username
        message = 'Subject: %s\n\n%s' % (SUBJECT, BODY)

        MESSAGE = MIMEMultipart('alternative')
        MESSAGE['subject'] = SUBJECT
        MESSAGE['To'] = TO
        MESSAGE['From'] = FROM
        MESSAGE.preamble = """
                Your mail reader does not support the report format.
                Please visit us <a href="http://www.mysite.com">online</a>!"""

        HTML_BODY = MIMEText(BODY.encode('utf-8'), 'html', 'utf-8')
        # Attach parts into message container.
        # According to RFC 2046, the last part of a multipart message, in this case
        # the HTML message, is best and preferred.
        MESSAGE.attach(HTML_BODY)
        msg = MESSAGE.as_string()
        server = smtplib.SMTP(SERVER + ':' + PORT)
        server.ehlo()
        server.starttls()
        server.login(USER, PASSWORD)
        server.sendmail(FROM, TO, msg)
        server.quit()

    except SMTPRecipientsRefused:
        pass
    except ObjectDoesNotExist:
        pass
    log_out(instance)
Ejemplo n.º 21
0
def logout(request):
    log_out(request)
    return redirect('index')
Ejemplo n.º 22
0
def delete_account(request):
    user = request.user
    user.delete()
    log_out(request)
    return HttpResponseRedirect(reverse_lazy('index'))
Ejemplo n.º 23
0
def logout(request):
    log_out(request)
    return redirect("movies:main")
Ejemplo n.º 24
0
def logout(request):
    log_out(request)
    return HttpResponseRedirect(reverse('main_page'))
Ejemplo n.º 25
0
def logout(request):
    del request.session['user']
    del request.session['email']
    log_out(request)
    return redirect('login')
Ejemplo n.º 26
0
def logout(request):
    log_out(request)
    return redirect('home')
Ejemplo n.º 27
0
def logout(req):
    log_out(req)
    return HttpResponseRedirect("/auth/login/?prev=/auth/logout/")
Ejemplo n.º 28
0
def logout(request):

    log_out(request)

    return render(request, 'blog/logout.html', {})
Ejemplo n.º 29
0
def logout(request):
    log_out(request)
    return render(request, "bounties/logged_out.html")
Ejemplo n.º 30
0
def logout(request):
    log_out(request)
    return render(request, 'accounts/logout.html')
Ejemplo n.º 31
0
def logout(request):
    log_out(request)
    return HttpResponseRedirect(redirect(request))
Ejemplo n.º 32
0
def confirm_account_view(request):
    """
     A view that confirms the user
    """
    try:
        #      data = json.loads(request.body).encode('utf-8')
        data = JSONParser().parse(request)

        user_id = data['user_id'].encode('utf-8')
        username = data['username'].encode('utf-8')
        first = data['first'].encode('utf-8')
        last = data['last'].encode('utf-8')
        phone = data['phone'].encode('utf-8')
        email = data['email'].encode('utf-8')

        if email:
            users_email = User.objects.filter(~Q(id=int(user_id)), email=email)
        else:
            users_email = []

        if phone:
            users_phone = Profile.objects.filter(~Q(id=int(user_id)),
                                                 phone=phone)
        else:
            users_phone = []

        if username:
            users_username = Profile.objects.filter(~Q(id=int(user_id)),
                                                    username=username)
        else:
            users_username = []

        content = None

        if not phone:
            content = {
                'user_activated': False,
                'user_confirmed': False,
                'error': {
                    'phone': 'phone empty'
                }
            }

        if not email:
            content = {
                'user_activated': False,
                'user_confirmed': False,
                'error': {
                    'email': 'email empty'
                }
            }

        if len(users_email) > 0:
            content = {
                'user_activated': False,
                'user_confirmed': False,
                'error': {
                    'email': 'already used'
                }
            }

        if len(users_phone) > 0:
            if not content:
                content = {}
                content['user_confirmed'] = False
                content['user_activated'] = False
            if content.get('error') == None:
                content['error'] = {}
            content['error']['phone'] = 'already used'

        if len(users_username) > 0:
            if not content:
                content = {}
                content['user_confirmed'] = False
                content['user_activated'] = False
            if content.get('error') == None:
                content['error'] = {}
            content['error']['username'] = '******'

        if content and len(content) > 0:
            log = Logger(log="WE GOT ERRORS {}".format(content))
            log.save()
            return Response(content)

        user = User.objects.get(id=int(user_id))
        user.is_active = True
        user.profile.is_confirmed = True
        user.profile.is_activated = False
        user.first_name = first
        user.last_name = last
        user.profile.first_name = first
        user.profile.last_name = last
        user.profile.email = email
        user.email = email
        user.profile.phone = phone
        user.username = username
        user.profile.username = username
        user.profile.save()
        user.save()

        user_resend_activation.send(sender=user, instance=user, kwargs=None)

    except Exception as e:
        first = ''
        last = ''
        phone = ''
        email = ''
        username = ''
        user_id = ''
        content = {
            'user_activated': False,
            'error': str(e),
            'last': '',
            'first': ''
        }

        log = Logger(log='FAILED TO CONFIRM {}'.format(e))
        log.save()

    content = {
        'user_activated': False,
        'user_confirmed': True,
        'first': first,
        'last': last,
        'phone': phone,
        'email': email,
        'username': username,
        'user_id': user_id
    }

    user = User.objects.get(id=user_id)
    user.profile.email = email
    user.email = email
    user.profile.phone = phone
    user.username = username
    user.profile.username = username
    user.profile.save()
    user.save()

    try:
        log_out(request)
    except Exception as e:
        log = Logger(log='FAILED TO LOG OUT {}'.format(e))
        log.save()

    return Response(content)
Ejemplo n.º 33
0
def logout(request):
    log_out(request)
    response = redirect('home')
    if 'myguid' in request.COOKIES:
        response.delete_cookie(key='myguid', domain='.my.jobs')
    return response
Ejemplo n.º 34
0
def logout(request):
    log_out(request)
    return redirect('login')
Ejemplo n.º 35
0
def logout(request):
    log_out(request)
    return HttpResponseRedirect(reverse_lazy('index'))
Ejemplo n.º 36
0
def logout(request):
    """Logout the user
    """
    mp.track(request.user.username, 'Logout')
    log_out(request)
    return HttpResponseRedirect('/')
Ejemplo n.º 37
0
def logout(request):
	if request.method == 'POST':
		log_out(request)
		return render_to_response('userauth/logout.html')
Ejemplo n.º 38
0
Archivo: views.py Proyecto: snakejj/p11
def logout(request):
    log_out(request)
    messages.info(request,
                  "On espere vous revoir bientot !",
                  fail_silently=True)
    return redirect("core:home")
Ejemplo n.º 39
0
 def get(self, request):
     log_out(request)
     return redirect(reverse("index"))
Ejemplo n.º 40
0
def logout(request):
    log_out(request)
    return redirect('homepage')
Ejemplo n.º 41
0
def logout(request):
    log_out(request)
    return redirect('login')
Ejemplo n.º 42
0
def logout(request, page=None):
	log_out(request)
	return HttpResponseRedirect("/posts")