diff --git a/app.py b/app.py index cf72f81..a592b8f 100644 --- a/app.py +++ b/app.py @@ -4064,6 +4064,37 @@ def settings_2fa(): db.close() +@app.route('/settings/privacy', methods=['GET', 'POST']) +@login_required +def settings_privacy(): + """Privacy settings - control visibility of phone and email""" + db = SessionLocal() + try: + user = db.query(User).get(current_user.id) + + if request.method == 'POST': + # Update privacy settings + user.privacy_show_phone = request.form.get('show_phone') == 'on' + user.privacy_show_email = request.form.get('show_email') == 'on' + db.commit() + + logger.info(f"Privacy settings updated for user: {user.email}") + flash('Ustawienia prywatności zostały zapisane.', 'success') + return redirect(url_for('settings_privacy')) + + return render_template('settings/privacy.html', + user=user, + show_phone=user.privacy_show_phone if user.privacy_show_phone is not None else True, + show_email=user.privacy_show_email if user.privacy_show_email is not None else True) + + except Exception as e: + logger.error(f"Privacy settings error: {e}") + flash('Wystąpił błąd.', 'error') + return redirect(url_for('dashboard')) + finally: + db.close() + + @app.route('/forgot-password', methods=['GET', 'POST']) @limiter.limit("5 per hour") def forgot_password(): diff --git a/database.py b/database.py index c0ea49d..99a27ea 100644 --- a/database.py +++ b/database.py @@ -215,6 +215,10 @@ class User(Base, UserMixin): totp_enabled = Column(Boolean, default=False) totp_backup_codes = Column(StringArray, nullable=True) # Emergency backup codes + # Privacy settings + privacy_show_phone = Column(Boolean, default=True) # If FALSE, phone hidden from other users + privacy_show_email = Column(Boolean, default=True) # If FALSE, email hidden from other users + # Relationships conversations = relationship('AIChatConversation', back_populates='user', cascade='all, delete-orphan') forum_topics = relationship('ForumTopic', back_populates='author', cascade='all, delete-orphan', primaryjoin='User.id == ForumTopic.author_id') diff --git a/database/migrations/028_add_user_privacy_settings.sql b/database/migrations/028_add_user_privacy_settings.sql new file mode 100644 index 0000000..23fefa9 --- /dev/null +++ b/database/migrations/028_add_user_privacy_settings.sql @@ -0,0 +1,14 @@ +-- Migration: Add privacy settings to users table +-- Date: 2026-01-28 +-- Description: Adds fields to control visibility of phone and email in user profile + +-- Add privacy columns to users table +ALTER TABLE users ADD COLUMN IF NOT EXISTS privacy_show_phone BOOLEAN DEFAULT TRUE; +ALTER TABLE users ADD COLUMN IF NOT EXISTS privacy_show_email BOOLEAN DEFAULT TRUE; + +-- Comment for documentation +COMMENT ON COLUMN users.privacy_show_phone IS 'If FALSE, phone number is hidden from other users'; +COMMENT ON COLUMN users.privacy_show_email IS 'If FALSE, email is hidden from other users'; + +-- Grant permissions +GRANT SELECT, UPDATE ON users TO nordabiz_app; diff --git a/templates/base.html b/templates/base.html index b6d5d28..1306239 100755 --- a/templates/base.html +++ b/templates/base.html @@ -1042,6 +1042,13 @@
+ + + + + + Ustawienia + diff --git a/templates/settings/privacy.html b/templates/settings/privacy.html new file mode 100644 index 0000000..0e6dd5b --- /dev/null +++ b/templates/settings/privacy.html @@ -0,0 +1,236 @@ +{% extends "base.html" %} + +{% block title %}Ustawienia prywatności - Norda Biznes Partner{% endblock %} + +{% block extra_css %} + +{% endblock %} + +{% block content %} +
+

+ + + + Ustawienia prywatności +

+

Kontroluj, które Twoje dane kontaktowe są widoczne dla innych użytkowników

+
+ +
+ Prywatność + Uwierzytelnianie 2FA +
+ +
+ + + +
+ Poniższe ustawienia kontrolują widoczność Twoich danych osobowych w portalu. + Dane Twojej firmy są zarządzane osobno w profilu firmy. +
+
+ +
+ + +
+

Widoczność danych kontaktowych

+ +
+
+
Pokaż numer telefonu
+
+ Twój numer telefonu ({{ user.phone or 'nie podano' }}) będzie widoczny dla innych członków +
+
+ +
+ +
+
+
Pokaż adres email
+
+ Twój adres email ({{ user.email }}) będzie widoczny dla innych członków +
+
+ +
+
+ + +
+{% endblock %}