如何解决极慢的 Oauth 身份验证 django-allauth
保持电子邮件验证=“无”,
settings.py:
Django settings for config project.
Generated by 'django-admin startproject' using Django 3.2.
For more information on this file,see
https://docs.djangoproject.com/en/3.2/topics/settings/
For the full list of settings and their values,see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
# Security WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-xc-592)no)((2&6grj56rfw$um58(cd(+0zvs2f=ar0wq6&@0='
# Security WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application deFinition
INSTALLED_APPS = [
'django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','django.contrib.sites',# new
'userlogin','allauth',# new
'allauth.account',# new
'allauth.socialaccount',# new
'allauth.socialaccount.providers.github',# new
'allauth.socialaccount.providers.shopify',]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware','django.contrib.sessions.middleware.SessionMiddleware','django.middleware.common.CommonMiddleware','django.middleware.csrf.CsrfViewMiddleware','django.contrib.auth.middleware.AuthenticationMiddleware','django.contrib.messages.middleware.MessageMiddleware','django.middleware.clickjacking.XFrameOptionsMiddleware',]
ROOT_URLconf = 'config.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates','Dirs': [os.path.join(BASE_DIR,'templates'),os.path.join(BASE_DIR,'templates','allauth')],'APP_Dirs': True,'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug','django.template.context_processors.request','django.contrib.auth.context_processors.auth','django.contrib.messages.context_processors.messages',],},]
Wsgi_APPLICATION = 'config.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3','NAME': BASE_DIR / 'db.sqlite3',}
}
# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',]
# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS,JavaScript,Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_URL = '/static/'
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
AUTHENTICATION_BACKENDS = (
"django.contrib.auth.backends.ModelBackend","allauth.account.auth_backends.AuthenticationBackend",)
SITE_ID = 1
ACCOUNT_EMAIL_VERIFICATION = 'none'
LOGIN_REDIRECT_URL = 'home'
ACCOUNT_AUTHENTICATION_METHOD = 'email'
ACCOUNT_EMAIL_required = True
ACCOUNT_EMAIL_VERIFICATION = 'none'
ACCOUNT_USERNAME_required = False
#mailgun creds
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.mailgun.org'
EMAIL_HOST_USER = 'postmaster1@alerts.xxxxxx.io'
EMAIL_HOST_PASSWORD = 'xxxxxxx'
EMAIL_PORT = 587
ACCOUNT_CONFIRM_EMAIL_ON_GET = True
ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION = True
#Modifying shopify access scope
SOCIALACCOUNT_PROVIDERS = {
'shopify': {
'ScopE': ['read_products','write_products','read_orders','write_orders','write_order_edits']
}
}
urls.py:
from django.contrib import admin
from django.urls import path,include
from userlogin import views
urlpatterns = [
path('admin/',admin.site.urls),path('accounts/',include('allauth.urls')),path('',views.home,name='home'),path('orders/',views.orders,name='orders'),]
控制台日志:
[16/May/2021 01:05:07] "GET /accounts/github/login/?process=login&next=%2F HTTP/1.1" 302 0
[16/May/2021 01:13:23] "GET /accounts/github/login/callback/?code=e4f316f33ab6aa66b058&state=MjOwL8N4N2bK HTTP/1.1" 302 0
[16/May/2021 01:13:23] "GET /accounts/confirm-email/ HTTP/1.1" 200 882
[16/May/2021 00:50:20] "GET /accounts/signup/?next=%2F HTTP/1.1" 200 1690
[16/May/2021 00:54:31] "POST /accounts/signup/ HTTP/1.1" 302 0
[16/May/2021 00:54:31] "GET /accounts/confirm-email/ HTTP/1.1" 200 882
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。