feat: passwords need 8 characters or more, on the Site and in the Kanban
All checks were successful
Build and deploy / Validate source (push) Successful in 7s
Build and deploy / Integration suite on a real stack (push) Successful in 3m28s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m2s
All checks were successful
Build and deploy / Validate source (push) Successful in 7s
Build and deploy / Integration suite on a real stack (push) Successful in 3m28s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m2s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,7 +26,7 @@ class UserIn(StrictModel):
|
||||
name: str = Field(min_length=1, max_length=80)
|
||||
email: str = Field(min_length=3, max_length=254)
|
||||
role: Literal['admin', 'gestao', 'operador', 'vendedor']
|
||||
password: str | None = Field(default=None, min_length=12, max_length=128)
|
||||
password: str | None = Field(default=None, min_length=8, max_length=128)
|
||||
active: bool = True
|
||||
machines: list[UUID] = Field(default_factory=list, max_length=50)
|
||||
# The team's alerts by e-mail: orders paid, carts waiting for review, payments to look at.
|
||||
@@ -49,7 +49,7 @@ class MachineIn(StrictModel):
|
||||
|
||||
class PasswordChange(StrictModel):
|
||||
current: str = Field(min_length=1, max_length=128)
|
||||
new: str = Field(min_length=12, max_length=128)
|
||||
new: str = Field(min_length=8, max_length=128)
|
||||
|
||||
|
||||
@router.get('/api/operator/me')
|
||||
@@ -112,7 +112,7 @@ def set_machines(c, uid, machines):
|
||||
@router.post('/api/operator/users')
|
||||
def create_user(body: UserIn, request: Request, user=Depends(can('users'))):
|
||||
if not body.password:
|
||||
raise HTTPException(422, 'Defina uma senha inicial com 12 caracteres ou mais.')
|
||||
raise HTTPException(422, 'Defina uma senha inicial com 8 caracteres ou mais.')
|
||||
uid = uuid4()
|
||||
with db.connect() as c:
|
||||
if c.execute('SELECT 1 FROM dtf_local.operators WHERE email=%s', (body.email,)).fetchone():
|
||||
|
||||
@@ -255,7 +255,7 @@ class Resolution(StrictModel):
|
||||
|
||||
class Register(StrictModel):
|
||||
customer: Customer
|
||||
password: str = Field(min_length=12, max_length=128)
|
||||
password: str = Field(min_length=8, max_length=128)
|
||||
|
||||
class ProfileUpdate(StrictModel):
|
||||
"""What a customer may change about their account; the CPF/CNPJ is not among it."""
|
||||
@@ -290,7 +290,7 @@ class EmailChange(StrictModel):
|
||||
|
||||
class PasswordChange(StrictModel):
|
||||
current: str = Field(min_length=1, max_length=128)
|
||||
new: str = Field(min_length=12, max_length=128)
|
||||
new: str = Field(min_length=8, max_length=128)
|
||||
|
||||
class SignupCode(StrictModel):
|
||||
signup: UUID
|
||||
@@ -311,7 +311,7 @@ class ForgotPassword(StrictModel):
|
||||
|
||||
class PasswordReset(StrictModel):
|
||||
token: str = Field(min_length=20, max_length=100, pattern=r'^[A-Za-z0-9_-]+$')
|
||||
password: str = Field(min_length=12, max_length=128)
|
||||
password: str = Field(min_length=8, max_length=128)
|
||||
|
||||
class Login(StrictModel):
|
||||
email: str = Field(min_length=3, max_length=254)
|
||||
|
||||
@@ -28,7 +28,7 @@ from uuid import uuid4
|
||||
from .core.auth import ROLES, password_hash
|
||||
from .core.db import connect
|
||||
|
||||
MIN_PASSWORD = 12
|
||||
MIN_PASSWORD = 8
|
||||
|
||||
|
||||
def seed_from_environment(cursor):
|
||||
|
||||
@@ -109,7 +109,7 @@ final files are separately labeled. Never print the local text fixture.
|
||||
## Customer accounts, corrections, and cart recovery
|
||||
|
||||
Open **Minha conta** on the Site, or `/portal.html`. Create a local account with
|
||||
a test CNPJ, phone, email and password of at least 12 characters. Passwords use
|
||||
a test CNPJ, phone, email and password of at least 8 characters. Passwords use
|
||||
the current stronger scrypt format; legacy local hashes are verified and upgraded
|
||||
on successful login. Sessions are stored in PostgreSQL, expire after
|
||||
seven days, and are revoked on logout. Login/registration attempts are limited.
|
||||
|
||||
@@ -92,7 +92,11 @@ def run():
|
||||
assert seller.call('/operator/me')['can'] == ['view']
|
||||
# Their own password: the current one is asked for.
|
||||
seller.call('/operator/me/password', {'current': 'errada', 'new': 'outra-senha-de-teste'}, expected=403)
|
||||
seller.call('/operator/me/password', {'current': PASSWORD, 'new': 'outra-senha-de-teste'})
|
||||
# Eight characters or more.
|
||||
seller.call('/operator/me/password', {'current': PASSWORD, 'new': 'sete-77'}, expected=422)
|
||||
seller.call('/operator/me/password', {'current': PASSWORD, 'new': 'oito-888'})
|
||||
seller = signed_in(emails['vendedor'], 'oito-888')
|
||||
seller.call('/operator/me/password', {'current': 'oito-888', 'new': 'outra-senha-de-teste'})
|
||||
signed_in(emails['vendedor'], 'outra-senha-de-teste').call('/operator/me')
|
||||
|
||||
# Disabled, the operator is out at once; deleted, the account is gone.
|
||||
|
||||
@@ -1139,8 +1139,8 @@ function userForm(u){
|
||||
const roles=u?.role==='superadmin'?['superadmin']:['admin','gestao','operador','vendedor'];
|
||||
for(const r of roles){const o=node('option',ROLE_NAMES[r]);o.value=r;role.append(o);}
|
||||
role.value=u?.role||'operador';role.disabled=u?.role==='superadmin'||u?.email===ME.email;
|
||||
const pass=node('input');pass.type='password';pass.minLength=12;pass.maxLength=128;pass.autocomplete='new-password';
|
||||
pass.required=!editing;pass.placeholder=editing?'Deixe em branco para manter':'12 caracteres ou mais';
|
||||
const pass=node('input');pass.type='password';pass.minLength=8;pass.maxLength=128;pass.autocomplete='new-password';
|
||||
pass.required=!editing;pass.placeholder=editing?'Deixe em branco para manter':'8 caracteres ou mais';
|
||||
const active=node('input');active.type='checkbox';active.checked=u?u.active:true;active.disabled=u?.email===ME.email;
|
||||
const activeLabel=node('label',undefined,'check');activeLabel.append(active,'Ativo (pode entrar no Kanban)');
|
||||
const alerts=node('input');alerts.type='checkbox';alerts.checked=!!u?.alerts;
|
||||
@@ -1174,9 +1174,9 @@ function machineForm(m){
|
||||
}
|
||||
function passwordForm(){
|
||||
const current=node('input');current.type='password';current.required=true;current.autocomplete='current-password';
|
||||
const next=node('input');next.type='password';next.required=true;next.minLength=12;next.autocomplete='new-password';
|
||||
const again=node('input');again.type='password';again.required=true;again.minLength=12;again.autocomplete='new-password';
|
||||
dialog('Minha senha',[field('Senha atual',current),field('Nova senha (12 caracteres ou mais)',next),field('Repita a nova senha',again)],async()=>{
|
||||
const next=node('input');next.type='password';next.required=true;next.minLength=8;next.autocomplete='new-password';
|
||||
const again=node('input');again.type='password';again.required=true;again.minLength=8;again.autocomplete='new-password';
|
||||
dialog('Minha senha',[field('Senha atual',current),field('Nova senha (8 caracteres ou mais)',next),field('Repita a nova senha',again)],async()=>{
|
||||
if(next.value!==again.value)throw new Error('A nova senha e a repetição não conferem.');
|
||||
await api('/me/password',{current:current.value,new:next.value});say('Senha trocada.');
|
||||
});
|
||||
|
||||
@@ -66,8 +66,8 @@
|
||||
</div>
|
||||
<label for="register-email">E-mail</label>
|
||||
<input id="register-email" type="email" autocomplete="email" required>
|
||||
<label for="register-password">Senha <span class="obs">12 caracteres ou mais</span></label>
|
||||
<input id="register-password" type="password" minlength="12" maxlength="128" autocomplete="new-password" required>
|
||||
<label for="register-password">Senha <span class="obs">8 caracteres ou mais</span></label>
|
||||
<input id="register-password" type="password" minlength="8" maxlength="128" autocomplete="new-password" required>
|
||||
<button class="bPri" id="criarConta">Criar conta</button>
|
||||
</form>
|
||||
<!-- Takes the place of "Criar conta" while the e-mail is confirmed. -->
|
||||
@@ -93,10 +93,10 @@
|
||||
<form class="bloco" id="fRedefinir">
|
||||
<h2>Nova senha</h2>
|
||||
<p class="nota2">Depois de salvar, você já entra na sua conta.</p>
|
||||
<label for="rNova">Nova senha <span class="obs">12 caracteres ou mais</span></label>
|
||||
<input id="rNova" type="password" minlength="12" maxlength="128" autocomplete="new-password" required>
|
||||
<label for="rNova">Nova senha <span class="obs">8 caracteres ou mais</span></label>
|
||||
<input id="rNova" type="password" minlength="8" maxlength="128" autocomplete="new-password" required>
|
||||
<label for="rRepete">Repita a nova senha</label>
|
||||
<input id="rRepete" type="password" minlength="12" maxlength="128" autocomplete="new-password" required>
|
||||
<input id="rRepete" type="password" minlength="8" maxlength="128" autocomplete="new-password" required>
|
||||
<button class="bPri">Salvar e entrar</button>
|
||||
</form>
|
||||
</div>
|
||||
@@ -188,7 +188,7 @@
|
||||
<form class="bloco" id="fSenha">
|
||||
<h2>Senha</h2>
|
||||
<label for="dAtual">Senha atual</label><input id="dAtual" type="password" autocomplete="current-password" required>
|
||||
<label for="dNova">Nova senha <span class="obs">12 caracteres ou mais</span></label><input id="dNova" type="password" minlength="12" maxlength="128" autocomplete="new-password" required>
|
||||
<label for="dNova">Nova senha <span class="obs">8 caracteres ou mais</span></label><input id="dNova" type="password" minlength="8" maxlength="128" autocomplete="new-password" required>
|
||||
<button class="bSec">Alterar senha</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
@@ -361,7 +361,7 @@ $('fSenha').onsubmit=async event=>{
|
||||
event.preventDefault();
|
||||
try{await api('/account/password',{current:$('dAtual').value,new:$('dNova').value});
|
||||
$('dAtual').value='';$('dNova').value='';aviso('Senha alterada.');}
|
||||
catch(e){aviso(e.status===422?'A nova senha precisa ter 12 caracteres ou mais.':e.message,true);}
|
||||
catch(e){aviso(e.status===422?'A nova senha precisa ter 8 caracteres ou mais.':e.message,true);}
|
||||
};
|
||||
|
||||
// ---- Signing in ----------------------------------------------------------
|
||||
@@ -388,7 +388,7 @@ async function authenticate(path,body,destino){
|
||||
$('login').onsubmit=async event=>{event.preventDefault();try{await authenticate('/account/login',{email:$('email').value,password:$('password').value});}catch(e){aviso(e.message,true);}};
|
||||
$('register').onsubmit=async event=>{event.preventDefault();$('criarConta').disabled=true;
|
||||
try{await authenticate('/account/register',{customer:{name:$('register-name').value,cnpj:$('cnpj').value,zap:$('phone').value,mail:$('register-email').value},password:$('register-password').value});}
|
||||
catch(e){aviso(e.status===422?'Confira o nome, o CPF ou CNPJ, o WhatsApp e o e-mail. A senha precisa ter 12 caracteres ou mais.':e.message,true);}
|
||||
catch(e){aviso(e.status===422?'Confira o nome, o CPF ou CNPJ, o WhatsApp e o e-mail. A senha precisa ter 8 caracteres ou mais.':e.message,true);}
|
||||
finally{$('criarConta').disabled=false;}};
|
||||
|
||||
// Signup code: the account is created only once the code e-mailed to the
|
||||
@@ -460,7 +460,7 @@ $('fRedefinir').onsubmit=async event=>{
|
||||
if($('rNova').value!==$('rRepete').value){aviso('A nova senha e a repetição não conferem.',true);return;}
|
||||
try{await authenticate('/account/reset',{token:resetToken,password:$('rNova').value},'/conta');
|
||||
resetToken='';$('rNova').value='';$('rRepete').value='';aviso('Senha criada. Você já está na sua conta.');}
|
||||
catch(e){aviso(e.status===422?(resetToken?'A nova senha precisa ter 12 caracteres ou mais.':'Este link está incompleto. Peça outro em “Esqueci minha senha”.'):e.message,true);}
|
||||
catch(e){aviso(e.status===422?(resetToken?'A nova senha precisa ter 8 caracteres ou mais.':'Este link está incompleto. Peça outro em “Esqueci minha senha”.'):e.message,true);}
|
||||
};
|
||||
$('logout').onclick=async()=>{try{await window.dtfForgetPrivateData();await api('/account/logout',{});location.assign('/conta/entrar');}catch(error){aviso('Não foi possível limpar os dados deste navegador. Feche as abas do Site e limpe os dados do site nas configurações do navegador.',true);}};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user