Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auth login: websale #8

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion auth_oauth_autologin/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Auth Oauth Autologin",
"summary": """
Automatically redirect to the OAuth provider for login""",
"version": "16.0.1.0",
"version": "16.0.2.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA), Deepa, The Open Source Company (TOSC)",
"maintainers": ["sbidoul"],
Expand Down
33 changes: 25 additions & 8 deletions auth_oauth_autologin/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from odoo.addons.auth_oauth.controllers.main import OAuthLogin
from odoo.addons.web.controllers.session import Session
from odoo.addons.website.controllers.main import Website as WebsiteHome
from odoo.addons.website_sale.controllers.main import WebsiteSale
from odoo.http import request

import logging
Expand Down Expand Up @@ -52,15 +53,31 @@ def logout(self, redirect='/web'):
redirect = '/logout'
return super(SessionLogout, self).logout(redirect=redirect)


class WebsiteHome(WebsiteHome):

@http.route('/', type='http', auth="public", website=True, sitemap=True)
def index(self, **kw):
""" Autologin, if website app is installed """
# Open this block, if auto login needed on Index/Home page.
# class WebsiteHome(WebsiteHome):
#
# @http.route('/', type='http', auth="public", website=True, sitemap=True)
# def index(self, **kw):
# """ Autologin, if website app is installed """
#
# if not request.session.uid:
# return request.redirect('/web/login')
#
# return super().index(**kw)


class WebsiteSale(WebsiteSale):

@http.route([
'/shop',
'/shop/page/<int:page>',
'/shop/category/<model("product.public.category"):category>',
'/shop/category/<model("product.public.category"):category>/page/<int:page>',
], type='http', auth="public", website=True, sitemap=WebsiteSale.sitemap_shop)
def shop(self, page=0, category=None, search='', min_price=0.0, max_price=0.0, ppg=False, **post):
""" Autologin, if website_sale is installed """

if not request.session.uid:
# return http.redirect_with_hash('/web/login')
return request.redirect('/web/login')

return super().index(**kw)
return super().shop(self, page, category, search, min_price, max_price, ppg, **post)
Loading