Skip to Content
Menu
This question has been flagged

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 


Avatar
Discard
Author Best Answer


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.



Avatar
Discard
Best Answer

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

Thanks

Avatar
Discard
Related Posts Replies Views Activity
2
Jan 25
5119
1
Jan 20
8607
0
Feb 23
1906
3
Oct 19
5690
0
Aug 21
3893