def activate_account(request, token):
    user = get_object_or_404(User, auth_token=token)

    if not user.auth_token_is_used:
        if request.POST:
            form = ActivateAccountForm(request.POST, user=user)

            if form.is_valid():

                # Activate the user's account
                user.full_name = form.cleaned_data['full_name']
                user.password = make_password(form.cleaned_data['password'])
                user.is_active = True

                user.activated_datetime = now()
                user.auth_token_is_used = True
                user.save()

                email = user.email
                password = request.POST['password']
                user = authenticate(username=email, password=password)
                login(request, user)

                # Redirect to dashboard with welcome message
                request.session['show_welcome'] = True
                return redirect(reverse('dashboard'))

        else:
            form = ActivateAccountForm(user=user)

        context = {
            'user': user,
            'form': form,
        }

    else:
        token_is_used = True

        context = {
            'token_is_used': token_is_used,
        }

    return render(request, 'accounts/activate_account.html', context)
Allow a user to activate their account with the token sent to them
dataset/ETHPy150Open nlhkabu/connect/connect/accounts/views.py/activate_account