美好的一天,我正在尝试覆盖 Django allauth 的 password_reset_email 。问题是它成功覆盖,但数据(密码重置链接、站点名称和域名)未传递到电子邮件,这最终意味着用户无法重置密码,因为没有发送链接。
我的密码重置序列化器
class PasswordResetSerializer(PasswordResetSerializer):
def get_email_options(self):
return {
'subject_template_name': 'account/email/password_reset_key_subject.txt',
# 'email_template_name': 'account/email/password_reset_key.txt',
'html_email_template_name': 'account/password_reset_key.html',
}
Run Code Online (Sandbox Code Playgroud)
在我的templates/registration/password_reset_email.html
{% load i18n %}
{% autoescape off %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Confirm Your E-mail</title>
<style>
.body {
background-color: #f6f6f6;
padding: 30px;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.content {
background-color: #FFFFFF;
color: #4d4d4d;
max-width: 400px;
padding: 20px;
margin: auto;
}
.title {
font-size: …Run Code Online (Sandbox Code Playgroud) django django-rest-framework django-allauth django-rest-auth
你好,我正在使用django all-authSlack。但是,我有两个问题。
第一:重定向 URL 始终转到 HTTP 而不是 HTTPS。例如,我单击 ***.ngrok.io/accounts/slack/login,然后被重定向到,https://***.slack.com/oauth?client_id=1737791866593.2107881969061&scope=identify&user_scope=&redirect_uri=http%3A%2F%2F***.ngrok.io%2Faccounts%2Fslack%2Flogin%2Fcallback%2F&state=ANmZKE1CMWq7&granular_bot_scope=0&single_channel=0&install_redirect=&tracked=1&response_type=code&team=如您所见,redirect_uri 是 HTTP。我怎样才能改变这个django all-auth?

第二:手动更改后,我仍然无法登录,因为出现以下错误(见图):

例如https://django-allauth.readthedocs.io/en/latest/providers.html#slack
我正在尝试将 Google 身份验证集成到我的登录页面中。我在 Django 工作。我在登录页面上添加了使用 Google 按钮登录,但是当我单击该按钮时,我将重定向到accounts/google/login,其中要求确认以继续以及带有登录和注销的菜单。
但我想要的是,当我单击按钮时,它应该要求帐户登录。
这是我的 HTML 按钮登录代码:Login.html:
{% if user.is_authenticated %}
<p>Welcome, You are logged in as {{ user.username }}</p>
{% else %}
<a href="{% provider_login_url 'google' %}">Login With Google</a>
{% endif %}
Run Code Online (Sandbox Code Playgroud)
我怎样才能跳过这个确认页面,如果有人能帮我解决这个问题,我将很高兴,谢谢。
我正在使用Django allauth来满足我的网站的身份验证需求。
当用户使用社交帐户登录我的网站时-大多数是Google(我只设置了twitter,facebook和google,大多数用户似乎更喜欢google)-用户的电子邮件始终会自动验证,尽管这些设置来自allauth文档(http://django-allauth.readthedocs.org/en/latest/#configuration):
ACCOUNT_EMAIL_REQUIRED = True
SOCIALACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
SOCIALACCOUNT_EMAIL_VERIFICATION = "mandatory"
Run Code Online (Sandbox Code Playgroud)
没有验证电子邮件不断发送一个帐户是通过社交和电子邮件报始终上市尽管是“验证”。
我已经设置了一个重要的安全挂钩,以拦截验证信号。我需要社交用户获取电子邮件,然后单击电子邮件验证链接。
手动注册的用户都可以正常工作(电子邮件,验证链接等)。
什么是或可能是错的?
Python 3.3,Django 1.6.2,django-allauth 0.15.0(通过pip)
更新:即使我设置
SOCIALACCOUNT_AUTO_SIGNUP = False
Run Code Online (Sandbox Code Playgroud)
并强制用户填写表格,它仍然会自动验证社交用户。
让我解释一下我在做什么?
我在浏览器上打开了两个标签,显示了我的登录页面(简单的用户名和密码表单).
使用选项卡1:我登录时提供正确的凭据.工作正常.
使用选项卡2 :(不刷新)我再次尝试使用相同或不同的凭据登录,这会引发403禁止错误失败原因:CSRF令牌丢失或不正确.
我知道,我正在做一些愚蠢的事情,当我已经登录时,我正在尝试登录.
我想防止引发的脏403错误并使进程顺利,因为当有人已经登录或其他不会破坏流程时,应该忽略第二个登录请求.我该怎么做呢?
我正在使用Django == 1.6.2和django-allauth == 0.14.1
在我的应用程序中,我需要用户使用他们的电子邮件和密码登录.使用allauth它创建一个注册表单,其中email字段是可选的,并且有一个用户名字段.
我希望我的注册有三个字段:
我试过创建一个自定义表单,但由于某种原因它不起作用.我不知道如何从表单中删除用户名.
class SignupForm(forms.Form):
email = forms.EmailField(label='Email', required=True)
class Meta:
model = get_user_model()
def save(self, user):
user.email = self.cleaned_data['email']
user.save()
Run Code Online (Sandbox Code Playgroud)
它只需要允许我正确注册用户然后我可以处理其余的
编辑:凯文的答案在下面解决了我的问题.原来"allauth不支持命名空间"所以我不应该把它引入我的urls.py
原始邮寄:
我完全按照教程安装了django-allauth
https://github.com/pennersr/django-allauth
我这里有一个非常基本的问题; 甚至在我添加社交集成之前,无法使基本用户登录/退出页面正常工作.
通过导航到/ admin,我点击"退出",所以我不是登录用户.
现在,当我访问时,/accounts/login我遇到了这个错误
NoReverseMatch at /accounts/login/
Reverse for 'account_signup' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Request Method: GET
Request URL: http://localhost:5000/accounts/login/
Django Version: 1.6.5
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'account_signup' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Run Code Online (Sandbox Code Playgroud)
问题:我是否需要修改默认的allauth views.py来解决这个问题?
在相关的情况下,当我尝试通过shell时,这是同样的问题
(awe01)MoriartyMacBookAir13:getstartapp macuser$ python manage.py shell
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
>>> from django.core.urlresolvers import reverse …Run Code Online (Sandbox Code Playgroud) 我正在使用Django我的项目和django-allauth身份验证.当任何用户使用Facebook登录时,如何获取他facebook friends已经在我的网站上注册的"列表",以便我可以让他/她在我的网站上关注他们?
或者我应该使用django-socialauth它来使它更容易?
import contacts from Google account如果用户链接帐户,我该怎么办Google?
我是初学者.请帮忙!
谢谢!
django facebook django-socialauth facebook-graph-api django-allauth
我已经设置了django-allauth并在新用户注册时使用电子邮件确认,效果很好
但在确认电子邮件中,我得到了
Hello from example.com!
You're receiving this e-mail because user abc13 at example.com has given yours as an e-mail address to connect their account.
To confirm this is correct, go to http://<mysite>.com/accounts/confirm-email/q3rknxpflshgwddlbjw6aqzlr1ayqtnfrtezucoq2ysmfbm2etcldusq5dyrcoap/
Thank you from example.com!
example.com
Run Code Online (Sandbox Code Playgroud)
如何用网站名称替换“ example.com”?
谢谢
我有一个检查用户配置文件的中间件.如果auth用户没有配置文件,则重定向到用户配置文件.我的浏览器显示错误The page isn’t redirecting properly.
class Check(MiddlewareMixin):
def process_request(self, request):
if request.user.is_authenticated():
user = request.user
try:
profile = Profile.objects.get(user_id = user)
if profile:
pass
except ObjectDoesNotExist:
return HttpResponseRedirect('/accounts/profile/')
Run Code Online (Sandbox Code Playgroud)
我用了django-allauth.