コード例 #1
0
    def __disconnect_form(_next=None, usas=None, providers=None):
        usas = usas or UserSocialAuth.get_social_auth_for_user(
            get_current_user())
        usas_no_openid = [usa for usa in usas if usa.provider != 'openid']
        providers = providers or SocialAuth.__get_providers()

        # Add list with currently connected accounts
        form = FORM(
            SELECT(_name='association_id', _size=5),
            INPUT(_type="hidden", _name="next", _value=_next),
            DIV(
                INPUT(_value='Disconnect', _type='submit'
                      ) if len(usas) > 1 else ''))

        for usa in usas_no_openid:
            form[0].append(OPTION(providers[usa.provider], _value=usa.id))

        i = 0
        for usa in [x for x in usas if x.provider == 'openid']:
            i += 1
            form[0].append(
                OPTION('OpenID [%s]' % urlparse(usa.uid).hostname,
                       _value=usa.id))

        form[0][0]['_selected'] = 'selected'

        return form
コード例 #2
0
ファイル: utils.py プロジェクト: bnmnetp/w2p-social-auth
        def wrapper(*args, **kwargs):
            r = current.request
            uri = redirect_uri
            backend = r.vars.backend
            association_id = r.vars.association_id

            if association_id and not backend:
                usa = UserSocialAuth.get_social_auth_for_user(association_id=association_id)
                if usa and len(usa) > 0:
                    backend = usa[0].provider

            current.strategy = load_strategy(request=r,
                                             backend=backend,
                                             redirect_uri=url_for(uri, backend),
                                             *args, **kwargs)
            return func(*args, **kwargs)
コード例 #3
0
    def associations(self):
        """Shows form to manage social account associations."""

        self.__add_static_files()

        nextt = URL(args=['associations'])

        usas = UserSocialAuth.get_social_auth_for_user(get_current_user())
        providers = SocialAuth.__get_providers()

        form1 = self.__disconnect_form(usas=usas,
                                       providers=providers,
                                       _next=nextt)

        backends = [
            backend for backend in SocialAuth.__get_backends().keys()
            if backend not in [x.provider
                               for x in usas] and backend in providers
        ]

        if self.__setting('SOCIAL_AUTH_UI_STYLE') == 'buttons':
            form2 = self.__button_form(_next=nextt, backends=backends)
        else:
            form2 = self.__dropdown_form(
                _next=nextt,
                button_label=current.plugin_social_auth.T("Connect"),
                backends=backends)

        form3 = self.__openid_form(_next=nextt)

        if form1.process(formname='form_one').accepted:
            return _disconnect()
        if form2.process(formname='form_two').accepted or form3.process(
                formname='form_three').accepted:
            return _auth()

        form = DIV(
            FIELDSET(LEGEND(current.plugin_social_auth.T('Your logons')),
                     form1),
            FIELDSET(
                LEGEND(current.plugin_social_auth.T('Add new logon')), form2,
                P(
                    EM(
                        current.plugin_social_auth.T(
                            'Or manually enter your OpenId:'))), form3))

        return dict(form=form)
コード例 #4
0
        def wrapper():
            r = current.request
            print('backend', r.vars.backend)
            uri = redirect_uri
            #backend = r.vars.backend
            backend = current.session.backend
            association_id = r.vars.association_id

            if association_id and not backend:
                usa = UserSocialAuth.get_social_auth_for_user(association_id=association_id)
                if usa and len(usa) > 0:
                    backend = usa[0].provider

            current.strategy = load_strategy(request=r)
            current.backend = load_backend(current.strategy, backend, uri)
            #current.strategy = load_strategy(request=r,
            #                                 backend=backend,
            #                                 redirect_uri=url_for(uri, backend),
            #                                 *args, **kwargs)
            return func()
コード例 #5
0
ファイル: utils.py プロジェクト: bnmnetp/w2p-social-auth
    def __disconnect_form(_next=None, usas=None, providers=None):
        usas = usas or UserSocialAuth.get_social_auth_for_user(get_current_user())
        usas_no_openid = [usa for usa in usas if usa.provider != 'openid']
        providers = providers or SocialAuth.__get_providers()

        # Add list with currently connected accounts
        form = FORM(SELECT(_name='association_id', _size=5),
                    INPUT(_type="hidden", _name="next", _value=_next),
                    DIV(INPUT(_value='Disconnect', _type='submit') if len(usas) > 1 else ''))

        for usa in usas_no_openid:
            form[0].append(OPTION(providers[usa.provider], _value=usa.id))

        i = 0
        for usa in [x for x in usas if x.provider == 'openid']:
            i += 1
            form[0].append(OPTION('OpenID [%s]' % urlparse(usa.uid).hostname, _value=usa.id))

        form[0][0]['_selected'] = 'selected'

        return form
コード例 #6
0
ファイル: utils.py プロジェクト: DonaldMc/gdms
        def wrapper(*args, **kwargs):
            r = current.request
            uri = redirect_uri
            backend = r.vars.backend
            association_id = r.vars.association_id

            if association_id and not backend:
                usa = UserSocialAuth.get_social_auth_for_user(association_id=association_id)
                if usa and len(usa) > 0:
                    backend = usa[0].provider

            current.strategy = load_strategy(request=r,
                                             backend=backend,
                                             redirect_uri=url_for(uri, backend),
                                             *args, **kwargs)
            #current.strategy = load_strategy(request=r,
            #                                 backend=backend,
            #                                 redirect_uri='http://dmcc.pythonanywhere.com//gdms/plugin_social_auth/complete',
            #                                 *args, **kwargs)
            print('red' + redirect_uri)
            return func(*args, **kwargs)
コード例 #7
0
ファイル: utils.py プロジェクト: bnmnetp/w2p-social-auth
    def associations(self):
        """Shows form to manage social account associations."""

        self.__add_static_files()

        nextt = URL(args=['associations'])

        usas = UserSocialAuth.get_social_auth_for_user(get_current_user())
        providers = SocialAuth.__get_providers()

        form1 = self.__disconnect_form(usas=usas, providers=providers, _next=nextt)

        backends = [backend for backend in SocialAuth.__get_backends().keys() if
                    backend not in [x.provider for x in usas] and backend in providers]

        if self.__setting('SOCIAL_AUTH_UI_STYLE') == 'buttons':
            form2 = self.__button_form(_next=nextt, backends=backends)
        else:
            form2 = self.__dropdown_form(_next=nextt, button_label=current.plugin_social_auth.T("Connect"),
                                         backends=backends)

        form3 = self.__openid_form(_next=nextt)

        if form1.process(formname='form_one').accepted:
            return _disconnect()
        if form2.process(formname='form_two').accepted or form3.process(formname='form_three').accepted:
            return _auth()

        form = DIV(FIELDSET(LEGEND(current.plugin_social_auth.T('Your logons')),
                            form1),
                   FIELDSET(LEGEND(current.plugin_social_auth.T('Add new logon')),
                            form2,
                            P(EM(current.plugin_social_auth.T('Or manually enter your OpenId:'))),
                            form3))

        return dict(form=form)