Browse Source

Oct 23: [FIX] Bug Fixed 'user_password_strength'

pull/347/head
Cybrosys Technologies 6 months ago
parent
commit
5821581dd2
  1. 7
      user_password_strength/__manifest__.py
  2. BIN
      user_password_strength/static/description/assets/modules/module01.png
  3. BIN
      user_password_strength/static/description/assets/modules/module02.png
  4. BIN
      user_password_strength/static/description/assets/modules/module03.png
  5. BIN
      user_password_strength/static/description/assets/modules/module04.png
  6. BIN
      user_password_strength/static/description/assets/modules/module05.png
  7. BIN
      user_password_strength/static/description/assets/modules/module06.png
  8. BIN
      user_password_strength/static/description/assets/screenshots/PSCO5.png
  9. BIN
      user_password_strength/static/description/assets/screenshots/hero.gif
  10. 32
      user_password_strength/static/description/index.html
  11. 133
      user_password_strength/static/src/js/reset_user.js
  12. 210
      user_password_strength/static/src/js/signup_user.js
  13. 2
      user_password_strength/views/restrict_password.xml
  14. 3
      user_password_strength/views/signup_page_view.xml

7
user_password_strength/__manifest__.py

@ -20,7 +20,7 @@
# #
########################################################################### ###########################################################################
{ {
'name': "User Password Strength", 'name': "User Password Strength - Restrict Weak Password",
'version': "17.0.1.0.0", 'version': "17.0.1.0.0",
'summary': """ User password strength - restrict weak password""", 'summary': """ User password strength - restrict weak password""",
'description': """ Customized setting to restrict weak password which is 'description': """ Customized setting to restrict weak password which is
@ -38,7 +38,10 @@
], ],
'images': ['static/description/banner.jpg'], 'images': ['static/description/banner.jpg'],
'assets': { 'assets': {
'web.assets_frontend': ['user_password_strength/static/src/js/signup_user.js', ], 'web.assets_frontend': [
'user_password_strength/static/src/js/signup_user.js',
'user_password_strength/static/src/js/reset_user.js',
],
}, },
'license': "AGPL-3", 'license': "AGPL-3",
'installable': True, 'installable': True,

BIN
user_password_strength/static/description/assets/modules/module01.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

BIN
user_password_strength/static/description/assets/modules/module02.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

BIN
user_password_strength/static/description/assets/modules/module03.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

BIN
user_password_strength/static/description/assets/modules/module04.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
user_password_strength/static/description/assets/modules/module05.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
user_password_strength/static/description/assets/modules/module06.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

BIN
user_password_strength/static/description/assets/screenshots/PSCO5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

BIN
user_password_strength/static/description/assets/screenshots/hero.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 209 KiB

32
user_password_strength/static/description/index.html

@ -4,7 +4,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Odoo App 3 Index</title> <title>User password strength - restrict weak password</title>
<!-- Bootstrap CSS --> <!-- Bootstrap CSS -->
<link rel="stylesheet" <link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css"
@ -48,7 +48,7 @@
style="margin: 80px 0px !important;"> style="margin: 80px 0px !important;">
<h1 style="font-size: 2.8rem;font-weight: 700; color: <h1 style="font-size: 2.8rem;font-weight: 700; color:
#1A202C;"> #1A202C;">
User Password Strength - Restrict Weak Password</h1> USER PASSWORD STRENGTH - RESTRICT WEAK PASSWORD</h1>
<p class="my-3 mb-4" <p class="my-3 mb-4"
style="max-width: 80%; font-weight: 400 !important; line-height: 32px; color: #718096;"> style="max-width: 80%; font-weight: 400 !important; line-height: 32px; color: #718096;">
User Password Strength - Configurable setting to restrict User Password Strength - Configurable setting to restrict
@ -226,7 +226,32 @@
If selected conditions of the password is not satisfies the user password an error message will appear as warning about the conditions in signup form and restricting further signup.</h4> If selected conditions of the password is not satisfies the user password an error message will appear as warning about the conditions in signup form and restricting further signup.</h4>
</div> </div>
</div> </div>
</div><div class="col-lg-12 py-2" </div>
<div class="col-lg-12 py-2"
style="padding: 1rem 4rem !important;">
<div
style="border: 1px solid #d8d6d6; border-radius: 4px; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);">
<div class="px-3">
<u>
<h4 class="my-2"
style="font-family: 'Roboto', sans-serif !important; font-weight: 600 !important; color: #282F33 !important; font-size: 1.3rem !important;">
Create a New Password</h4>
</u>
</div>
<div class="row justify-content-center p-3 w-100 m-0">
<img src="assets/screenshots/PSCO5.png"
class="img-responsive" width="100%"
height="auto">
<div class="px-3">
<h4 class="mt-2"
style=" font-weight:600 !important; color:#282F33 !important; font-size:1.3rem !important">
Users can create a new password by ensuring it is strong, using a mix of uppercase and lowercase letters, numbers, and special characters.</h4>
</div>
</div>
</div>
</div>
<div class="col-lg-12 py-2"
style="padding: 1rem 4rem !important;"> style="padding: 1rem 4rem !important;">
<div <div
style="border: 1px solid #d8d6d6; border-radius: 4px; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);"> style="border: 1px solid #d8d6d6; border-radius: 4px; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);">
@ -245,6 +270,7 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div id="tab2" class="tab-pane fade"> <div id="tab2" class="tab-pane fade">

133
user_password_strength/static/src/js/reset_user.js

@ -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;
}
});
},
});

210
user_password_strength/static/src/js/signup_user.js

@ -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;
}
},
}); });

2
user_password_strength/views/restrict_password.xml

@ -1,10 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<odoo> <odoo>
<!-- Inherit and Extend Base Settings Form View -->
<record id="res_config_settings_inherit_view_form" model="ir.ui.view"> <record id="res_config_settings_inherit_view_form" model="ir.ui.view">
<field name="name">res.config.settings.inherit.view</field> <field name="name">res.config.settings.inherit.view</field>
<field name="model">res.config.settings</field> <field name="model">res.config.settings</field>
<field name="inherit_id" ref="base.res_config_settings_view_form"/> <field name="inherit_id" ref="base.res_config_settings_view_form"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<!-- Insert our new settings after the existing password reset section -->
<xpath expr="//setting[@id='enable_password_reset']" position="after"> <xpath expr="//setting[@id='enable_password_reset']" position="after">
<div class="col-12 col-lg-6 o_setting_box" <div class="col-12 col-lg-6 o_setting_box"
id="enable_password_restrict"> id="enable_password_restrict">

3
user_password_strength/views/signup_page_view.xml

@ -1,7 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<odoo> <odoo>
<!-- Inherit and Extend the Standard Auth Signup Fields Template -->
<template id="document_fields" inherit_id="auth_signup.fields"> <template id="document_fields" inherit_id="auth_signup.fields">
<xpath expr="//input[@name='password']" position="after"> <xpath expr="//input[@name='password']" position="after">
<br>
</br>
<div> <div>
<progress id="progress" value="0" max="100" <progress id="progress" value="0" max="100"
style="color: red;">70</progress> style="color: red;">70</progress>

Loading…
Cancel
Save