コード例 #1
0
def activate(request, uidb64, token):
    try:
        uid = force_text(urlsafe_base64_decode(uidb64))
        user = User.objects.get(pk=uid)
    except (TypeError, ValueError, OverflowError, User.DoesNotExist):
        user = None

    if user is not None and account_activation_token.check_token(user, token):
        user.is_active = True
        user.reset = True
        if user.is_school:
            SchoolCode.objects.filter(reg_number=user.code).update(
                used=True, user_id=user.id)
            user.save()
            login(request, user)
            sweetify.success(request,
                             'Account Created Successful',
                             button='Great!')
            return redirect('schoolPortal:schoolProfile', )
        elif user.is_professional:
            ProfessionalCode.objects.filter(reg_number=user.code).update(
                used=True, user_id=user.id)
            user.save()
            login(request, user)
            sweetify.success(request,
                             'Account Created Successful',
                             button='Great!')
            return redirect('profPortal:dashboard', )

    else:
        return render(request, 'auth/sch_register.html')
コード例 #2
0
def activate(request, uidb64, token):
    try:
        uid = force_text(urlsafe_base64_decode(uidb64))
        user = User.objects.get(pk=uid)
    except (TypeError, ValueError, OverflowError, User.DoesNotExist):
        user = None
    if user is not None and account_activation_token.check_token(user, token):
        user.is_active = True
        user.save()
        login(request, user)
        return redirect('authentication:login_user')
    else:
        return HttpResponse('Activation link is invalid!')
コード例 #3
0
def activate(request, uidb64, token):
    try:
        # uid = force_text(urlsafe_base64_decode(uidb64))
        uid = uidb64
        user = User.objects.get(pk=uid)
    except (TypeError, ValueError, OverflowError, User.DoesNotExist):
        user = None

    if user is not None and account_activation_token.check_token(user, token):
        user.is_active = True
        user.profile.email_confirmed = True
        user.save()
        login(request, user)
        return redirect('home')
コード例 #4
0
def activate(request, uidb64, token):
    try:
        uid = force_text(urlsafe_base64_decode(uidb64))
        user = UserModel.objects.get(pk=uid)
    except (TypeError, ValueError, OverflowError, UserModel.DoesNotExist):
        user = None
    if user is not None and account_activation_token.check_token(user, token):
        user.is_active = True
        user.save()
        return render(request,
                      "msg.html",
                      context={'user_type': user.user_type})
    else:
        return HTTPResponse('Activation link is invalid')
コード例 #5
0
ファイル: views.py プロジェクト: dimatroickij/searchImages
def activate(request, uidb64, token):
    try:
        uid = int(urlsafe_base64_decode(uidb64))
        print(uid)
        user = get_user_model().objects.get(pk=uid)
        print(user.username)
    except(TypeError, ValueError, OverflowError, get_user_model().DoesNotExist):
        user = None
    if user is not None and account_activation_token.check_token(user, token):
        user.is_active = True
        user.save()
        login(request, user)
        messages.add_message(request, messages.SUCCESS, 'Email подтверждён. Выполнен вход на сайт.')
    else:
        messages.add_message(request, messages.SUCCESS, 'Ошибка подтверждения email')
    return redirect('search:home')
コード例 #6
0
ファイル: views.py プロジェクト: Shaurov05/example-blog
    def get(self, request, uidb64, token, *args, **kwargs):
        try:
            uid = force_text(urlsafe_base64_decode(uidb64))
            user = get_user_model().objects.get(pk=uid)
        except (TypeError, ValueError, OverflowError, get_user_model().DoesNotExist):
            user = None

        if user is not None and account_activation_token.check_token(user, token):
            user.is_active = True
            user.email_confirmed = True
            user.save()
            login(request, user, backend='django.contrib.auth.backends.ModelBackend')
            messages.success(request, ('Your account have been confirmed.'))
            return render(request, "accounts/profile.html", context={'pk':uid})
        else:
            messages.warning(request, ('The confirmation link was invalid, possibly because it has already been used.'))
            return redirect('index')
コード例 #7
0
def activate(request, uidb64, token):
    User = get_user_model()
    try:
        uid = force_text(urlsafe_base64_decode(uidb64))
        user = User.objects.get(pk=uid)
    except (TypeError, ValueError, OverflowError, User.DoesNotExist):
        user = None
    if user is not None and account_activation_token.check_token(user, token):
        user.is_active = True
        user.save()
        messages.success(
            request,
            'Thank you for your email confirmation. Now you can login your account.'
        )
        return redirect('login')
    else:
        return HttpResponse('Activation link is invalid!')
コード例 #8
0
ファイル: views.py プロジェクト: lazyvar/dailyinquirer.me
def activate(request, uidb64, token):
    try:
        uid = force_text(urlsafe_base64_decode(uidb64))
        user = User.objects.get(pk=uid)
    except (TypeError, ValueError, OverflowError, User.DoesNotExist):
        user = None
    if user is not None and account_activation_token.check_token(user, token):
        user.confirmed_email = True
        user.save()
        login(request, user)
        try:
            mail_newsletter(user)
        except:
            pass

        return redirect('index')
    else:
        return HttpResponse('Activation link is invalid!')
コード例 #9
0
def activate(request, uidb64, token):
    try:
        uid = force_text(urlsafe_base64_decode(uidb64))
        user = User.objects.get(pk=uid)
    except (TypeError, ValueError, OverflowError, User.DoesNotExist):
        user = None
    if user is not None and account_activation_token.check_token(user, token):
        user.is_active = True
        user.save()
        login(request,
              user,
              backend='django.contrib.auth.backends.ModelBackend')
        # return redirect('home')
        return HttpResponse(
            'Thank you for your email confirmation. Now you can login your account.'
        )
    else:
        return HttpResponse('Activation link is invalid!')
コード例 #10
0
ファイル: views.py プロジェクト: vvt5676/DjangoLogin
def activate(request, uidb64, token):
    try:
        uid = urlsafe_base64_decode(uidb64).decode()
        user = User.objects.get(pk=uid)
    except (TypeError, ValueError, OverflowError, User.DoesNotExist):
        user = None

    if user is not None and account_activation_token.check_token(user, token):
        user.is_active = True
        user.email_confirmed = True
        user.save()
        login(request,
              user,
              backend='django.contrib.auth.backends.ModelBackend')
        return redirect('main:home')
    else:
        return render(request,
                      'authentication/account_activation_invalid.html')
コード例 #11
0
def activate(request, uidb64, token):
    try:
        uid = force_text(urlsafe_base64_decode(uidb64))
        user = User.objects.get(pk=uid)
    except (TypeError, ValueError, OverflowError, User.DoesNotExist):
        user = None

    if user is not None and account_activation_token.check_token(user, token):
        user.is_active = True
        user.profile.email_confirmed = True
        user.save()
        login(request, user)
        welcome_post = '{0} has joined the network.'.format(user.username,
                                                            user.username)
        feed = Feed(user=user, post=welcome_post)
        feed.save()
        return redirect('/')
    else:
        return render(request, 'authentication/account_activation_invalid.html')
コード例 #12
0
ファイル: views.py プロジェクト: cHowTv/cNovels
def activateAccount(request, uidb64, token):
    if request.GET:
        try:
            uid = force_text(urlsafe_base64_decode(uidb64))
            user = User.objects.get(pk=uid)
        except (TypeError, ValueError, OverflowError, User.DoesNotExist):
            user = None

        if user is not None and account_activation_token.check_token(
                user, token):
            user.is_active = True
            user.email_confirmed = True
            user.save()
            login(request, user)
            messages.success(request, ('Your account have been confirmed.'))
            return redirect('home')
        else:
            messages.warning(request, (
                'The confirmation link was invalid, possibly because it has already been used.'
            ))
            return redirect('home')