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')
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!')
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')
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')
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')
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')
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!')
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!')
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!')
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')
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')
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')