Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
1156 Vizualizări

Odoo v17.  

https://apps.odoo.com/apps/modules/16.0/auth_user_case_insensitive/ isn't released for v17 yet.   



It's surpising how some sites still allow this.  I've seen conversations that support upper/lower case email addresses.  Can be problematic for some users.  I have also noticed that at times a trailing space could exist.


If you have run into this issue, here we go.


Steps to reproduce:

Sign up with a new email address: " new Customerwith spaces@gmail.com  "


Current behavior:

System allows account to be created


Expected behavior:

Should either provide an error or stirp out spaces and convert to lower 


Imagine profil
Abandonează
Autor Cel mai bun răspuns


The code to add an oninput attribute to remove spaces and convert to lower case whenver anything is typed:

... oninput="this.value = this.value.toLowerCase().replace(/\s/g, '')

We're going to edit the signup HTML

Signup Page / account creation:  /web?debug=1#id=7066&cids=1&menu_id=43&action=30&model=ir.ui.view&view_type=form

Update this line:

input type="text" placeholder="Email" name="login" t-att-value="login" id="login" t-attf-class="form-control #{'form-control-sm' if form_small else ''}" required="required" autocomplete="username" autofocus="autofocus" autocapitalize="off"

New Code:

input type="text" name="login" t-att-value="login" id="login" class="form-control form-control-sm" autofocus="autofocus" autocapitalize="off" required="required" t-att-readonly="'readonly' if only_passwords else None" oninput="this.value = this.value.toLowerCase().replace(/\s/g, '')"



Login Page:  /web?debug=1#id=7066&cids=1&menu_id=43&action=30&model=ir.ui.view&view_type=form
Update the following code:

input type="text" placeholder="Email" name="login" t-att-value="login" id="login" t-attf-class="form-control #{'form-control-sm' if form_small else ''}" required="required" autocomplete="username" autofocus="autofocus" autocapitalize="off"

Updated code:

input type="text" placeholder="Email" name="login" t-att-value="login" id="login" t-attf-class="form-control #{'form-control-sm' if form_small else ''}" required="required" autocomplete="username" autofocus="autofocus" autocapitalize="off" oninput="this.value = this.value.toLowerCase().replace(/\s/g, '')"


This will work for all new logins.  However if you already have mixed-case email addresses, you may run into an issue.  I've seen an addon to go through existing data sets to rectify this. 


Hope this helps someone.



Imagine profil
Abandonează
Cel mai bun răspuns

Hi, this might help you: https://youtu.be/An6YTH3kJD8

Thanks

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
ian. 25
5710
1
ian. 20
9043
0
feb. 23
2274
3
oct. 19
6097
0
aug. 21
4524