Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie

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 


Awatar
Odrzuć
Autor Najlepsza odpowiedź


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.



Awatar
Odrzuć
Najlepsza odpowiedź

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

Thanks

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
sty 25
5710
1
sty 20
9043
0
lut 23
2274
3
paź 19
6097
0
sie 21
4524