diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/mail_client_extension/models/ir_http.py | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/mail_client_extension/models/ir_http.py')
| -rw-r--r-- | addons/mail_client_extension/models/ir_http.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/addons/mail_client_extension/models/ir_http.py b/addons/mail_client_extension/models/ir_http.py new file mode 100644 index 00000000..e69a1232 --- /dev/null +++ b/addons/mail_client_extension/models/ir_http.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from werkzeug.exceptions import BadRequest + +from odoo import models +from odoo.http import request + +class IrHttp(models.AbstractModel): + _inherit = 'ir.http' + + @classmethod + def _auth_method_outlook(cls): + access_token = request.httprequest.headers.get('Authorization') + if not access_token: + raise BadRequest('Access token missing') + + if access_token.startswith('Bearer '): + access_token = access_token[7:] + + user_id = request.env["res.users.apikeys"]._check_credentials(scope='odoo.plugin.outlook', key=access_token) + if not user_id: + raise BadRequest('Access token invalid') + + # take the identity of the API key user + request.uid = user_id
\ No newline at end of file |
