2017-02-04 44 views
8

我使用Django的allauth身份验证系统我用的是社会的标志与UPS这样的“下一个”参数:添加屏幕第二签名支持社会注册allauth

<a data-provider="facebook" 
    href="{% provider_login_url "facebook" method="oauth2" next=next %}"> 

下一个地方是一个动态变量。

但是,我想为该过程注入第二个屏幕,要求输入一个打电话号码或其他信息。

我想我会需要重写一个方法重定向到第二个屏幕,并将下一个参数传递给此视图。

任何想法重写哪种方法?

编辑: 我想通了如何为“正常”的注册流程做到这一点:

我推翻了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() 

然后将自定义视图添加到我自己的帐户/注册网址文件中。

但是我无法在社交注册视图中找到该方法。有没有人知道下一个参数在社交注册视图中的评估?

编辑2:

所以我做了一些挖掘。该标志是在sociallogin类方法用于:

@classmethod 
def state_from_request(cls, request): 
    if next_url: 
     state['next'] = next_url 
    return state 

后,其通过在供应商助手complete_social_login或complete_social_signup(目前还不能确定何时叫什么)。

最后有一个函数account/utils perform_login实际执行重定向。

不知道到现在为止,还在挖掘哪里。

所以最后说到:

的socialaccount视图调用helpers.complete_social_signup然后调用与重定向URL完成注册。

我觉得生病必须重写该视图,然后通过我自己的完整社交注册方法。

EDIT3:

如果已经启用autosignup(我做)的SocialSignup ClassView中永远不会被调用,而不是新用户在创建socialaccount.helpers._process_signup。

+0

想要在用户使用社交网站之前咨询额外信息吗?或之后? –

+0

之后,我可以确认他们的社交数据并询问额外信息。 – Julian

回答

0

结束forking django-allauth并简单地添加一个名为ACCOUNT_SIGNUP_REDIRECT的可调用的设置。

def custom_signup_redirect(success_url): 
    ret = '/whatever/url/?next=' + success_url 
    return ret 

,然后在设置:

ACCOUNT_SIGNUP_REDIRECT = 'myapp.utils.custom_signup_redirect' 

this提交。