Ejemplo n.º 1
0
def logout(request):
    """
    Log the user out and redirect to the home page
    """
    dj_logout(request)
    messages.add_message(request, messages.SUCCESS, 'You have successfully logged out.')
    return redirect('/')
Ejemplo n.º 2
0
def signup(request):
    if User.is_authenticated:
        dj_logout(request)

    if request.method == 'POST':
        # fill it out with what i need on the way
        context = {}
        # use if not - can easily go out, if it is wrong
        if not request.POST['password'] == request.POST['confirmPassword']:
            #if they dont match, put an error message in the context
            context['error'] = "Passwords do not match."
            # if it is wrong, render the template and send the context
            return render(request, 'loginapp/signup.html', context)
        #check if the list of users is empty or not - use len
        if len(User.objects.filter(username=request.POST['user'])) > 0:
            # if the user already exists, send new error message
            context['error'] = 'Username already exists'
            return render(request, 'loginapp/signup.html', context)

        # create user
        user = User.objects.create_user(request.POST['user'],
                                        password=request.POST['password'])
        user.save()
        dj_login(request, user)
        return HttpResponseRedirect(reverse('blogapp:index'))

    # if it is not a post (then it is a get) it should just show the signup form
    return render(request, 'loginapp/signup.html')
Ejemplo n.º 3
0
def logout(request):
    context = {'page_title': "Halaman Logout"}
    if request.method == 'POST':
        print(request.POST['logout'] == 'Submit')
        if request.POST['logout'] == 'Submit':
            dj_logout(request)
            return redirect('home')
    return render(request, 'logout.html', context)
Ejemplo n.º 4
0
def deactivate_account(request):
    """
    Deactivates a user account. Not deleted because breaking ForeignKey relationships could take a lot of time.
    """
    request.user.is_active = False
    request.user.save()
    dj_logout(request)
    return redirect('/')
Ejemplo n.º 5
0
def logout(request):
    dj_logout(request)

    if request.user.is_authenticated:
        pass
    else:
        return redirect('index')

    return render(request, 'webAdmin/logout.html')
Ejemplo n.º 6
0
def logout(request):
    """
    Logs out the user.
    """

    dj_logout(request)
    messages.add_message(request, messages.SUCCESS,
                         "You have logged out successfully!")
    return redirect(reverse("firstfloor:login_prompt"))
Ejemplo n.º 7
0
def logout(request):
    if request.method != 'GET':
        return HttpResponseBadRequest()

    dj_logout(request)

    messages.success(request, 'You have successfully logged out. We hope to see you again soon!')

    return redirect('home:index')
Ejemplo n.º 8
0
def deactivate_account(request):
    """
    Deactivate the request.user's account and redirect to the home page
    """
    current_user = request.user
    current_user.is_active = False  # Disable rather than delete to avoid breaking foreign keys if they exist
    current_user.save()
    dj_logout(request)
    return redirect('/')
Ejemplo n.º 9
0
    def post(self, request, *args, **kwargs):
        user = request.user
        # disable email notify
        setting = user.setting
        setting.notify = False
        update_task(setting)

        dj_logout(request)
        user.delete()
        return http.HttpResponseRedirect(reverse('memo.views.home'))
Ejemplo n.º 10
0
def index(request):
    if not request.user.is_authenticated:
        return render(request,
                      'to_login.html',
                      context={'login_url': settings.LOGIN_URL})
    if not request.user.profile.user_agreement:
        return user_agreement(request)
    if not group_check(request.user):
        dj_logout(request)
        return render(request,
                      'to_login.html',
                      context={'login_url': settings.LOGIN_URL})
    return render(request, 'index.html')
Ejemplo n.º 11
0
def logout(request):
    """" Log user out, delete session info. """
    session = request.session.get("ApiSession", None)
    if session is not None:
        session = Session.deserialize(request.session["ApiSession"])
        aa.SessionsApi(session.api_client).sessions_logout_session(
            session.data_view, session.session_id)
    username = request.user.username
    dj_logout(request)

    context = {
        "alert_type": "alert-success",
        "alert_message": username + " has been logged out.",
    }
    return index(request, context)
Ejemplo n.º 12
0
def signup(request):
    if User.is_authenticated:
        dj_logout(request)
    context = {}
    if request.method == 'POST':
        if not request.POST['password'] == request.POST['repeatpassword']:
            context['error'] = 'Passwords do not match.'
            return render(request, 'loginapp/signup.html', context)
        if len(User.objects.filter(username=request.POST['user'])) > 0:
            context['error'] = 'Username already exists.'
            return render(request, 'loginapp/signup.html', context)
        user = User.objects.create_user(request.POST['user'],password=request.POST['password'])
        user.save()
        dj_login(request, user)
        return HttpResponseRedirect(reverse('shop:product_list'))

    return render(request, 'loginapp/signup.html')
Ejemplo n.º 13
0
def Change_Password(request):
    if request.method == 'POST':
        form = ChangePassWordForm(request.POST, user=request.user)
        if form.is_valid():
            user = request.user
            old_password = form.cleaned_data['old_password']
            new_password = form.cleaned_data['new_password']
            new_password_again = form.cleaned_data['new_password_again']
            user.set_password(new_password)
            user.save()
            dj_logout(request)
            return redirect(request.GET.get('from', reverse('home')))
    else:
        form = ChangePassWordForm()
    context = {}
    context['form'] = form
    return render(request, 'Chanage_password.html', context)
Ejemplo n.º 14
0
def login(request):
    if User.is_authenticated:
        dj_logout(request)
    if request.method == 'POST':
        user = authenticate(request,
                            username=request.POST['user'],
                            password=request.POST['password'])
        if user:
            dj_login(request, user)
            return HttpResponseRedirect(reverse('articles:create'))
        else:
            context = {
                'error':
                'Authentication failed. You may need to activate your user'
            }
            return render(request, 'accounts/login.html', context)

    return render(request, 'accounts/login.html')
Ejemplo n.º 15
0
def user_login(request, project_name):
    dj_logout(request)
    project = get_object_or_404(ClientProject, project_name=project_name)
    if request.method == 'POST':
        form = LoginForm(request.POST)
        if form.is_valid():
            cd = form.cleaned_data
            user = authenticate(username=cd['username'],
                                password=cd['password'])
            if user is not None and user.is_active:
                login(request, user)
                return redirect(reverse('client_project', args=[project_name]))
    else:
        form = LoginForm()
    return render(request, 'login.html', {
        'form': form,
        'logo': project.logo if project.logo else None
    })
Ejemplo n.º 16
0
def signup(request):
    if User.is_authenticated:
        dj_logout(request)

    context = {}
    if request.method == 'POST':
        if request.POST['password'] == request.POST['confirm_password']:
            username = request.POST['user']

            if not User.objects.filter(username=username):
                email = request.POST['email']
                user = User.objects.create_user(
                    username=username,
                    email=email,
                    first_name=request.POST['firstname'],
                    last_name=request.POST['lastname'],
                    password=request.POST['password'],
                    is_active=False)
                activation_key = str(uuid.uuid4())
                userActivation = UserActivation()
                userActivation.user = user
                userActivation.activation_key = activation_key
                userActivation.save()

                # send email with uuid for activation
                # send_mail(
                #     'Activation of your user for ToDo',
                #     'Click this link to activate your user <a href="localhost:8000/activation?username={{username}}&activation_key={{activation_key}}',
                #     '*****@*****.**',
                #     ['{{email}}'],
                #     fail_silently=False,
                # )

                return HttpResponseRedirect(reverse('accounts:login'))
            else:
                context['error'] = 'User already exist'
        else:
            context['error'] = 'Password and confirmation did not match'

    return render(request, 'accounts/signup.html', context)
Ejemplo n.º 17
0
    def process_view(self, request, view_func, view_args, view_kwargs):
        assert hasattr(request, 'user')  # has the urls defined
        # lstrip removes first / from path
        path = request.path_info.lstrip('/')

        url_is_exempt = any(url.match(path) for url in EXEMPT_URLS)

        # if not request.user.is_authenticated:
        #     if not url_is_exempt:
        #         return redirect(settings.LOGIN_URL)

        if path == 'accounts/logout/':
            dj_logout(request)

        if request.user.is_authenticated and url_is_exempt:
            return redirect(settings.LOGIN_AUTH_URL)

        elif request.user.is_authenticated or url_is_exempt:
            return None

        else:
            return redirect(settings.LOGIN_URL)
Ejemplo n.º 18
0
def signup(request):
    if User.is_authenticated:
        dj_logout(request)
    context = {}

    if request.method == 'POST':
        if not request.POST['password'] == request.POST['repeatpassword']:
            context['error'] = 'Passwords do not match.'
            return render(request, 'loginapp/signup.html', context)

        if len(User.objects.filter(username=request.POST['user'])) > 0:
            context['error'] = 'Username already exists.'
            return render(request, 'loginapp/signup.html', context)

        if len(User.objects.filter(email=request.POST['email'])) > 0:
            context['error'] = 'Email already exists.'
            return render(request, 'loginapp/signup.html', context)

        user = User.objects.create_user(request.POST['user'],
                                        password=request.POST['password'])
        user.save()
        dj_login(request, user)

        app = Celery()
        app.config_from_object('celeryconfig')

        receiver = "*****@*****.**"
        body = "Congratulations, you are now a part of Social Network. Your life is officially over"

        yag = yagmail.SMTP("*****@*****.**")
        yag.send(to=receiver,
                 subject="Signup confirmation for Social Network",
                 contents=body)
        return HttpResponseRedirect(reverse('loginapp:login'))

    return render(request, 'loginapp/signup.html')
Ejemplo n.º 19
0
def logout(request):
    next_url = request.GET.get('next') or LOGIN_URL
    dj_logout(request)
    return HttpResponseRedirect(next_url)
Ejemplo n.º 20
0
def logout(request):
    dj_logout(request)
    messages.success(request, 'You have been logged out.')
    return redirect(settings.LOGOUT_REDIRECT_URL)
Ejemplo n.º 21
0
def logout(request):
    dj_logout(request)
    messages.success(request, 'Successfully logged out.')
    return redirect('home')
Ejemplo n.º 22
0
def logout(request):
    dj_logout(request)
    return HttpResponseRedirect(reverse('loginapp:login'))
Ejemplo n.º 23
0
def logout(request):
    dj_logout(request)
    return redirect('index')
Ejemplo n.º 24
0
def logout(request):
    dj_logout(request)
    # redirect to the home page
    return redirect(reverse('memo.views.home'))
Ejemplo n.º 25
0
def logout(request):
    dj_logout(request)
    messages.success(request, "You have been signed out")
    return redirect(settings.LOGOUT_REDIRECT_URL)
Ejemplo n.º 26
0
def logout(request):
    dj_logout(request)
    return render(request, "accounts/login.html")
Ejemplo n.º 27
0
def logout(request):
    dj_logout(request)
    return HttpResponseRedirect('/')
Ejemplo n.º 28
0
def logout(request):
    dj_logout(request)
    return HttpResponseRedirect('/accounts/login')
Ejemplo n.º 29
0
def logout(request):
    dj_logout(request)
    return redirect("login")
Ejemplo n.º 30
0
def logout(request):
    dj_logout(request)
    return render(request, 'app/login.html',
                  dict(appcfg={},
                       message="You have been logged out"))
Ejemplo n.º 31
0
def logout(request):
    dj_logout(request)
    return http.HttpResponseRedirect("/")
Ejemplo n.º 32
0
def logout(request):
    dj_logout(request)
Ejemplo n.º 33
0
def logout(request):
    """
    Log the user out and redirect home.
    """
    dj_logout(request)
    return redirect('/')
Ejemplo n.º 34
0
def logout(request):
    if request.user.is_authenticated:
        dj_logout(request)
        messages.add_message(request, messages.SUCCESS, 'Logged out.')
    return redirect(request.META.get('HTTP_REFERER'))
Ejemplo n.º 35
0
Archivo: views.py Proyecto: alanma/sin
def logout_api(request):
  dj_logout(request)
  return HttpResponse(json.dumps({
    'ok'   : True,
  }))
Ejemplo n.º 36
0
def logout(request):
    dj_logout(request)
    return redirect('home')
Ejemplo n.º 37
0
def logout(request):
    dj_logout(request)
    return HttpResponseRedirect('/')
Ejemplo n.º 38
0
def logout(request):
    dj_logout(request)
    # redirect user if they logout
    return HttpResponseRedirect(reverse('loginapp:login'))
Ejemplo n.º 39
0
def logout(request):
    dj_logout(request)
    return redirect('/login')
Ejemplo n.º 40
0
    def get(self, request):
        user = request.user
        dj_logout(request)

        return HttpResponseRedirect("/splits")
Ejemplo n.º 41
0
def logout(request):
    dj_logout(request)
    return render_to_response('dash/pages/page_login.html', {}, context_instance=RequestContext(request))
Ejemplo n.º 42
0
def user_logout(request, project_name):
    project = get_object_or_404(ClientProject, project_name=project_name)
    dj_logout(request)
    return redirect(reverse('client_login', args=[project_name]))
Ejemplo n.º 43
0
def logout(request):
    dj_logout(request)
    url = request.META['HTTP_REFERER']
    return redirect(url)
Ejemplo n.º 44
0
def logout(request):
    print(request.user)
    dj_logout(request)
    messages.success(request, 'You were logged out.')
    return redirect("LAPTOP")
Ejemplo n.º 45
0
def logout(request):
    dj_logout(request)
    return HttpResponse('\'Successful logout\'')
Ejemplo n.º 46
0
def logout(request):
    dj_logout(request)
    return render(request, 'login_app/login.html')
Ejemplo n.º 47
0
def logout (request):
    dj_logout(request)
Ejemplo n.º 48
0
def logout(request):
    dj_logout(request)
    return HttpResponseRedirect(reverse('landing:index'))
Ejemplo n.º 49
0
def logout(request):
    dj_logout(request)
    context = {}
    template = loader.get_template("registration/logout.html")
    return HttpResponse(template.render(context))