Files
NTBug/web/Helpdesk.Web/Models/ProfileViewModel.cs
PatTheEvil 3965a8a2a1 web: registrace, ověření e-mailu, obnova hesla a profil
Stránky na cestách z e-mailových odkazů API (/confirm-email, /reset-password).
Token se spotřebuje až tlačítkem, ne otevřením odkazu (poštovní skenery).
Profil s úpravou jména, telefonu a e-mailových upozornění, odhlášení ze všech
zařízení. Chyby validace z API se zobrazují u polí formuláře.

Refs #21
2026-12-02 00:31:07 +01:00

40 lines
1.4 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.ComponentModel.DataAnnotations;
using Helpdesk.Web.Api;
namespace Helpdesk.Web.Models;
public sealed class ProfileViewModel
{
// Jen pro zobrazení – e-mail a roli uživatel sám nemění.
public string Email { get; set; } = "";
public string Role { get; set; } = "";
[Required(ErrorMessage = "Zadejte jméno.")]
[StringLength(100, ErrorMessage = "Jméno může mít nejvýše 100 znaků.")]
[Display(Name = "Jméno")]
public string FirstName { get; set; } = "";
[Required(ErrorMessage = "Zadejte příjmení.")]
[StringLength(100, ErrorMessage = "Příjmení může mít nejvýše 100 znaků.")]
[Display(Name = "Příjmení")]
public string LastName { get; set; } = "";
[StringLength(30, ErrorMessage = "Telefon může mít nejvýše 30 znaků.")]
[RegularExpression(@"^\+?[0-9 ]+$", ErrorMessage = "Telefon smí obsahovat jen číslice, mezery a úvodní +.")]
[Display(Name = "Telefon")]
public string? Phone { get; set; }
[Display(Name = "Posílat upozornění e-mailem")]
public bool EmailNotificationsEnabled { get; set; }
public static ProfileViewModel From(UserDto user) => new()
{
Email = user.Email,
Role = user.Role,
FirstName = user.FirstName,
LastName = user.LastName,
Phone = user.Phone,
EmailNotificationsEnabled = user.EmailNotificationsEnabled,
};
}