profileShare

rasmusjy / splitapp-backend-clean-onion

Read-only snapshot

No repository description.

main default branch 429 files Expires Sep 13, 2026, 9:06 AM
InitialData.cs 2,633 bytes
1 namespace App.DAL.EF.Seeding;
2
3 public static class InitialData
4 {
5 public static readonly string[] Roles = ["user", "admin"];
6
7 // The demo password for the ordinary accounts is in the source on purpose:
8 // the running instance is a demo and anyone reading the code is meant to be
9 // able to sign in and look around.
10 //
11 // The administrator is not. That account can change other people's data, and
12 // this source is shared read-only with people outside the project, so its
13 // password comes from SEED_ADMIN_PASSWORD and there is no default. No
14 // variable, no administrator: seeding skips the account rather than falling
15 // back to something guessable.
16 public const string DemoPassword = "Kala.12345";
17
18 public static string? AdminPassword =>
19 Environment.GetEnvironmentVariable("SEED_ADMIN_PASSWORD");
20
21 public static readonly (string email, string password, string firstName, string lastName, string[] roles)[] Users =
22 [
23 ("user@taltech.ee", DemoPassword, "Test", "User", ["user"]),
24 ("alice@taltech.ee", DemoPassword, "Alice", "Johnson", ["user"]),
25 ("bob@taltech.ee", DemoPassword, "Bob", "Smith", ["user"]),
26 ("charlie@taltech.ee", DemoPassword, "Charlie", "Brown", ["user"]),
27 ("diana@taltech.ee", DemoPassword, "Diana", "Miller", ["user"]),
28 ];
29
30 /// <summary>
31 /// The seed users, with the administrator included only when
32 /// SEED_ADMIN_PASSWORD is set.
33 /// </summary>
34 public static IEnumerable<(string email, string password, string firstName, string lastName, string[] roles)> SeedUsers()
35 {
36 var adminPassword = AdminPassword;
37 if (!string.IsNullOrWhiteSpace(adminPassword))
38 {
39 yield return ("admin@taltech.ee", adminPassword, "Admin", "User", ["admin"]);
40 }
41
42 foreach (var user in Users)
43 {
44 yield return user;
45 }
46 }
47
48 public static readonly (string Code, string NameEn, string NameEt, string Symbol)[] Currencies =
49 [
50 ("EUR", "Euro", "Euro", "\u20ac"),
51 ("USD", "US Dollar", "USA dollar", "$"),
52 ("GBP", "British Pound", "Briti nael", "\u00a3"),
53 ("SEK", "Swedish Krona", "Rootsi kroon", "kr"),
54 ("NOK", "Norwegian Krone", "Norra kroon", "kr"),
55 ];
56
57 public static readonly (string nameEn, string nameEt, string? icon)[] BudgetCategories =
58 [
59 ("Food", "Toit", "utensils"),
60 ("Accommodation", "Majutus", "bed"),
61 ("Transport", "Transport", "car"),
62 ("Activities", "Tegevused", "hiking"),
63 ("Shopping", "Ostlemine", "shopping-bag"),
64 ];
65 }
66