After Width: | Height: | Size: 49 KiB |
After Width: | Height: | Size: 47 KiB |
After Width: | Height: | Size: 54 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 88 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 209 KiB |
@ -0,0 +1,133 @@ |
|||
/** @odoo-module **/ |
|||
/*Extending the public widget of the signup form for checking the user |
|||
password strength conditions on input password function of the password field in |
|||
the sign up form,Based on the conditions from configuration settings*/ |
|||
import { jsonrpc } from "@web/core/network/rpc_service"; |
|||
import publicWidget from "@web/legacy/js/public/public_widget"; |
|||
|
|||
publicWidget.registry.ResetFormInputPasswordChange = publicWidget.Widget.extend({ |
|||
selector: '.oe_website_login_container', |
|||
events: { |
|||
'input input[type="password"]': '_onPasswordInput', // Using input event instead of keypress
|
|||
}, |
|||
start() { |
|||
this._super.apply(this, arguments); |
|||
}, |
|||
|
|||
_onPasswordInput: function (ev) { |
|||
// Get the password field value
|
|||
var password = ev.currentTarget.value; |
|||
|
|||
// Reset the progress bar if the password field is empty
|
|||
var progressBar = document.getElementById("progress"); |
|||
if (password.length === 0) { |
|||
if (progressBar) { |
|||
progressBar.value = "0"; |
|||
progressBar.style.backgroundColor = "#FF0000"; // Reset to red
|
|||
} |
|||
return; |
|||
} |
|||
|
|||
// Fetch configuration settings via jsonrpc
|
|||
jsonrpc('/web/config_params', {}).then(function (data) { |
|||
var conditions = []; |
|||
for (let key in data) { |
|||
conditions.push(data[key]); |
|||
} |
|||
|
|||
var flag = conditions.filter(cond => cond === 'True').length; |
|||
|
|||
// Evaluate password strength based on specific conditions
|
|||
var prog = [/[$@$!%*#?&]/, /[A-Z]/, /[0-9]/, /[a-z]/] |
|||
.reduce((memo, test) => memo + test.test(password), 0); |
|||
|
|||
if (prog > 2 && password.length > 7) { |
|||
prog++; |
|||
} |
|||
|
|||
var progress = "0"; |
|||
var colors = ['#FF0000', '#00FF00', '#0000FF']; // Red, Green, Blue for progress levels
|
|||
var currentColor = colors[0]; |
|||
|
|||
// Adjust progress based on conditions enabled
|
|||
switch (flag) { |
|||
case 5: |
|||
switch (prog) { |
|||
case 0: |
|||
case 1: |
|||
progress = "20"; |
|||
break; |
|||
case 2: |
|||
progress = "25"; |
|||
break; |
|||
case 3: |
|||
progress = "50"; |
|||
currentColor = colors[1]; // Green
|
|||
break; |
|||
case 4: |
|||
progress = "75"; |
|||
currentColor = colors[1]; // Green
|
|||
break; |
|||
case 5: |
|||
progress = "100"; |
|||
currentColor = colors[1]; // Green
|
|||
break; |
|||
} |
|||
break; |
|||
case 4: |
|||
switch (prog) { |
|||
case 0: |
|||
case 1: |
|||
case 2: |
|||
progress = "25"; |
|||
break; |
|||
case 3: |
|||
progress = "50"; |
|||
currentColor = colors[0]; // Red
|
|||
break; |
|||
case 4: |
|||
progress = "75"; |
|||
currentColor = colors[1]; // Green
|
|||
break; |
|||
case 5: |
|||
progress = "100"; |
|||
currentColor = colors[1]; // Green
|
|||
break; |
|||
} |
|||
break; |
|||
case 3: |
|||
switch (prog) { |
|||
case 0: |
|||
case 1: |
|||
case 2: |
|||
case 3: |
|||
progress = "33.33"; |
|||
break; |
|||
case 4: |
|||
progress = "66.66"; |
|||
currentColor = colors[1]; // Green
|
|||
break; |
|||
case 5: |
|||
progress = "100"; |
|||
currentColor = colors[1]; // Green
|
|||
break; |
|||
} |
|||
break; |
|||
case 2: |
|||
progress = (prog !== 5) ? "50" : "100"; |
|||
currentColor = (prog !== 5) ? colors[0] : colors[1]; // Red or Green
|
|||
break; |
|||
case 1: |
|||
progress = "100"; |
|||
currentColor = colors[1]; // Green
|
|||
break; |
|||
} |
|||
|
|||
// Update progress bar
|
|||
if (progressBar) { |
|||
progressBar.value = progress; |
|||
progressBar.style.backgroundColor = currentColor; |
|||
} |
|||
}); |
|||
}, |
|||
}); |
@ -1,135 +1,135 @@ |
|||
/** @odoo-module **/ |
|||
/*Extending the public widget of the signup form for checking the user |
|||
password strength conditions on key up function of the password field in |
|||
the sign up form,Based on the conditions from configuration settings.*/ |
|||
import { jsonrpc } from "@web/core/network/rpc_service"; |
|||
import publicWidget from "@web/legacy/js/public/public_widget"; |
|||
var password = document.getElementById("password"); |
|||
publicWidget.registry.SignUpFormKeyupChange = publicWidget.Widget.extend({ |
|||
/*Extending the public widget of the reset form for checking the user |
|||
password strength conditions on password input function of the password field in |
|||
the reset form,Based on the conditions from configuration settings.*/ |
|||
import { jsonrpc } from "@web/core/network/rpc_service"; |
|||
import publicWidget from "@web/legacy/js/public/public_widget"; |
|||
|
|||
publicWidget.registry.SignUpFormInputPasswordChange = publicWidget.Widget.extend({ |
|||
selector: '.oe_signup_form', |
|||
events: { |
|||
'keypress input': '_onKeypress', |
|||
'input input[type="password"]': '_onPasswordInput', // Listening for input event on password field
|
|||
}, |
|||
init() { |
|||
this._super(...arguments); |
|||
}, |
|||
_onKeypress: function () { |
|||
jsonrpc('/web/config_params',{}).then(function (data) { |
|||
var list=[] |
|||
for (let x in data) { |
|||
list.push(data[x]); |
|||
} |
|||
var flag = 0 |
|||
for(var i=0;i<=list.length;i++){ |
|||
if(list[i] == 'True'){ |
|||
flag +=1 |
|||
} |
|||
} |
|||
var prog = [/[$@$!%*#?&]/, /[A-Z]/, /[0-9]/, /[a-z]/] |
|||
.reduce((memo, test) => memo + test.test(current_pwd), |
|||
0); |
|||
if(prog > 2 && current_pwd.length > 7){ |
|||
prog++; |
|||
} |
|||
var progress = ""; |
|||
var colors = ['#FF0000', '#00FF00','#0000FF']; |
|||
var currentColor = 0; |
|||
//When 5 conditions are enabled in config settings
|
|||
if (flag == 5){ |
|||
|
|||
start() { |
|||
this._super.apply(this, arguments); |
|||
}, |
|||
|
|||
_onPasswordInput: function (ev) { |
|||
var passwordInput = ev.currentTarget; // Get the password input field
|
|||
var current_pwd = passwordInput.value; // Get the current password value
|
|||
|
|||
// Reset the progress bar if the password field is empty
|
|||
if (current_pwd.length === 0) { |
|||
var progressBar = document.getElementById("progress"); |
|||
if (progressBar) { |
|||
progressBar.value = "0"; |
|||
progressBar.style.backgroundColor = "#FF0000"; // Reset to red
|
|||
} |
|||
return; |
|||
} |
|||
|
|||
// Fetch configuration settings via jsonrpc
|
|||
jsonrpc('/web/config_params', {}).then(function (data) { |
|||
var conditions = []; |
|||
for (let key in data) { |
|||
conditions.push(data[key]); |
|||
} |
|||
|
|||
var flag = conditions.filter(cond => cond === 'True').length; |
|||
|
|||
// Evaluate password strength based on specific conditions
|
|||
var prog = [/[$@$!%*#?&]/, /[A-Z]/, /[0-9]/, /[a-z]/] |
|||
.reduce((memo, test) => memo + test.test(current_pwd), 0); |
|||
|
|||
if (prog > 2 && current_pwd.length > 7) { |
|||
prog++; |
|||
} |
|||
|
|||
var progress = "0"; |
|||
var colors = ['#FF0000', '#00FF00', '#0000FF']; // Red, Green, Blue for progress levels
|
|||
var currentColor = colors[0]; |
|||
|
|||
// Adjust progress based on conditions enabled
|
|||
switch (flag) { |
|||
case 5: |
|||
switch (prog) { |
|||
case 0: |
|||
case 1: |
|||
progress = "20"; |
|||
currentColor = colors[0]; |
|||
break; |
|||
progress = "20"; |
|||
break; |
|||
case 2: |
|||
progress = "25"; |
|||
currentColor = colors[0]; |
|||
break; |
|||
progress = "25"; |
|||
break; |
|||
case 3: |
|||
progress = "100"; |
|||
currentColor = colors[1]; |
|||
break; |
|||
progress = "50"; |
|||
currentColor = colors[1]; // Green
|
|||
break; |
|||
case 4: |
|||
progress = "75"; |
|||
currentColor = colors[1]; |
|||
break; |
|||
progress = "75"; |
|||
currentColor = colors[1]; // Green
|
|||
break; |
|||
case 5: |
|||
progress = "100"; |
|||
currentColor = colors[1]; |
|||
break; |
|||
progress = "100"; |
|||
currentColor = colors[1]; // Green
|
|||
break; |
|||
} |
|||
} |
|||
//When 4 conditions are enabled in config settings
|
|||
if (flag == 4){ |
|||
break; |
|||
case 4: |
|||
switch (prog) { |
|||
case 0: |
|||
case 1: |
|||
case 2: |
|||
progress = "25"; |
|||
currentColor = colors[0]; |
|||
break; |
|||
progress = "25"; |
|||
break; |
|||
case 3: |
|||
progress = "50"; |
|||
currentColor = colors[0]; |
|||
break; |
|||
progress = "50"; |
|||
currentColor = colors[0]; // Red
|
|||
break; |
|||
case 4: |
|||
progress = "75"; |
|||
currentColor = colors[1]; |
|||
break; |
|||
progress = "75"; |
|||
currentColor = colors[1]; // Green
|
|||
break; |
|||
case 5: |
|||
progress = "100"; |
|||
currentColor = colors[1]; |
|||
break; |
|||
progress = "100"; |
|||
currentColor = colors[1]; // Green
|
|||
break; |
|||
} |
|||
} |
|||
//When 3 conditions are enabled in config settings
|
|||
if (flag == 3){ |
|||
break; |
|||
case 3: |
|||
switch (prog) { |
|||
case 0: |
|||
case 1: |
|||
case 2: |
|||
case 3: |
|||
progress = "33.33"; |
|||
currentColor = colors[0]; |
|||
break; |
|||
progress = "33.33"; |
|||
break; |
|||
case 4: |
|||
progress = "66.66"; |
|||
currentColor = colors[1]; |
|||
break; |
|||
progress = "66.66"; |
|||
currentColor = colors[1]; // Green
|
|||
break; |
|||
case 5: |
|||
progress = "100"; |
|||
currentColor = colors[1]; |
|||
break; |
|||
} |
|||
} |
|||
//When 2 conditions are enabled in config settings
|
|||
if (flag == 2) { |
|||
if (prog != 5) { |
|||
progress = "50"; |
|||
currentColor = colors[0]; |
|||
} else{ |
|||
progress = "100"; |
|||
currentColor = colors[1]; |
|||
progress = "100"; |
|||
currentColor = colors[1]; // Green
|
|||
break; |
|||
} |
|||
} |
|||
//When only 1 condition is enabled in config settings
|
|||
if (flag == 1){ |
|||
break; |
|||
case 2: |
|||
progress = (prog !== 5) ? "50" : "100"; |
|||
currentColor = (prog !== 5) ? colors[0] : colors[1]; // Red or Green
|
|||
break; |
|||
case 1: |
|||
progress = "100"; |
|||
currentColor = colors[1]; |
|||
} |
|||
var val = document.getElementById("progress") |
|||
if(val!== null){ |
|||
document.getElementById("progress").value = progress; |
|||
document.getElementById("progress").style |
|||
.backgroundColor = currentColor; |
|||
} |
|||
}); |
|||
// Reset if password length is zero
|
|||
var current_pwd = password.value |
|||
if (current_pwd.length === 0) { |
|||
document.getElementById("progress").value = "0"; |
|||
return; |
|||
} |
|||
}, |
|||
currentColor = colors[1]; // Green
|
|||
break; |
|||
} |
|||
|
|||
// Update progress bar
|
|||
var progressBar = document.getElementById("progress"); |
|||
if (progressBar) { |
|||
progressBar.value = progress; |
|||
progressBar.style.backgroundColor = currentColor; |
|||
} |
|||
}); |
|||
}, |
|||
}); |
|||
|