标签: django-allauth

如何在 Django 中进行身份验证后执行代码?

我想在用户登录我的网站后执行一项或多项功能。这怎么可能?我研究了中间件。Djangobook 说我需要它来对 Django 处理的每个请求运行一段代码。但是,我只需要在身份验证成功时运行代码。

注意:我使用 Django Allauth 进行身份验证,但我没有自己的任何视图来登录用户。

django django-middleware django-signals django-authentication django-allauth

0
推荐指数
1
解决办法
749
查看次数

如何将singup\signin模板移动到下拉菜单中?

我有一个固定的导航,我想添加下拉框,用户可以在其中单挑\(如Twitter使用).

我试过了:

# project/tempates/signup.html
{% load i18n %}
{% load account socialaccount %}

{% block head_title %}{% trans "Signup" %}{% endblock %}

{% block content %}

  <h1>{% trans "Sign Up" %}</h1>

  <p>{% blocktrans %}Already have an account? Then please <a href="{{ login_url }}">sign in</a>.{% endblocktrans %}</p>

  <form class="signup" id="signup_form" method="post" action="{% url 'account_signup' %}">
    {% csrf_token %}
    {{ signupform.as_p }}
    {% if redirect_field_value %}
    <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
    {% endif %}
    <button type="submit">{% trans "Sign …
Run Code Online (Sandbox Code Playgroud)

django django-templates django-allauth

0
推荐指数
1
解决办法
912
查看次数

django-allauth 帐户/注册获取 [WinError 10061] 无法建立连接,因为目标计算机主动拒绝它

我知道这个问题有很多答案说我应该尝试在另一个端口上运行我的服务器,如下所示:python manage.py runserver 0.0.0.0:8080 我已经尝试过但没有解决它。我已经关闭了 Windows Norton 防火墙:

在此输入图像描述

我已以管理员身份启动 PyCharm。让我认为这些解决方案对我不起作用的是其他 API 端点工作得很好: 也http://localhost:8000/accounts/login/能工作http://localhost:8000/accounts/logout/。但是,当我填写表单并将数据发布到时,http://localhost:8000/accounts/signup出现此错误:

OSError at /accounts/signup/
[WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions
Request Method: POST
Request URL:    http://127.0.0.1:8000/accounts/signup/
Django Version: 2.2.7
Exception Type: OSError
Exception Value:    
[WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我我在这里缺少什么吗?

django django-allauth

0
推荐指数
1
解决办法
1607
查看次数

如何删除 Django all auth Facebook 登录期间的中间页面?

我正在使用 Django all-auth 来启用 Google 和 Facebook 社交登录到我的应用程序。流程工作正常,但流程中有两个不必要的屏幕。配置如下:

ACCOUNT_ALLOW_REGISTRATION = env.bool("DJANGO_ACCOUNT_ALLOW_REGISTRATION", True)
ACCOUNT_AUTHENTICATION_METHOD = "email"
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_EMAIL_VERIFICATION = "none"
ACCOUNT_ADAPTER = "project.users.adapters.AccountAdapter"
SOCIALACCOUNT_ADAPTER = "project.users.adapters.SocialAccountAdapter"

SOCIALACCOUNT_PROVIDERS = {
    "google": {
        "SCOPE": [
            "profile",
            "email",
            "https://www.googleapis.com/auth/youtube",
            "https://www.googleapis.com/auth/youtube.readonly",
            "https://www.googleapis.com/auth/youtube.upload",
            "https://www.googleapis.com/auth/youtube.force-ssl",
        ],
        "AUTH_PARAMS": {
            "access_type": "offline",
        },
    },

    "facebook":
        {
        'METHOD': 'oauth2',
        'SCOPE': ['email', 'public_profile'],
        'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
        'INIT_PARAMS': {'cookie': True},
        'FIELDS': [
            'id',
            'first_name',
            'last_name',
            'middle_name',
            'name',
            'name_format',
            'picture',
            'short_name'
        ],
        'EXCHANGE_TOKEN': True,
        'LOCALE_FUNC': lambda request: 'en_US', …
Run Code Online (Sandbox Code Playgroud)

django facebook-login django-allauth

0
推荐指数
1
解决办法
1166
查看次数