Jul*_*an 8 django django-allauth
我正在使用django allauth auth系统,我使用带有"next"参数的社交注册,如下所示:
<a data-provider="facebook"
href="{% provider_login_url "facebook" method="oauth2" next=next %}">
Run Code Online (Sandbox Code Playgroud)
其中next是动态变量.
但是我想为这个过程注入第二个屏幕,要求提供一个phoner号码或其他信息.
我想我需要覆盖一个方法来重定向到第二个屏幕并将下一个参数传递给这个视图.
知道要覆盖哪种方法?
编辑:我想出了如何为"正常"注册流程执行此操作:
我重写了allauth.account.views.SignupView并添加了一个新方法:
class CustomSignupView(SignupView):
def get_success_url(self):
next_value = (get_next_redirect_url(self.request,
self.redirect_field_name)
or self.success_url)
ret = 'whatever/url?next=' + next_value
return ret
signup = CustomSignupView.as_view()
Run Code Online (Sandbox Code Playgroud)
然后将自定义视图添加到我自己的帐户/注册URL文件中.
但我无法在社交注册视图中找到该方法.有人知道在社交注册视图中评估下一个参数的位置吗?
EDIT2:
所以我做了一些挖掘.Flag用于sociallogin类方法:
@classmethod
def state_from_request(cls, request):
if next_url:
state['next'] = next_url
return state
Run Code Online (Sandbox Code Playgroud)
之后,它将提供程序传递给helpers complete_social_login或complete_social_signup(当被调用时不确定).
最后有一个函数account/utils perform_login实际执行重定向.
不知道现在在哪里覆盖,仍在挖掘.
所以最后它来到:
socialaccount视图调用helpers.complete_social_signup,然后使用重定向URL调用完整注册.
我认为不得不覆盖该视图,然后通过我自己的完整社交注册方法.
EDIT3:
如果您启用了自动签名(我这样做),则永远不会调用SocialSignup ClassView,而是在socialaccount.helpers._process_signup中创建新用户.
Jul*_*an 1
最终分叉了django -allauth 并简单地添加了一个名为 ACCOUNT_SIGNUP_REDIRECT 的可调用设置。
def custom_signup_redirect(success_url):
ret = '/whatever/url/?next=' + success_url
return ret
Run Code Online (Sandbox Code Playgroud)
然后在设置中:
ACCOUNT_SIGNUP_REDIRECT = 'myapp.utils.custom_signup_redirect'
Run Code Online (Sandbox Code Playgroud)
请参阅此提交。
| 归档时间: |
|
| 查看次数: |
248 次 |
| 最近记录: |