Пример #1
0
    def auth(self, action='', next='', scope=SNSAPI_BASE, state='STATE'):
        """发起微信登录,在需要的地方带用即可。

        :param action: 公众号授权登录(mp)、扫码登录(qrcode)
        :param next: 授权后下一步链接
        :param scope: snsapi_base|snsapi_userinfo
        :param state: STATE
        """
        action = self.get_action(action)
        if action == 'mobile' or is_json():
            return abort(WXAUTH_REQUIRED)

        return redirect(self.get_auth_url(action, next, scope, state))
Пример #2
0
    def auth(self, action='', next='', scope=SNSAPI_BASE, state='STATE'):
        """发起微信登录,在需要的地方带用即可。

        :param action: 公众号授权登录(mp)、扫码登录(qrcode)
        :param next: 授权后下一步链接
        :param scope: snsapi_base|snsapi_userinfo
        :param state: STATE
        """
        action = self.get_action(action)
        if action == 'mobile' or is_json():
            return abort(WXAUTH_REQUIRED)

        return redirect(self.get_auth_url(action, next, scope, state))
Пример #3
0
    def auth(self,
             action='',
             next='',
             scope=SNSAPI_BASE,
             state='STATE',
             config=None,
             **kwargs):
        """发起微信登录,在需要的地方带用即可。

        :param action: 公众号授权登录(mp)、扫码登录(qrcode)
        :param next: 授权后下一步链接
        :param scope: snsapi_base|snsapi_userinfo
        :param state: STATE
        """
        action = self.get_action(action)
        if action == 'mobile' or is_json() \
   and (next is None or next.find('redirect=true') == -1):
            return abort(WXAUTH_REQUIRED)

        if config is None:
            config = self.load_config()

        return redirect(
            self.get_auth_url(action, next, scope, state, config, **kwargs))
Пример #4
0
    def wxauth_error(err, action, next):
        if is_json():
            abort(WXAUTH_ERROR, wxcode=err, wxmsg=wxauth.MSGS.get(err, '未知错误'))

        return error('微信授权失败')
Пример #5
0
    def wxauth_error(err, action, next):
        if is_json():
            abort(WXAUTH_ERROR, wxcode=err, wxmsg=wxauth.MSGS.get(err, '未知错误'))

        return error('微信授权失败')
Пример #6
0
    def auth(self, action='', next='', scope=SNSAPI_BASE, state='STATE'):
        action = self.get_action(action)
        if action == 'mobile' or is_json():
            return abort(WXAUTH_REQUIRED)

        return redirect(self.get_auth_url(action, next, scope, state))
Пример #7
0
    def auth(self, action='', next='', scope=SNSAPI_BASE, state='STATE'):
        action = self.get_action(action)
        if action == 'mobile' or is_json():
            return abort(WXAUTH_REQUIRED)

        return redirect(self.get_auth_url(action, next, scope, state))