Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

Restrict ecommerce website signup to certain email domain

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
developmentshop
2 Réponses
1788 Vues
Avatar
Admin matprotect

Hello,

I would like to only allow users from my own company to signup to my ecommerce website. They all have an email address ending with MyCompany domain name like this "XXXX@MyCompany.com" so I would like to restrict new signups based on the email address.

How to best implement this?

Any help would be much appreciated 🙏

1
Avatar
Ignorer
Josep Anton Belchi Riera

You can restrict the creation of new users in Odoo.



With this setting, only users with your invitation can create an account in Odoo.

Odiware Technologies

1. Override the Signup Controller

Modify Odoo’s auth_signup controller to check the email domain before allowing registration.

📌 Steps:

  1. Create a new module or update your existing custom module.
  2. Extend the AuthSignupHome controller to restrict email domains.

📌 Example Code (Python - Controller Override):

python

CopyEdit

from odoo import http from odoo.http import request from odoo.addons.auth_signup.controllers.main import AuthSignupHome ALLOWED_DOMAIN = "mycompany.com" class CustomAuthSignup(AuthSignupHome): def do_signup(self, qcontext): email = qcontext.get('email', '').strip().lower() if not email.endswith(f"@{ALLOWED_DOMAIN}"): raise ValueError("Signup is restricted to MyCompany employees only.") return super(CustomAuthSignup, self).do_signup(qcontext)

2. Modify Signup Form to Show Error Message

You can customize the signup page template to display a warning message if users enter an invalid email.

📌 Steps:

  1. Edit the views/auth_signup_login.xml file in your custom module.
  2. Add a validation script to check the email before submission.

📌 Example (JavaScript - Client-Side Validation):

javascript

CopyEdit

document.addEventListener("DOMContentLoaded", function () { document.querySelector("#signup_form").addEventListener("submit", function (event) { var email = document.querySelector("input[name='email']").value; if (!email.endsWith("@mycompany.com")) { alert("Signup is restricted to MyCompany employees only."); event.preventDefault(); } }); });

3. Hide Signup Option for Non-Company Emails

If you want to completely disable signup for external users, you can restrict the “Sign Up” button in the website settings:

📌 Steps:

  1. Go to Website > Configuration > Settings.
  2. Under Customer Accounts, select “Customers Only”.
  3. Enable Login Required to prevent public users from accessing the signup page.

Avatar
Abhay Singh
Meilleure réponse

If you're not developer than this is the easiest solution you can implement by yourself:

  1. Go to Automated Actions:
    • In Odoo, navigate to "Settings" (or "Technical Settings" if you don't see Settings).
    • Search for "Automated Actions" and open it.
  2. Create a New Automated Action:
    • Click "Create".
  3. Configure the Automated Action:
    • Model: Select "Users" (res.users).
    • Trigger: Select "On Creation".
    • Apply on: Leave as "All Records" (or you can add a condition if needed).
    • Action To Do: Select "Execute Python Code".
  4. Python Code:
    • In the "Python Code" section, enter the following code:
# Allow only users with email ending in "@mycompany.com"
allowed_domain = "@mycompany.com"
user_email = record.email or record.login  # fallback to login if email is not set

if user_email and not user_email.lower().endswith(allowed_domain.lower()):
    raise UserError("Signup is restricted to users with @mycompany.com email addresses.")

5. Save and Close


If you know how to code then use this solution:
Add this code in some module or create your own custom module and add this code to fix it.

from odoo import models, fields, api
from odoo.exceptions import ValidationError

class ResUsers(models.Model):
    _inherit = 'res.users'

    @api.model
    def create(self, vals):
        if 'login' in vals and not vals['login'].endswith('@MyCompany.com'):
            raise ValidationError("Only users with @MyCompany.com email addresses can sign up.")
        return super(ResUsers, self).create(vals)


I hope it helps.

Thanks,
Abhay

1
Avatar
Ignorer
Avatar
Admin matprotect
Auteur Meilleure réponse

Hello,

Thank you for your answer, it is very helpful.

I am going the automated action way, however your code raises an error:

forbidden opcode(s) in '# Available variables:\n#  - env: environment on which the action is triggered\n#  - model: model of the record on which the action is triggered; is a void recordset\n#  - record: record on which the action is triggered; may be void\n#  - records: recordset of all records on which the action is triggered in multi-mode; may be void\n#  - time, datetime, dateutil, timezone: useful Python libraries\n#  - float_compare: utility function to compare floats based on specific precision\n#  - b64encode, b64decode: functions to encode/decode binary data\n#  - log: log(message, level=\'info\'): logging function to record debug information in ir.logging table\n#  - _logger: _logger.info(message): logger to emit messages in server logs\n#  - UserError: exception class for raising user-facing warning messages\n#  - Command: x2many commands namespace\n# To return an action, assign: action = {...}\n\nif record.login and "@MyCompany.com" not in record.login:\n    record.active = False\n    tag_id = env[\'ir.model.data\']._xmlid_to_res_id(\'your_module.invalid_email_tag\')  # Replace with your tag\'s XML ID\n    if tag_id:\n        record.write({\'category_id\': [(4, tag_id)]})\n    record.message_post(body="User deactivated and tagged: Invalid email domain. Only @MyCompany.com emails are allowed.")': STORE_ATTR

Any help with that?

0
Avatar
Ignorer
Abhay Singh

I updated my code in the original comment, try now and let me know if it works for you

Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
E-Commerce
development shop
Avatar
Avatar
2
mars 25
1885
Change the Checkout name in Odoo 18 Résolu
development workflow shop
Avatar
Avatar
2
juil. 25
2046
customizing print label
development system shop
Avatar
0
mars 25
1460
How do I change the name of the module, or rather the name assigned to the module, after I created it in Odoo Studio?
development
Avatar
1
nov. 25
229
Guest House Module - Rental Search Bar
development
Avatar
Avatar
1
nov. 25
114
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now