在社交 django 中创建用户的异常

问题描述 投票:0回答:0

我禁用了社交 Django 中的用户创建。它正在重定向到登录页面,但没有显示任何消息。

设置.py

Debug = False

INSTALLED_APPS = [
    ...
    'social_django',
]```


LOGIN_URL = 'login'
LOGIN_ERROR_URL = '/'
MIDDLEWARE = [
    ...
    'social_django.middleware.SocialAuthExceptionMiddleware',
]
TEMPLATES = [
    {
        ...
        'OPTIONS': {
            'context_processors': [
                ...
                'social_django.context_processors.backends',
            ],
        },
    },
]
SOCIAL_AUTH_PIPELINE = (
    'social_core.pipeline.social_auth.social_details',
    'social_core.pipeline.social_auth.social_uid',
    'social_core.pipeline.social_auth.social_user',
    'social_core.pipeline.user.get_username',
    'social_core.pipeline.social_auth.associate_by_email',
    'social_core.pipeline.social_auth.associate_user',
    'social_core.pipeline.social_auth.load_extra_data',
    'social_core.pipeline.user.user_details',
)

我已经从管道中删除了“social_core.pipeline.user.create_user”。

登录.html

          <h1 class="login-title">Log in</h1>
          {% if form.errors %}
          <div class="alert alert-danger alert-dismissable fade show" role="alert">
            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
              <span aria-hidden="true">&times;</span>
            </button>
            <p>Invalid Credentials. Retry again.</p>
          </div>
          {% endif %}
          {% if messages %}
            {% for message in messages %}
            <div  class="alert {% if message.tags %} {{ message.tags }} {% endif %} alert-dismissable fade show"  role="alert">
              <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
              <p>{{message}}</p>
            </div>
            {% endfor %}
          {% endif %}
          <form action="{% url 'login' %}" method="POST">
            {% csrf_token %}
            <div class="form-group">
              <label for="username">Username:</label>
              <input type="username" name="username" id="username" class="form-control" placeholder="Enter your Username">
            </div>
            <div class="form-group mb-4">
              <label for="password">Password:</label>
              <input type="password" name="password" id="password" class="form-control" placeholder="Enter your passsword">
            </div>
            <button class="btn btn-outline-primary btn-block btn-lg" type="submit" name="Login" id="Login">Login</button>
            <a href="{% url 'social:begin' 'google-oauth2' %}">Login With Google</a>
          </form>
          <a href="{% url 'password_reset' %}" class="forgot-password-link">Forgot password?</a>
  {% endif %}

有人可以帮我在此页面中显示适当的错误消息吗?

django authentication django-socialauth
© www.soinside.com 2019 - 2024. All rights reserved.