-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] shopinvader_api_signin_jwt: Call promote directly at signin
- Loading branch information
1 parent
0c7a3f1
commit 98f70b6
Showing
5 changed files
with
55 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
This addon adds a web API to signin into the application and create a partner | ||
if the email in the jwt payload is unknown. | ||
|
||
This addon supports the "anonymous partner" feature, which allows to create | ||
carts for user that are not loggedin. | ||
When you login from an anonymous partner, your cart is transfered to your real | ||
partner, and your anonymous partner is deleted. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,11 +9,10 @@ | |
|
||
/* | ||
:Author: David Goodger ([email protected]) | ||
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ | ||
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ | ||
:Copyright: This stylesheet has been placed in the public domain. | ||
|
||
Default cascading style sheet for the HTML output of Docutils. | ||
Despite the name, some widely supported CSS2 features are used. | ||
|
||
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to | ||
customize this style sheet. | ||
|
@@ -276,7 +275,7 @@ | |
margin-left: 2em ; | ||
margin-right: 2em } | ||
|
||
pre.code .ln { color: gray; } /* line numbers */ | ||
pre.code .ln { color: grey; } /* line numbers */ | ||
pre.code, code { background-color: #eeeeee } | ||
pre.code .comment, code .comment { color: #5C6576 } | ||
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } | ||
|
@@ -302,7 +301,7 @@ | |
span.pre { | ||
white-space: pre } | ||
|
||
span.problematic, pre.problematic { | ||
span.problematic { | ||
color: red } | ||
|
||
span.section-subtitle { | ||
|
@@ -368,11 +367,15 @@ <h1 class="title">Shopinvader Api Signin JWT</h1> | |
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:59c45a1d4cbece13c06acf5a0b621bf113fd94ed74b05de2143494c755320354 | ||
!! source digest: sha256:d2a37ed8f608aa991e96f29205867b36c47bf9ec58fd392ec4ee8d6f386da0f2 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> | ||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/shopinvader/odoo-shopinvader/tree/16.0/shopinvader_api_signin_jwt"><img alt="shopinvader/odoo-shopinvader" src="https://img.shields.io/badge/github-shopinvader%2Fodoo--shopinvader-lightgray.png?logo=github" /></a></p> | ||
<p>This addon adds a web API to signin into the application and create a partner | ||
if the email in the jwt payload is unknown.</p> | ||
<p>This addon supports the “anonymous partner” feature, which allows to create | ||
carts for user that are not loggedin. | ||
When you login from an anonymous partner, your cart is transfered to your real | ||
partner, and your anonymous partner is deleted.</p> | ||
<p><strong>Table of contents</strong></p> | ||
<div class="contents local topic" id="contents"> | ||
<ul class="simple"> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
|
||
from odoo.addons.fastapi.tests.common import FastAPITransactionCase | ||
from odoo.addons.fastapi_auth_jwt.dependencies import auth_jwt_default_validator_name | ||
from odoo.addons.shopinvader_anonymous_partner.models.res_partner import COOKIE_NAME | ||
|
||
from ..routers import signin_router | ||
|
||
|
@@ -79,6 +80,38 @@ def test_signin(self): | |
res = client.post("/signin", headers={"Authorization": token}) | ||
self.assertEqual(res.status_code, 200) | ||
|
||
def test_signin_anonymous_cart(self): | ||
anonymous_partner = self.env["res.partner"].create( | ||
{"name": "Test anonymous", "anonymous_token": "1234", "active": False} | ||
) | ||
product = self.env["product.product"].create( | ||
{"name": "product", "uom_id": self.env.ref("uom.product_uom_unit").id} | ||
) | ||
anonymous_cart = self.env["sale.order"].create( | ||
{ | ||
"partner_id": anonymous_partner.id, | ||
"order_line": [ | ||
(0, 0, {"product_id": product.id, "product_uom_qty": 1}), | ||
], | ||
"typology": "cart", | ||
} | ||
) | ||
|
||
token = self._get_token() | ||
with self._create_test_client() as client: | ||
res = client.post( | ||
"/signin", | ||
headers={"Authorization": token}, | ||
cookies={COOKIE_NAME: "1234"}, | ||
) | ||
self.assertFalse(res.cookies.get(COOKIE_NAME)) | ||
self.assertFalse(anonymous_partner.exists()) | ||
self.assertFalse(anonymous_cart.exists()) | ||
partner = self.env["res.partner"].search([("email", "=", "[email protected]")]) | ||
cart = self.env["sale.order"].search([("partner_id", "=", partner.id)]) | ||
self.assertEqual(len(cart.order_line), 1) | ||
self.assertEqual(cart.order_line[0].product_id, product) | ||
|
||
def test_signout(self): | ||
self.validator.write({"cookie_enabled": True, "cookie_name": "test_cookie"}) | ||
token = self._get_token() | ||
|