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