feat: Armarium v1.1.0 — dashboard, auth, 2FA, SMTP, settings, deploy
Dashboard: - ApexCharts bar chart (income vs fixed costs vs expenses) and donut chart - KPI cards: income, fixed costs, savings rate with configurable goal - Greeting with time-of-day and locale-aware date/time display Authentication & security: - Email-based login (no username), case-insensitive lookup - JWT access/refresh tokens with rotation and blacklist - TOTP 2FA with QR code, backup codes (copy + PDF export) - 2FA recovery via email code - Cloudflare Turnstile CAPTCHA on login and register Email flows: - Email verification on registration (24h token) - Password reset flow (15min token, anti-enumeration) - Brevo SMTP integration with HTML + plaintext email templates - Notification emails: 2FA recovery, password changed, email changed Settings page: - 2FA management (enable/disable, QR, backup codes) - Active sessions list with per-device revoke - Data export: ZIP with 6 PDFs via fpdf2 - Notification preferences (3 toggles) - Danger zone: account deletion with mandatory export + confirmation phrase UI & layout: - Sidebar with collapsible/flyout mode, Angular signal-based dropdowns - Dark mode (class-based), language switcher (DE/FR/IT/EN) - Mobile-responsive layout with touch-friendly targets - Roboto font via @fontsource (GDPR-compliant, no Google CDN) - Pure Tailwind CSS v3 Infrastructure: - Forgejo Actions CI/CD pipeline (auto-deploy on push to main) - Gunicorn + Nginx + PostgreSQL production setup - Rate limiting, HSTS, secure cookies, CSRF protection
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
from rest_framework import serializers
|
||||
from django.contrib.auth import get_user_model
|
||||
from .models import Account, Transaction, Budget, Expense, Profile, Deadline
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
class AccountSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Account
|
||||
exclude = ['user']
|
||||
|
||||
|
||||
class TransactionSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Transaction
|
||||
fields = '__all__'
|
||||
|
||||
def validate(self, data):
|
||||
request = self.context.get('request')
|
||||
if not request:
|
||||
return data
|
||||
user = request.user
|
||||
source = data.get('source_account') or (self.instance.source_account if self.instance else None)
|
||||
dest = data.get('destination_account') or (self.instance.destination_account if self.instance else None)
|
||||
if source and source.user != user:
|
||||
raise serializers.ValidationError('Source account does not belong to you.')
|
||||
if dest and dest.user != user:
|
||||
raise serializers.ValidationError('Destination account does not belong to you.')
|
||||
return data
|
||||
|
||||
|
||||
class BudgetSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Budget
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class ExpenseSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Expense
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class ProfileSerializer(serializers.ModelSerializer):
|
||||
totp_enabled = serializers.BooleanField(read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = Profile
|
||||
exclude = ['user', 'totp_secret', 'email_verify_token', 'email_verify_token_expires', 'password_reset_token_hash', 'password_reset_token_expires']
|
||||
|
||||
|
||||
class DeadlineSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Deadline
|
||||
exclude = ['user']
|
||||
|
||||
|
||||
class RegisterSerializer(serializers.Serializer):
|
||||
email = serializers.EmailField()
|
||||
password = serializers.CharField(min_length=8, write_only=True)
|
||||
|
||||
def validate_email(self, value):
|
||||
if User.objects.filter(email=value).exists():
|
||||
raise serializers.ValidationError('Email already registered.')
|
||||
return value
|
||||
|
||||
def create(self, validated_data):
|
||||
email = validated_data['email']
|
||||
return User.objects.create_user(
|
||||
username=email,
|
||||
email=email,
|
||||
password=validated_data['password'],
|
||||
)
|
||||
Reference in New Issue
Block a user