feat: implement password setup link for tenant registration

When admin approves tenant registration:
- Owner account created in tenant schema (in addition to admin@localhost)
- Owner assigned 'owner' role with full permissions
- Password setup email sent with secure 7-day token link
- Owner sets password via link and auto-logs into their shop

Key changes:
- Added password_setup_token fields to TenantRegistration model
- Created tenants/services.py with formatted email service
- Modified _approve_registration to create owner account
- Added password_setup_confirm view with token validation
- Created password setup template and URL route
- Added admin action to resend password setup emails

Security:
- Token expires after 7 days
- Password not transmitted in email (secure setup link)
- Owner account inactive until password set
- Admin@localhost preserved for system administrator access

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-01 22:08:18 +03:00
parent 0ce854644e
commit fb4bcf37ec
7 changed files with 348 additions and 2 deletions

View File

@@ -0,0 +1,28 @@
# Generated by Django 5.0.10 on 2025-12-01 18:56
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('tenants', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='tenantregistration',
name='owner_notified_at',
field=models.DateTimeField(blank=True, help_text='Когда было отправлено письмо владельцу с ссылкой установки пароля', null=True, verbose_name='Дата уведомления владельца'),
),
migrations.AddField(
model_name='tenantregistration',
name='password_setup_token',
field=models.UUIDField(blank=True, help_text='UUID токен для ссылки установки пароля владельцем', null=True, unique=True, verbose_name='Токен установки пароля'),
),
migrations.AddField(
model_name='tenantregistration',
name='password_setup_token_created_at',
field=models.DateTimeField(blank=True, help_text='Когда был создан токен установки пароля (действителен 7 дней)', null=True, verbose_name='Дата создания токена'),
),
]