Начальное наполнение
This commit is contained in:
parent
512b9a29da
commit
596fc91a0a
2
__init__.py
Normal file
2
__init__.py
Normal file
@ -0,0 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import controllers
|
17
__manifest__.py
Normal file
17
__manifest__.py
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
'name': "Password Policy support for Signup",
|
||||
'depends': ['auth_password_policy', 'auth_signup'],
|
||||
'category': 'Hidden/Tools',
|
||||
'auto_install': True,
|
||||
'data': [
|
||||
'views/signup_templates.xml',
|
||||
],
|
||||
'assets': {
|
||||
'web.assets_frontend': [
|
||||
'auth_password_policy_signup/static/src/public/**/*',
|
||||
'auth_password_policy/static/src/password_meter.js',
|
||||
'auth_password_policy/static/src/password_policy.js',
|
||||
],
|
||||
},
|
||||
'license': 'LGPL-3',
|
||||
}
|
10
controllers.py
Normal file
10
controllers.py
Normal file
@ -0,0 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo.http import request
|
||||
from odoo.addons.auth_signup.controllers.main import AuthSignupHome
|
||||
|
||||
class AddPolicyData(AuthSignupHome):
|
||||
def get_auth_signup_config(self):
|
||||
d = super(AddPolicyData, self).get_auth_signup_config()
|
||||
d['password_minimum_length'] = request.env['ir.config_parameter'].sudo().get_param('auth_password_policy.minlength')
|
||||
return d
|
15
i18n/auth_password_policy_signup.pot
Normal file
15
i18n/auth_password_policy_signup.pot
Normal file
@ -0,0 +1,15 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 17.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2023-10-26 21:55+0000\n"
|
||||
"PO-Revision-Date: 2023-10-26 21:55+0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
@ -0,0 +1,35 @@
|
||||
/** @odoo-module */
|
||||
|
||||
import { Meter } from "@auth_password_policy/password_meter";
|
||||
import { ConcretePolicy, recommendations } from "@auth_password_policy/password_policy";
|
||||
import { Component, useExternalListener, useState, xml } from "@odoo/owl";
|
||||
import { registry } from "@web/core/registry";
|
||||
|
||||
class PasswordMeter extends Component {
|
||||
static template = xml`
|
||||
<Meter t-if="hasMinlength"
|
||||
password="state.password"
|
||||
required="required"
|
||||
recommended="recommended"/>`;
|
||||
static components = { Meter };
|
||||
static props = {
|
||||
selector: String,
|
||||
};
|
||||
|
||||
setup() {
|
||||
const inputEl = document.querySelector(this.props.selector);
|
||||
useExternalListener(inputEl, "input", (e) => {
|
||||
this.state.password = e.target.value || "";
|
||||
});
|
||||
|
||||
const minlength = Number(inputEl.getAttribute("minlength"));
|
||||
this.hasMinlength = !isNaN(minlength);
|
||||
this.state = useState({
|
||||
password: inputEl.value || "",
|
||||
});
|
||||
this.required = new ConcretePolicy({ minlength });
|
||||
this.recommended = recommendations;
|
||||
}
|
||||
}
|
||||
|
||||
registry.category("public_components").add("password_meter", PasswordMeter);
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
<t t-name="auth_password_policy_signup.PasswordMeter">
|
||||
<Meter t-if="hasMinlength" password="state.password" required="required" recommended="recommended"/>
|
||||
</t>
|
||||
</templates>
|
6
static/src/public/scss/signup_policy.scss
Normal file
6
static/src/public/scss/signup_policy.scss
Normal file
@ -0,0 +1,6 @@
|
||||
.field-password {
|
||||
position: relative;
|
||||
meter.o_password_meter {
|
||||
bottom: calc(#{$input-height} / 2 - 7px);
|
||||
}
|
||||
}
|
8
views/signup_templates.xml
Normal file
8
views/signup_templates.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<odoo>
|
||||
<template id="fields" inherit_id="auth_signup.fields"
|
||||
name="Password policy data for auth_signup">
|
||||
<xpath expr="//input[@name='password']" position="after">
|
||||
<owl-component name="password_meter" props='{"selector": "input[name=password]"}'/>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
Loading…
x
Reference in New Issue
Block a user