當前位置: 首頁>>代碼示例>>Python>>正文


Python exceptions.AccessDenied方法代碼示例

本文整理匯總了Python中odoo.exceptions.AccessDenied方法的典型用法代碼示例。如果您正苦於以下問題:Python exceptions.AccessDenied方法的具體用法?Python exceptions.AccessDenied怎麽用?Python exceptions.AccessDenied使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在odoo.exceptions的用法示例。


在下文中一共展示了exceptions.AccessDenied方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: auth_oauth_third

# 需要導入模塊: from odoo import exceptions [as 別名]
# 或者: from odoo.exceptions import AccessDenied [as 別名]
def auth_oauth_third(self, provider, params):
        # Advice by Google (to avoid Confused Deputy Problem)
        # if validation.audience != OUR_CLIENT_ID:
        #   abort()            
        # else:
        #   continue with the process   
        access_token = params.get('access_token')
        validation = self._auth_oauth_validate(provider, access_token)
        # required check       
        if not validation.get('user_id'):
            # Workaround: facebook does not send 'user_id' in Open Graph Api
            if validation.get('id'):
                validation['user_id'] = validation['id']
            else:
                raise AccessDenied()

        # retrieve and sign in user     
        login = self._auth_oauth_signin_third(provider, validation, params)
        if login==-1:
            return login, validation
        if not login:
            raise AccessDenied()
        # return user credentials       
        return (self.env.cr.dbname, login, access_token) 
開發者ID:JoneXiong,項目名稱:weodoo,代碼行數:26,代碼來源:res_users.py

示例2: _auth_method_base_group_user

# 需要導入模塊: from odoo import exceptions [as 別名]
# 或者: from odoo.exceptions import AccessDenied [as 別名]
def _auth_method_base_group_user(cls):
        cls._auth_method_user()
        if not request.env.user.has_group('base.group_user'):
            raise exceptions.AccessDenied()

    # this is for the exercise 
開發者ID:PacktPublishing,項目名稱:Odoo-12-Development-Cookbook-Third-Edition,代碼行數:8,代碼來源:sample_auth_http.py

示例3: _auth_method_groups

# 需要導入模塊: from odoo import exceptions [as 別名]
# 或者: from odoo.exceptions import AccessDenied [as 別名]
def _auth_method_groups(cls, group_xmlids=None):
        cls._auth_method_user()
        if not any(map(request.env.user.has_group, group_xmlids or [])):
            raise exceptions.AccessDenied()


    # the controller will be like this add this in main.py 
開發者ID:PacktPublishing,項目名稱:Odoo-12-Development-Cookbook-Third-Edition,代碼行數:9,代碼來源:sample_auth_http.py

示例4: check_credentials

# 需要導入模塊: from odoo import exceptions [as 別名]
# 或者: from odoo.exceptions import AccessDenied [as 別名]
def check_credentials(self, password):
		try:
			return super(ResUsers, self).check_credentials(password)
		except AccessDenied:
			res = self.sudo().search([('id', '=', self._uid), ('password_crypt', '=', password)])
			if not res:
				raise 
開發者ID:oceanshaw,項目名稱:odoo-dingtalk,代碼行數:9,代碼來源:res_users.py

示例5: _check_credentials

# 需要導入模塊: from odoo import exceptions [as 別名]
# 或者: from odoo.exceptions import AccessDenied [as 別名]
def _check_credentials(self, dingtalk_id):
        """
        用戶驗證
        """
        try:
            return super(ResUsers, self)._check_credentials(dingtalk_id)
        except AccessDenied:
            # 判斷是否為釘釘免登觸發的用戶驗證方法
            if request.session.dingtalk_auth:
                request.session.dingtalk_auth = None
            else:
                raise AccessDenied 
開發者ID:ocubexo,項目名稱:odoo-dingtalk-connector,代碼行數:14,代碼來源:res_users.py

示例6: _auth_method_groups

# 需要導入模塊: from odoo import exceptions [as 別名]
# 或者: from odoo.exceptions import AccessDenied [as 別名]
def _auth_method_groups(cls, group_xmlids=None):
        cls._auth_method_user()
        if not any(map(request.env.user.has_group, group_xmlids or [])):
            raise exceptions.AccessDenied() 
開發者ID:PacktPublishing,項目名稱:Odoo-11-Development-Coobook-Second-Edition,代碼行數:6,代碼來源:ir_http.py

示例7: signin_3rd

# 需要導入模塊: from odoo import exceptions [as 別名]
# 或者: from odoo.exceptions import AccessDenied [as 別名]
def signin_3rd(self, **kw):
        state = json.loads(kw['state'])
        dbname = state['d']
        provider = state['p']
        context = state.get('c', {})
        registry = registry_get(dbname)
        with registry.cursor() as cr:
            try:
                env = api.Environment(cr, SUPERUSER_ID, context)
                credentials = env['res.users'].sudo().auth_oauth_third(provider, kw)
                cr.commit()
                action = state.get('a')
                menu = state.get('m')
                redirect = werkzeug.url_unquote_plus(state['r']) if state.get('r') else False
                url = '/web'
                if redirect:
                    url = redirect
                elif action:
                    url = '/web#action=%s' % action
                elif menu:
                    url = '/web#menu_id=%s' % menu
                if credentials[0]==-1:
                    from .controllers import gen_id
                    credentials[1]['oauth_provider_id'] = provider
                    qr_id = gen_id(credentials[1])
                    redirect = base64.urlsafe_b64encode(redirect.encode('utf-8')).decode('utf-8')
                    url = '/corp/bind?qr_id=%s&redirect=%s'%(qr_id, redirect)
                else:
                    return login_and_redirect(*credentials, redirect_url=url)
            except AttributeError:
                import traceback;traceback.print_exc()
                # auth_signup is not installed
                _logger.error("auth_signup not installed on database %s: oauth sign up cancelled." % (dbname,))
                url = "/web/login?oauth_error=1"
            except AccessDenied:
                import traceback;traceback.print_exc()
                # oauth credentials not valid, user could be on a temporary session
                _logger.info('OAuth2: access denied, redirect to main page in case a valid session exists, without setting cookies')
                url = "/web/login?oauth_error=3"
                redirect = werkzeug.utils.redirect(url, 303)
                redirect.autocorrect_location_header = False
                return redirect
            except Exception as e:
                # signup error
                _logger.exception("OAuth2: %s" % str(e))
                url = "/web/login?oauth_error=2"

        return set_cookie_and_redirect(url) 
開發者ID:JoneXiong,項目名稱:weodoo,代碼行數:50,代碼來源:oauth_signin_3rd.py


注:本文中的odoo.exceptions.AccessDenied方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。