Browse Source

Added Feature infrastructure and changed email accounts to start disabled for new accounts.

Teknikode 1 month ago
parent
commit
8a6353f3da

+ 6
- 0
MailService/HMailService.cs View File

@@ -128,5 +128,11 @@ namespace Teknik.MailService
128 128
             var domain = _App.Domains.ItemByName[_Domain];
129 129
             return domain.Accounts.ItemByAddress[username];
130 130
         }
131
+
132
+        public bool Enabled(string username)
133
+        {
134
+            var account = GetAccount(username);
135
+            return account.Active;
136
+        }
131 137
     }
132 138
 }

+ 2
- 0
MailService/IMailService.cs View File

@@ -8,6 +8,8 @@ namespace Teknik.MailService
8 8
 
9 9
         DateTime LastActive(string username);
10 10
 
11
+        bool Enabled(string username);
12
+
11 13
         void CreateAccount(string username, string password, int size);
12 14
 
13 15
         void EditPassword(string username, string password);

+ 10
- 16
Teknik/Areas/About/Views/About/Index.cshtml View File

@@ -44,25 +44,13 @@
44 44
                             <td class="text-center"><i class="fa fa-times fa-2x text-danger"></i></td>
45 45
                             <td class="text-center"><i class="fa fa-times fa-2x text-danger"></i></td>
46 46
                         </tr>
47
-                        <tr>
48
-                            <td class="text-left">Email Storage</td>
49
-                            <td class="text-center">5GB Storage</td>
50
-                            <td class="text-center">1GB Storage</td>
51
-                            <td class="text-center"><i class="fa fa-times fa-2x text-danger"></i></td>
52
-                        </tr>
53
-                        <tr>
54
-                            <td class="text-left">Outbound Emails</td>
55
-                            <td class="text-center">Unlimited</td>
56
-                            <td class="text-center">100 per Day</td>
57
-                            <td class="text-center"><i class="fa fa-times fa-2x text-danger"></i></td>
58
-                        </tr>
59
-                        <!-- Basic Features -->
60 47
                         <tr>
61 48
                             <td class="text-left">Email Account</td>
62 49
                             <td class="text-center"><i class="fa fa-check fa-2x text-success"></i></td>
63
-                            <td class="text-center"><i class="fa fa-check fa-2x text-success"></i></td>
50
+                            <td class="text-center"><i class="fa fa-times fa-2x text-danger"></i></td>
64 51
                             <td class="text-center"><i class="fa fa-times fa-2x text-danger"></i></td>
65 52
                         </tr>
53
+                        <!-- Basic Features -->
66 54
                         <tr>
67 55
                             <td class="text-left">Git Repositories</td>
68 56
                             <td class="text-center">Unlimited Public &amp; Private Repos</td>
@@ -76,14 +64,14 @@
76 64
                             <td class="text-center"><i class="fa fa-times fa-2x text-danger"></i></td>
77 65
                         </tr>
78 66
                         <tr>
79
-                            <td class="text-left">Vault Editing</td>
67
+                            <td class="text-left">Vault and Paste Editing</td>
80 68
                             <td class="text-center"><i class="fa fa-check fa-2x text-success"></i></td>
81 69
                             <td class="text-center"><i class="fa fa-check fa-2x text-success"></i></td>
82 70
                             <td class="text-center"><i class="fa fa-times fa-2x text-danger"></i></td>
83 71
                         </tr>
84 72
                         <tr>
85 73
                             <td class="text-left">
86
-                                View Content History:
74
+                                View and Delete Previous Content:
87 75
                                 <br />
88 76
                                 <ul>
89 77
                                     <li>Pastes</li>
@@ -121,6 +109,12 @@
121 109
                             <td class="text-center">@StringHelper.GetBytesReadable(Config.UploadConfig.MaxDownloadSize)</td>
122 110
                             <td class="text-center">@StringHelper.GetBytesReadable(Config.UploadConfig.MaxDownloadSize)</td>
123 111
                         </tr>
112
+                        <tr>
113
+                            <td class="text-left">Upload Expiration</td>
114
+                            <td class="text-center">Never</td>
115
+                            <td class="text-center">Never</td>
116
+                            <td class="text-center">24 Hours</td>
117
+                        </tr>
124 118
                         <tr>
125 119
                             <td class="text-left">Url Shortening</td>
126 120
                             <td class="text-center"><i class="fa fa-check fa-2x text-success"></i></td>

+ 19
- 2
Teknik/Areas/Contact/Views/Contact/Index.cshtml View File

@@ -1,5 +1,22 @@
1 1
 @model Teknik.Areas.Contact.ViewModels.ContactViewModel
2 2
 
3
+@using Teknik.Areas.Users.Utility
4
+
5
+@{ 
6
+    string username = string.Empty;
7
+    string email = string.Empty;
8
+
9
+    if (User.Identity.IsAuthenticated)
10
+    {
11
+        username = User.Identity.Name;
12
+
13
+        if (UserHelper.UserEmailEnabled(Config, UserHelper.GetUserEmailAddress(Config, username)))
14
+        {
15
+            email = UserHelper.GetUserEmailAddress(Config, username);
16
+        }
17
+    }
18
+}
19
+
3 20
 <div class="container">
4 21
     <div class="row">
5 22
         <div class="col-sm-12 col-lg-12">
@@ -22,7 +39,7 @@
22 39
                                 <label for="Name">
23 40
                                     Name
24 41
                                 </label>
25
-                                <input type="text" class="form-control" id="Name" name="Name" placeholder="Enter name" required="required" value="@((User.Identity.IsAuthenticated) ? User.Identity.Name : string.Empty)" />
42
+                                <input type="text" class="form-control" id="Name" name="Name" placeholder="Enter name" required="required" value="@username" />
26 43
                             </div>
27 44
                             <div class="form-group">
28 45
                                 @Html.ValidationMessageFor(u => u.Email)
@@ -33,7 +50,7 @@
33 50
                                     <span class="input-group-addon">
34 51
                                         <span class="fa fa-envelope"></span>
35 52
                                     </span>
36
-                                    <input type="email" class="form-control" id="Email" name="Email" placeholder="Enter email" required="required" value="@((User.Identity.IsAuthenticated) ? User.Identity.Name + "@" + Config.Host : string.Empty)" />
53
+                                    <input type="email" class="form-control" id="Email" name="Email" placeholder="Enter email" required="required" value="@email" />
37 54
                                 </div>
38 55
                             </div>
39 56
                             <div class="form-group">

+ 18
- 0
Teknik/Areas/User/Models/Feature.cs View File

@@ -0,0 +1,18 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+
6
+namespace Teknik.Areas.Users.Models
7
+{
8
+    public class Feature
9
+    {
10
+        public string FeatureId { get; set; }
11
+
12
+        public string Name { get; set; }
13
+
14
+        public string Description { get; set; }
15
+
16
+        public bool Enabled { get; set; }
17
+    }
18
+}

+ 0
- 22
Teknik/Areas/User/Models/LoginInfo.cs View File

@@ -1,22 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Threading.Tasks;
5
-
6
-namespace Teknik.Areas.Users.Models
7
-{
8
-    public class LoginInfo
9
-    {
10
-        public int LoginInfoId { get; set; }
11
-
12
-        public virtual string LoginProvider { get; set; }
13
-
14
-        public virtual string ProviderDisplayName { get; set; }
15
-
16
-        public virtual string ProviderKey { get; set; }
17
-
18
-        public int UserId { get; set; }
19
-
20
-        public virtual User User { get; set; }
21
-    }
22
-}

+ 2
- 2
Teknik/Areas/User/Models/User.cs View File

@@ -15,7 +15,7 @@ namespace Teknik.Areas.Users.Models
15 15
 
16 16
         public string Username { get; set; }
17 17
 
18
-        public virtual ICollection<LoginInfo> Logins { get; set; }
18
+        public virtual ICollection<UserFeature> Features { get; set; }
19 19
 
20 20
         public virtual InviteCode ClaimedInviteCode { get; set; }
21 21
 
@@ -38,7 +38,7 @@ namespace Teknik.Areas.Users.Models
38 38
         public User()
39 39
         {
40 40
             Username = string.Empty;
41
-            Logins = new List<LoginInfo>();
41
+            Features = new List<UserFeature>();
42 42
             ClaimedInviteCode = null;
43 43
             OwnedInviteCodes = new List<InviteCode>();
44 44
         }

+ 20
- 0
Teknik/Areas/User/Models/UserFeature.cs View File

@@ -0,0 +1,20 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+
6
+namespace Teknik.Areas.Users.Models
7
+{
8
+    public class UserFeature
9
+    {
10
+        public int UserFeatureId { get; set; }
11
+
12
+        public string FeatureId { get; set; }
13
+
14
+        public virtual Feature Feature { get; set; }
15
+
16
+        public int UserId { get; set; }
17
+
18
+        public virtual User User { get; set; }
19
+    }
20
+}

+ 28
- 0
Teknik/Areas/User/Utility/UserExtensions.cs View File

@@ -0,0 +1,28 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using Teknik.Areas.Users.Models;
6
+
7
+namespace Teknik.Areas.Users.Utility
8
+{
9
+    public static class UserExtensions
10
+    {
11
+        public static bool HasFeatures(this User user, params string[] features)
12
+        {
13
+            if (user.Features.Any())
14
+            {
15
+                return user.Features.Where(f => features.Contains(f.FeatureId)).FirstOrDefault() != null;
16
+            }
17
+            return false;
18
+        }
19
+        public static bool HasFeature(this User user, string feature)
20
+        {
21
+            if (user.Features.Any())
22
+            {
23
+                return user.Features.Where(f => f.FeatureId == feature).FirstOrDefault() != null;
24
+            }
25
+            return false;
26
+        }
27
+    }
28
+}

+ 25
- 10
Teknik/Areas/User/Utility/UserHelper.cs View File

@@ -145,6 +145,9 @@ namespace Teknik.Areas.Users.Utility
145 145
                     // Create an Email Account
146 146
                     CreateUserEmail(config, GetUserEmailAddress(config, username), password);
147 147
 
148
+                    // Disable the email account
149
+                    DisableUserEmail(config, GetUserEmailAddress(config, username));
150
+
148 151
                     // Create a Git Account
149 152
                     CreateUserGit(config, username, password);
150 153
 
@@ -253,18 +256,12 @@ namespace Teknik.Areas.Users.Utility
253 256
                     switch (type)
254 257
                     {
255 258
                         case AccountType.Basic:
256
-                            // Set the email size to 1GB
257
-                            EditUserEmailMaxSize(config, email, config.EmailConfig.MaxSize);
258
-
259
-                            // Set the email max/day to 100
260
-                            EditUserEmailMaxEmailsPerDay(config, email, 100);
259
+                            // Disable their email
260
+                            DisableUserEmail(config, email);
261 261
                             break;
262 262
                         case AccountType.Premium:
263
-                            // Set the email size to 5GB
264
-                            EditUserEmailMaxSize(config, email, 5000);
265
-
266
-                            // Set the email max/day to infinite (-1)
267
-                            EditUserEmailMaxEmailsPerDay(config, email, -1);
263
+                            // Enable their email account
264
+                            EnableUserEmail(config, email);
268 265
                             break;
269 266
                     }
270 267
                 }
@@ -668,6 +665,24 @@ If you recieved this email and you did not reset your password, you can ignore t
668 665
             return lastActive;
669 666
         }
670 667
 
668
+        public static bool UserEmailEnabled(Config config, string email)
669
+        {
670
+            try
671
+            {
672
+                // If Email Server is enabled
673
+                if (config.EmailConfig.Enabled)
674
+                {
675
+                    var svc = CreateMailService(config);
676
+                    return svc.Enabled(email);
677
+                }
678
+            }
679
+            catch (Exception ex)
680
+            {
681
+                throw new Exception("Unable to disable email account.", ex);
682
+            }
683
+            return false;
684
+        }
685
+
671 686
         public static void CreateUserEmail(Config config, string email, string password)
672 687
         {
673 688
             try

+ 767
- 0
Teknik/Data/Migrations/20190127224049_Features.Designer.cs View File

@@ -0,0 +1,767 @@
1
+// <auto-generated />
2
+using System;
3
+using Microsoft.EntityFrameworkCore;
4
+using Microsoft.EntityFrameworkCore.Infrastructure;
5
+using Microsoft.EntityFrameworkCore.Metadata;
6
+using Microsoft.EntityFrameworkCore.Migrations;
7
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
8
+using Teknik.Data;
9
+
10
+namespace Teknik.Data.Migrations
11
+{
12
+    [DbContext(typeof(TeknikEntities))]
13
+    [Migration("20190127224049_Features")]
14
+    partial class Features
15
+    {
16
+        protected override void BuildTargetModel(ModelBuilder modelBuilder)
17
+        {
18
+#pragma warning disable 612, 618
19
+            modelBuilder
20
+                .HasAnnotation("ProductVersion", "2.2.0-preview3-35497")
21
+                .HasAnnotation("Relational:MaxIdentifierLength", 128)
22
+                .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
23
+
24
+            modelBuilder.Entity("Teknik.Areas.Blog.Models.Blog", b =>
25
+                {
26
+                    b.Property<int>("BlogId")
27
+                        .ValueGeneratedOnAdd()
28
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
29
+
30
+                    b.Property<int>("UserId");
31
+
32
+                    b.HasKey("BlogId");
33
+
34
+                    b.HasIndex("UserId");
35
+
36
+                    b.ToTable("Blogs");
37
+                });
38
+
39
+            modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPost", b =>
40
+                {
41
+                    b.Property<int>("BlogPostId")
42
+                        .ValueGeneratedOnAdd()
43
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
44
+
45
+                    b.Property<string>("Article");
46
+
47
+                    b.Property<int>("BlogId");
48
+
49
+                    b.Property<DateTime>("DateEdited");
50
+
51
+                    b.Property<DateTime>("DatePosted");
52
+
53
+                    b.Property<DateTime>("DatePublished");
54
+
55
+                    b.Property<bool>("Published");
56
+
57
+                    b.Property<bool>("System");
58
+
59
+                    b.Property<string>("Title");
60
+
61
+                    b.HasKey("BlogPostId");
62
+
63
+                    b.HasIndex("BlogId");
64
+
65
+                    b.ToTable("BlogPosts");
66
+                });
67
+
68
+            modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPostComment", b =>
69
+                {
70
+                    b.Property<int>("BlogPostCommentId")
71
+                        .ValueGeneratedOnAdd()
72
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
73
+
74
+                    b.Property<string>("Article");
75
+
76
+                    b.Property<int>("BlogPostId");
77
+
78
+                    b.Property<DateTime>("DateEdited");
79
+
80
+                    b.Property<DateTime>("DatePosted");
81
+
82
+                    b.Property<int?>("UserId");
83
+
84
+                    b.HasKey("BlogPostCommentId");
85
+
86
+                    b.HasIndex("BlogPostId");
87
+
88
+                    b.HasIndex("UserId");
89
+
90
+                    b.ToTable("BlogPostComments");
91
+                });
92
+
93
+            modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPostTag", b =>
94
+                {
95
+                    b.Property<int>("BlogPostTagId")
96
+                        .ValueGeneratedOnAdd()
97
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
98
+
99
+                    b.Property<int>("BlogPostId");
100
+
101
+                    b.Property<string>("Description");
102
+
103
+                    b.Property<string>("Name");
104
+
105
+                    b.HasKey("BlogPostTagId");
106
+
107
+                    b.HasIndex("BlogPostId");
108
+
109
+                    b.ToTable("BlogPostTags");
110
+                });
111
+
112
+            modelBuilder.Entity("Teknik.Areas.Contact.Models.Contact", b =>
113
+                {
114
+                    b.Property<int>("ContactId")
115
+                        .ValueGeneratedOnAdd()
116
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
117
+
118
+                    b.Property<DateTime>("DateAdded");
119
+
120
+                    b.Property<string>("Email");
121
+
122
+                    b.Property<string>("Message");
123
+
124
+                    b.Property<string>("Name");
125
+
126
+                    b.Property<string>("Subject");
127
+
128
+                    b.HasKey("ContactId");
129
+
130
+                    b.ToTable("Contact");
131
+                });
132
+
133
+            modelBuilder.Entity("Teknik.Areas.Paste.Models.Paste", b =>
134
+                {
135
+                    b.Property<int>("PasteId")
136
+                        .ValueGeneratedOnAdd()
137
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
138
+
139
+                    b.Property<int>("BlockSize");
140
+
141
+                    b.Property<string>("Content");
142
+
143
+                    b.Property<DateTime>("DateEdited");
144
+
145
+                    b.Property<DateTime>("DatePosted");
146
+
147
+                    b.Property<string>("DeleteKey")
148
+                        .HasAnnotation("CaseSensitive", true);
149
+
150
+                    b.Property<DateTime?>("ExpireDate");
151
+
152
+                    b.Property<string>("FileName")
153
+                        .HasAnnotation("CaseSensitive", true);
154
+
155
+                    b.Property<string>("HashedPassword")
156
+                        .HasAnnotation("CaseSensitive", true);
157
+
158
+                    b.Property<string>("IV")
159
+                        .HasAnnotation("CaseSensitive", true);
160
+
161
+                    b.Property<string>("Key")
162
+                        .HasAnnotation("CaseSensitive", true);
163
+
164
+                    b.Property<int>("KeySize");
165
+
166
+                    b.Property<int>("MaxViews");
167
+
168
+                    b.Property<string>("Syntax");
169
+
170
+                    b.Property<string>("Title");
171
+
172
+                    b.Property<string>("Url")
173
+                        .HasAnnotation("CaseSensitive", true);
174
+
175
+                    b.Property<int?>("UserId");
176
+
177
+                    b.Property<int>("Views");
178
+
179
+                    b.HasKey("PasteId");
180
+
181
+                    b.HasIndex("UserId");
182
+
183
+                    b.ToTable("Pastes");
184
+                });
185
+
186
+            modelBuilder.Entity("Teknik.Areas.Podcast.Models.Podcast", b =>
187
+                {
188
+                    b.Property<int>("PodcastId")
189
+                        .ValueGeneratedOnAdd()
190
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
191
+
192
+                    b.Property<DateTime>("DateEdited");
193
+
194
+                    b.Property<DateTime>("DatePosted");
195
+
196
+                    b.Property<DateTime>("DatePublished");
197
+
198
+                    b.Property<string>("Description");
199
+
200
+                    b.Property<int>("Episode");
201
+
202
+                    b.Property<bool>("Published");
203
+
204
+                    b.Property<string>("Title");
205
+
206
+                    b.HasKey("PodcastId");
207
+
208
+                    b.ToTable("Podcasts");
209
+                });
210
+
211
+            modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastComment", b =>
212
+                {
213
+                    b.Property<int>("PodcastCommentId")
214
+                        .ValueGeneratedOnAdd()
215
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
216
+
217
+                    b.Property<string>("Article");
218
+
219
+                    b.Property<DateTime>("DateEdited");
220
+
221
+                    b.Property<DateTime>("DatePosted");
222
+
223
+                    b.Property<int>("PodcastId");
224
+
225
+                    b.Property<int>("UserId");
226
+
227
+                    b.HasKey("PodcastCommentId");
228
+
229
+                    b.HasIndex("PodcastId");
230
+
231
+                    b.HasIndex("UserId");
232
+
233
+                    b.ToTable("PodcastComments");
234
+                });
235
+
236
+            modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastFile", b =>
237
+                {
238
+                    b.Property<int>("PodcastFileId")
239
+                        .ValueGeneratedOnAdd()
240
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
241
+
242
+                    b.Property<long>("ContentLength");
243
+
244
+                    b.Property<string>("ContentType");
245
+
246
+                    b.Property<string>("FileName");
247
+
248
+                    b.Property<string>("Path");
249
+
250
+                    b.Property<int>("PodcastId");
251
+
252
+                    b.Property<int>("Size");
253
+
254
+                    b.HasKey("PodcastFileId");
255
+
256
+                    b.HasIndex("PodcastId");
257
+
258
+                    b.ToTable("PodcastFiles");
259
+                });
260
+
261
+            modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastTag", b =>
262
+                {
263
+                    b.Property<int>("PodcastTagId")
264
+                        .ValueGeneratedOnAdd()
265
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
266
+
267
+                    b.Property<string>("Description");
268
+
269
+                    b.Property<string>("Name");
270
+
271
+                    b.Property<int>("PodcastId");
272
+
273
+                    b.HasKey("PodcastTagId");
274
+
275
+                    b.HasIndex("PodcastId");
276
+
277
+                    b.ToTable("PodcastTags");
278
+                });
279
+
280
+            modelBuilder.Entity("Teknik.Areas.Shortener.Models.ShortenedUrl", b =>
281
+                {
282
+                    b.Property<int>("ShortenedUrlId")
283
+                        .ValueGeneratedOnAdd()
284
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
285
+
286
+                    b.Property<DateTime>("DateAdded");
287
+
288
+                    b.Property<string>("OriginalUrl");
289
+
290
+                    b.Property<string>("ShortUrl")
291
+                        .HasAnnotation("CaseSensitive", true);
292
+
293
+                    b.Property<int?>("UserId");
294
+
295
+                    b.Property<int>("Views");
296
+
297
+                    b.HasKey("ShortenedUrlId");
298
+
299
+                    b.HasIndex("UserId");
300
+
301
+                    b.ToTable("ShortenedUrls");
302
+                });
303
+
304
+            modelBuilder.Entity("Teknik.Areas.Stats.Models.Takedown", b =>
305
+                {
306
+                    b.Property<int>("TakedownId")
307
+                        .ValueGeneratedOnAdd()
308
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
309
+
310
+                    b.Property<string>("ActionTaken");
311
+
312
+                    b.Property<DateTime>("DateActionTaken");
313
+
314
+                    b.Property<DateTime>("DateRequested");
315
+
316
+                    b.Property<string>("Reason");
317
+
318
+                    b.Property<string>("Requester");
319
+
320
+                    b.Property<string>("RequesterContact");
321
+
322
+                    b.HasKey("TakedownId");
323
+
324
+                    b.ToTable("Takedowns");
325
+                });
326
+
327
+            modelBuilder.Entity("Teknik.Areas.Stats.Models.Transaction", b =>
328
+                {
329
+                    b.Property<int>("TransactionId")
330
+                        .ValueGeneratedOnAdd()
331
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
332
+
333
+                    b.Property<decimal>("Amount")
334
+                        .HasColumnType("decimal(19, 5)");
335
+
336
+                    b.Property<int>("Currency");
337
+
338
+                    b.Property<DateTime>("DateSent");
339
+
340
+                    b.Property<string>("Reason");
341
+
342
+                    b.HasKey("TransactionId");
343
+
344
+                    b.ToTable("Transactions");
345
+                });
346
+
347
+            modelBuilder.Entity("Teknik.Areas.Upload.Models.Upload", b =>
348
+                {
349
+                    b.Property<int>("UploadId")
350
+                        .ValueGeneratedOnAdd()
351
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
352
+
353
+                    b.Property<int>("BlockSize");
354
+
355
+                    b.Property<long>("ContentLength");
356
+
357
+                    b.Property<string>("ContentType");
358
+
359
+                    b.Property<DateTime>("DateUploaded");
360
+
361
+                    b.Property<string>("DeleteKey")
362
+                        .HasAnnotation("CaseSensitive", true);
363
+
364
+                    b.Property<int>("Downloads");
365
+
366
+                    b.Property<DateTime?>("ExpireDate");
367
+
368
+                    b.Property<string>("FileName")
369
+                        .HasAnnotation("CaseSensitive", true);
370
+
371
+                    b.Property<string>("IV")
372
+                        .HasAnnotation("CaseSensitive", true);
373
+
374
+                    b.Property<string>("Key")
375
+                        .HasAnnotation("CaseSensitive", true);
376
+
377
+                    b.Property<int>("KeySize");
378
+
379
+                    b.Property<int>("MaxDownloads");
380
+
381
+                    b.Property<int?>("Takedown_TakedownId");
382
+
383
+                    b.Property<string>("Url")
384
+                        .HasAnnotation("CaseSensitive", true);
385
+
386
+                    b.Property<int?>("UserId");
387
+
388
+                    b.HasKey("UploadId");
389
+
390
+                    b.HasIndex("Takedown_TakedownId");
391
+
392
+                    b.HasIndex("UserId");
393
+
394
+                    b.ToTable("Uploads");
395
+                });
396
+
397
+            modelBuilder.Entity("Teknik.Areas.Users.Models.Feature", b =>
398
+                {
399
+                    b.Property<string>("FeatureId")
400
+                        .ValueGeneratedOnAdd();
401
+
402
+                    b.Property<string>("Description");
403
+
404
+                    b.Property<bool>("Enabled");
405
+
406
+                    b.Property<string>("Name");
407
+
408
+                    b.HasKey("FeatureId");
409
+
410
+                    b.ToTable("Features");
411
+                });
412
+
413
+            modelBuilder.Entity("Teknik.Areas.Users.Models.InviteCode", b =>
414
+                {
415
+                    b.Property<int>("InviteCodeId")
416
+                        .ValueGeneratedOnAdd()
417
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
418
+
419
+                    b.Property<bool>("Active");
420
+
421
+                    b.Property<int?>("ClaimedUserId");
422
+
423
+                    b.Property<string>("Code")
424
+                        .HasAnnotation("CaseSensitive", true);
425
+
426
+                    b.Property<int?>("OwnerId");
427
+
428
+                    b.HasKey("InviteCodeId");
429
+
430
+                    b.HasIndex("ClaimedUserId")
431
+                        .IsUnique()
432
+                        .HasFilter("[ClaimedUserId] IS NOT NULL");
433
+
434
+                    b.HasIndex("OwnerId");
435
+
436
+                    b.ToTable("InviteCodes");
437
+                });
438
+
439
+            modelBuilder.Entity("Teknik.Areas.Users.Models.User", b =>
440
+                {
441
+                    b.Property<int>("UserId")
442
+                        .ValueGeneratedOnAdd()
443
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
444
+
445
+                    b.Property<string>("Username");
446
+
447
+                    b.HasKey("UserId");
448
+
449
+                    b.ToTable("Users");
450
+                });
451
+
452
+            modelBuilder.Entity("Teknik.Areas.Users.Models.UserFeature", b =>
453
+                {
454
+                    b.Property<int>("UserFeatureId")
455
+                        .ValueGeneratedOnAdd()
456
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
457
+
458
+                    b.Property<string>("FeatureId");
459
+
460
+                    b.Property<int>("UserId");
461
+
462
+                    b.HasKey("UserFeatureId");
463
+
464
+                    b.HasIndex("FeatureId");
465
+
466
+                    b.HasIndex("UserId");
467
+
468
+                    b.ToTable("UserFeatures");
469
+                });
470
+
471
+            modelBuilder.Entity("Teknik.Areas.Vault.Models.Vault", b =>
472
+                {
473
+                    b.Property<int>("VaultId")
474
+                        .ValueGeneratedOnAdd()
475
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
476
+
477
+                    b.Property<DateTime>("DateCreated");
478
+
479
+                    b.Property<DateTime>("DateEdited");
480
+
481
+                    b.Property<string>("Description");
482
+
483
+                    b.Property<string>("Title");
484
+
485
+                    b.Property<string>("Url");
486
+
487
+                    b.Property<int?>("UserId");
488
+
489
+                    b.Property<int>("Views");
490
+
491
+                    b.HasKey("VaultId");
492
+
493
+                    b.HasIndex("UserId");
494
+
495
+                    b.ToTable("Vaults");
496
+                });
497
+
498
+            modelBuilder.Entity("Teknik.Areas.Vault.Models.VaultItem", b =>
499
+                {
500
+                    b.Property<int>("VaultItemId")
501
+                        .ValueGeneratedOnAdd()
502
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
503
+
504
+                    b.Property<DateTime>("DateAdded");
505
+
506
+                    b.Property<string>("Description");
507
+
508
+                    b.Property<string>("Discriminator")
509
+                        .IsRequired();
510
+
511
+                    b.Property<string>("Title");
512
+
513
+                    b.Property<int>("VaultId");
514
+
515
+                    b.HasKey("VaultItemId");
516
+
517
+                    b.HasIndex("VaultId");
518
+
519
+                    b.ToTable("VaultItems");
520
+
521
+                    b.HasDiscriminator<string>("Discriminator").HasValue("VaultItem");
522
+                });
523
+
524
+            modelBuilder.Entity("Teknik.Areas.Vault.Models.PasteVaultItem", b =>
525
+                {
526
+                    b.HasBaseType("Teknik.Areas.Vault.Models.VaultItem");
527
+
528
+                    b.Property<int>("PasteId");
529
+
530
+                    b.HasIndex("PasteId");
531
+
532
+                    b.HasDiscriminator().HasValue("PasteVaultItem");
533
+                });
534
+
535
+            modelBuilder.Entity("Teknik.Areas.Vault.Models.UploadVaultItem", b =>
536
+                {
537
+                    b.HasBaseType("Teknik.Areas.Vault.Models.VaultItem");
538
+
539
+                    b.Property<int>("UploadId");
540
+
541
+                    b.HasIndex("UploadId");
542
+
543
+                    b.HasDiscriminator().HasValue("UploadVaultItem");
544
+                });
545
+
546
+            modelBuilder.Entity("Teknik.Areas.Blog.Models.Blog", b =>
547
+                {
548
+                    b.HasOne("Teknik.Areas.Users.Models.User", "User")
549
+                        .WithMany()
550
+                        .HasForeignKey("UserId")
551
+                        .OnDelete(DeleteBehavior.Cascade);
552
+                });
553
+
554
+            modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPost", b =>
555
+                {
556
+                    b.HasOne("Teknik.Areas.Blog.Models.Blog", "Blog")
557
+                        .WithMany("BlogPosts")
558
+                        .HasForeignKey("BlogId")
559
+                        .OnDelete(DeleteBehavior.Cascade);
560
+                });
561
+
562
+            modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPostComment", b =>
563
+                {
564
+                    b.HasOne("Teknik.Areas.Blog.Models.BlogPost", "BlogPost")
565
+                        .WithMany("Comments")
566
+                        .HasForeignKey("BlogPostId")
567
+                        .OnDelete(DeleteBehavior.Cascade);
568
+
569
+                    b.HasOne("Teknik.Areas.Users.Models.User", "User")
570
+                        .WithMany()
571
+                        .HasForeignKey("UserId");
572
+                });
573
+
574
+            modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPostTag", b =>
575
+                {
576
+                    b.HasOne("Teknik.Areas.Blog.Models.BlogPost", "BlogPost")
577
+                        .WithMany("Tags")
578
+                        .HasForeignKey("BlogPostId")
579
+                        .OnDelete(DeleteBehavior.Cascade);
580
+                });
581
+
582
+            modelBuilder.Entity("Teknik.Areas.Paste.Models.Paste", b =>
583
+                {
584
+                    b.HasOne("Teknik.Areas.Users.Models.User", "User")
585
+                        .WithMany("Pastes")
586
+                        .HasForeignKey("UserId");
587
+                });
588
+
589
+            modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastComment", b =>
590
+                {
591
+                    b.HasOne("Teknik.Areas.Podcast.Models.Podcast", "Podcast")
592
+                        .WithMany("Comments")
593
+                        .HasForeignKey("PodcastId")
594
+                        .OnDelete(DeleteBehavior.Cascade);
595
+
596
+                    b.HasOne("Teknik.Areas.Users.Models.User", "User")
597
+                        .WithMany()
598
+                        .HasForeignKey("UserId")
599
+                        .OnDelete(DeleteBehavior.Cascade);
600
+                });
601
+
602
+            modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastFile", b =>
603
+                {
604
+                    b.HasOne("Teknik.Areas.Podcast.Models.Podcast", "Podcast")
605
+                        .WithMany("Files")
606
+                        .HasForeignKey("PodcastId")
607
+                        .OnDelete(DeleteBehavior.Cascade);
608
+                });
609
+
610
+            modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastTag", b =>
611
+                {
612
+                    b.HasOne("Teknik.Areas.Podcast.Models.Podcast", "Podcast")
613
+                        .WithMany("Tags")
614
+                        .HasForeignKey("PodcastId")
615
+                        .OnDelete(DeleteBehavior.Cascade);
616
+                });
617
+
618
+            modelBuilder.Entity("Teknik.Areas.Shortener.Models.ShortenedUrl", b =>
619
+                {
620
+                    b.HasOne("Teknik.Areas.Users.Models.User", "User")
621
+                        .WithMany("ShortenedUrls")
622
+                        .HasForeignKey("UserId");
623
+                });
624
+
625
+            modelBuilder.Entity("Teknik.Areas.Upload.Models.Upload", b =>
626
+                {
627
+                    b.HasOne("Teknik.Areas.Stats.Models.Takedown")
628
+                        .WithMany("Attachments")
629
+                        .HasForeignKey("Takedown_TakedownId");
630
+
631
+                    b.HasOne("Teknik.Areas.Users.Models.User", "User")
632
+                        .WithMany("Uploads")
633
+                        .HasForeignKey("UserId");
634
+                });
635
+
636
+            modelBuilder.Entity("Teknik.Areas.Users.Models.InviteCode", b =>
637
+                {
638
+                    b.HasOne("Teknik.Areas.Users.Models.User", "ClaimedUser")
639
+                        .WithOne("ClaimedInviteCode")
640
+                        .HasForeignKey("Teknik.Areas.Users.Models.InviteCode", "ClaimedUserId");
641
+
642
+                    b.HasOne("Teknik.Areas.Users.Models.User", "Owner")
643
+                        .WithMany("OwnedInviteCodes")
644
+                        .HasForeignKey("OwnerId");
645
+                });
646
+
647
+            modelBuilder.Entity("Teknik.Areas.Users.Models.User", b =>
648
+                {
649
+                    b.OwnsOne("Teknik.Areas.Users.Models.BlogSettings", "BlogSettings", b1 =>
650
+                        {
651
+                            b1.Property<int>("UserId")
652
+                                .ValueGeneratedOnAdd()
653
+                                .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
654
+
655
+                            b1.Property<string>("Description")
656
+                                .HasColumnName("Description");
657
+
658
+                            b1.Property<string>("Title")
659
+                                .HasColumnName("Title");
660
+
661
+                            b1.HasKey("UserId");
662
+
663
+                            b1.ToTable("Users");
664
+
665
+                            b1.HasOne("Teknik.Areas.Users.Models.User")
666
+                                .WithOne("BlogSettings")
667
+                                .HasForeignKey("Teknik.Areas.Users.Models.BlogSettings", "UserId")
668
+                                .OnDelete(DeleteBehavior.Cascade);
669
+                        });
670
+
671
+                    b.OwnsOne("Teknik.Areas.Users.Models.UploadSettings", "UploadSettings", b1 =>
672
+                        {
673
+                            b1.Property<int>("UserId")
674
+                                .ValueGeneratedOnAdd()
675
+                                .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
676
+
677
+                            b1.Property<bool>("Encrypt")
678
+                                .HasColumnName("Encrypt");
679
+
680
+                            b1.Property<int>("ExpirationLength")
681
+                                .HasColumnName("ExpirationLength");
682
+
683
+                            b1.Property<int>("ExpirationUnit")
684
+                                .HasColumnName("ExpirationUnit");
685
+
686
+                            b1.HasKey("UserId");
687
+
688
+                            b1.ToTable("Users");
689
+
690
+                            b1.HasOne("Teknik.Areas.Users.Models.User")
691
+                                .WithOne("UploadSettings")
692
+                                .HasForeignKey("Teknik.Areas.Users.Models.UploadSettings", "UserId")
693
+                                .OnDelete(DeleteBehavior.Cascade);
694
+                        });
695
+
696
+                    b.OwnsOne("Teknik.Areas.Users.Models.UserSettings", "UserSettings", b1 =>
697
+                        {
698
+                            b1.Property<int>("UserId")
699
+                                .ValueGeneratedOnAdd()
700
+                                .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
701
+
702
+                            b1.Property<string>("About")
703
+                                .HasColumnName("About");
704
+
705
+                            b1.Property<string>("Quote")
706
+                                .HasColumnName("Quote");
707
+
708
+                            b1.Property<string>("Website")
709
+                                .HasColumnName("Website");
710
+
711
+                            b1.HasKey("UserId");
712
+
713
+                            b1.ToTable("Users");
714
+
715
+                            b1.HasOne("Teknik.Areas.Users.Models.User")
716
+                                .WithOne("UserSettings")
717
+                                .HasForeignKey("Teknik.Areas.Users.Models.UserSettings", "UserId")
718
+                                .OnDelete(DeleteBehavior.Cascade);
719
+                        });
720
+                });
721
+
722
+            modelBuilder.Entity("Teknik.Areas.Users.Models.UserFeature", b =>
723
+                {
724
+                    b.HasOne("Teknik.Areas.Users.Models.Feature", "Feature")
725
+                        .WithMany()
726
+                        .HasForeignKey("FeatureId");
727
+
728
+                    b.HasOne("Teknik.Areas.Users.Models.User", "User")
729
+                        .WithMany("Features")
730
+                        .HasForeignKey("UserId")
731
+                        .OnDelete(DeleteBehavior.Cascade);
732
+                });
733
+
734
+            modelBuilder.Entity("Teknik.Areas.Vault.Models.Vault", b =>
735
+                {
736
+                    b.HasOne("Teknik.Areas.Users.Models.User", "User")
737
+                        .WithMany("Vaults")
738
+                        .HasForeignKey("UserId");
739
+                });
740
+
741
+            modelBuilder.Entity("Teknik.Areas.Vault.Models.VaultItem", b =>
742
+                {
743
+                    b.HasOne("Teknik.Areas.Vault.Models.Vault", "Vault")
744
+                        .WithMany("VaultItems")
745
+                        .HasForeignKey("VaultId")
746
+                        .OnDelete(DeleteBehavior.Cascade);
747
+                });
748
+
749
+            modelBuilder.Entity("Teknik.Areas.Vault.Models.PasteVaultItem", b =>
750
+                {
751
+                    b.HasOne("Teknik.Areas.Paste.Models.Paste", "Paste")
752
+                        .WithMany("PasteVaultItems")
753
+                        .HasForeignKey("PasteId")
754
+                        .OnDelete(DeleteBehavior.Cascade);
755
+                });
756
+
757
+            modelBuilder.Entity("Teknik.Areas.Vault.Models.UploadVaultItem", b =>
758
+                {
759
+                    b.HasOne("Teknik.Areas.Upload.Models.Upload", "Upload")
760
+                        .WithMany("UploadVaultItems")
761
+                        .HasForeignKey("UploadId")
762
+                        .OnDelete(DeleteBehavior.Cascade);
763
+                });
764
+#pragma warning restore 612, 618
765
+        }
766
+    }
767
+}

+ 100
- 0
Teknik/Data/Migrations/20190127224049_Features.cs View File

@@ -0,0 +1,100 @@
1
+using Microsoft.EntityFrameworkCore.Metadata;
2
+using Microsoft.EntityFrameworkCore.Migrations;
3
+
4
+namespace Teknik.Data.Migrations
5
+{
6
+    public partial class Features : Migration
7
+    {
8
+        protected override void Up(MigrationBuilder migrationBuilder)
9
+        {
10
+            migrationBuilder.DropTable(
11
+                name: "UserLogins");
12
+
13
+            migrationBuilder.CreateTable(
14
+                name: "Features",
15
+                columns: table => new
16
+                {
17
+                    FeatureId = table.Column<string>(nullable: false),
18
+                    Name = table.Column<string>(nullable: true),
19
+                    Description = table.Column<string>(nullable: true),
20
+                    Enabled = table.Column<bool>(nullable: false)
21
+                },
22
+                constraints: table =>
23
+                {
24
+                    table.PrimaryKey("PK_Features", x => x.FeatureId);
25
+                });
26
+
27
+            migrationBuilder.CreateTable(
28
+                name: "UserFeatures",
29
+                columns: table => new
30
+                {
31
+                    UserFeatureId = table.Column<int>(nullable: false)
32
+                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
33
+                    FeatureId = table.Column<string>(nullable: true),
34
+                    UserId = table.Column<int>(nullable: false)
35
+                },
36
+                constraints: table =>
37
+                {
38
+                    table.PrimaryKey("PK_UserFeatures", x => x.UserFeatureId);
39
+                    table.ForeignKey(
40
+                        name: "FK_UserFeatures_Features_FeatureId",
41
+                        column: x => x.FeatureId,
42
+                        principalTable: "Features",
43
+                        principalColumn: "FeatureId",
44
+                        onDelete: ReferentialAction.Restrict);
45
+                    table.ForeignKey(
46
+                        name: "FK_UserFeatures_Users_UserId",
47
+                        column: x => x.UserId,
48
+                        principalTable: "Users",
49
+                        principalColumn: "UserId",
50
+                        onDelete: ReferentialAction.Cascade);
51
+                });
52
+
53
+            migrationBuilder.CreateIndex(
54
+                name: "IX_UserFeatures_FeatureId",
55
+                table: "UserFeatures",
56
+                column: "FeatureId");
57
+
58
+            migrationBuilder.CreateIndex(
59
+                name: "IX_UserFeatures_UserId",
60
+                table: "UserFeatures",
61
+                column: "UserId");
62
+        }
63
+
64
+        protected override void Down(MigrationBuilder migrationBuilder)
65
+        {
66
+            migrationBuilder.DropTable(
67
+                name: "UserFeatures");
68
+
69
+            migrationBuilder.DropTable(
70
+                name: "Features");
71
+
72
+            migrationBuilder.CreateTable(
73
+                name: "UserLogins",
74
+                columns: table => new
75
+                {
76
+                    LoginInfoId = table.Column<int>(nullable: false)
77
+                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
78
+                    LoginProvider = table.Column<string>(nullable: true),
79
+                    ProviderDisplayName = table.Column<string>(nullable: true),
80
+                    ProviderKey = table.Column<string>(nullable: true),
81
+                    UserId = table.Column<int>(nullable: false)
82
+                },
83
+                constraints: table =>
84
+                {
85
+                    table.PrimaryKey("PK_UserLogins", x => x.LoginInfoId);
86
+                    table.ForeignKey(
87
+                        name: "FK_UserLogins_Users_UserId",
88
+                        column: x => x.UserId,
89
+                        principalTable: "Users",
90
+                        principalColumn: "UserId",
91
+                        onDelete: ReferentialAction.Cascade);
92
+                });
93
+
94
+            migrationBuilder.CreateIndex(
95
+                name: "IX_UserLogins_UserId",
96
+                table: "UserLogins",
97
+                column: "UserId");
98
+        }
99
+    }
100
+}

+ 44
- 26
Teknik/Data/Migrations/TeknikEntitiesModelSnapshot.cs View File

@@ -392,6 +392,22 @@ namespace Teknik.Data.Migrations
392 392
                     b.ToTable("Uploads");
393 393
                 });
394 394
 
395
+            modelBuilder.Entity("Teknik.Areas.Users.Models.Feature", b =>
396
+                {
397
+                    b.Property<string>("FeatureId")
398
+                        .ValueGeneratedOnAdd();
399
+
400
+                    b.Property<string>("Description");
401
+
402
+                    b.Property<bool>("Enabled");
403
+
404
+                    b.Property<string>("Name");
405
+
406
+                    b.HasKey("FeatureId");
407
+
408
+                    b.ToTable("Features");
409
+                });
410
+
395 411
             modelBuilder.Entity("Teknik.Areas.Users.Models.InviteCode", b =>
396 412
                 {
397 413
                     b.Property<int>("InviteCodeId")
@@ -418,38 +434,36 @@ namespace Teknik.Data.Migrations
418 434
                     b.ToTable("InviteCodes");
419 435
                 });
420 436
 
421
-            modelBuilder.Entity("Teknik.Areas.Users.Models.LoginInfo", b =>
437
+            modelBuilder.Entity("Teknik.Areas.Users.Models.User", b =>
422 438
                 {
423
-                    b.Property<int>("LoginInfoId")
439
+                    b.Property<int>("UserId")
424 440
                         .ValueGeneratedOnAdd()
425 441
                         .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
426 442
 
427
-                    b.Property<string>("LoginProvider");
428
-
429
-                    b.Property<string>("ProviderDisplayName");
430
-
431
-                    b.Property<string>("ProviderKey");
432
-
433
-                    b.Property<int>("UserId");
434
-
435
-                    b.HasKey("LoginInfoId");
443
+                    b.Property<string>("Username");
436 444
 
437
-                    b.HasIndex("UserId");
445
+                    b.HasKey("UserId");
438 446
 
439
-                    b.ToTable("UserLogins");
447
+                    b.ToTable("Users");
440 448
                 });
441 449
 
442
-            modelBuilder.Entity("Teknik.Areas.Users.Models.User", b =>
450
+            modelBuilder.Entity("Teknik.Areas.Users.Models.UserFeature", b =>
443 451
                 {
444
-                    b.Property<int>("UserId")
452
+                    b.Property<int>("UserFeatureId")
445 453
                         .ValueGeneratedOnAdd()
446 454
                         .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
447 455
 
448
-                    b.Property<string>("Username");
456
+                    b.Property<string>("FeatureId");
449 457
 
450
-                    b.HasKey("UserId");
458
+                    b.Property<int>("UserId");
451 459
 
452
-                    b.ToTable("Users");
460
+                    b.HasKey("UserFeatureId");
461
+
462
+                    b.HasIndex("FeatureId");
463
+
464
+                    b.HasIndex("UserId");
465
+
466
+                    b.ToTable("UserFeatures");
453 467
                 });
454 468
 
455 469
             modelBuilder.Entity("Teknik.Areas.Vault.Models.Vault", b =>
@@ -628,14 +642,6 @@ namespace Teknik.Data.Migrations
628 642
                         .HasForeignKey("OwnerId");
629 643
                 });
630 644
 
631
-            modelBuilder.Entity("Teknik.Areas.Users.Models.LoginInfo", b =>
632
-                {
633
-                    b.HasOne("Teknik.Areas.Users.Models.User", "User")
634
-                        .WithMany("Logins")
635
-                        .HasForeignKey("UserId")
636
-                        .OnDelete(DeleteBehavior.Cascade);
637
-                });
638
-
639 645
             modelBuilder.Entity("Teknik.Areas.Users.Models.User", b =>
640 646
                 {
641 647
                     b.OwnsOne("Teknik.Areas.Users.Models.BlogSettings", "BlogSettings", b1 =>
@@ -711,6 +717,18 @@ namespace Teknik.Data.Migrations
711 717
                         });
712 718
                 });
713 719
 
720
+            modelBuilder.Entity("Teknik.Areas.Users.Models.UserFeature", b =>
721
+                {
722
+                    b.HasOne("Teknik.Areas.Users.Models.Feature", "Feature")
723
+                        .WithMany()
724
+                        .HasForeignKey("FeatureId");
725
+
726
+                    b.HasOne("Teknik.Areas.Users.Models.User", "User")
727
+                        .WithMany("Features")
728
+                        .HasForeignKey("UserId")
729
+                        .OnDelete(DeleteBehavior.Cascade);
730
+                });
731
+
714 732
             modelBuilder.Entity("Teknik.Areas.Vault.Models.Vault", b =>
715 733
                 {
716 734
                     b.HasOne("Teknik.Areas.Users.Models.User", "User")

+ 11
- 3
Teknik/Data/TeknikEntities.cs View File

@@ -19,12 +19,14 @@ namespace Teknik.Data
19 19
     {
20 20
         // Users
21 21
         public DbSet<User> Users { get; set; }
22
-        public DbSet<LoginInfo> UserLogins { get; set; }
23 22
         public DbSet<InviteCode> InviteCodes { get; set; }
23
+        public DbSet<UserFeature> UserFeatures { get; set; }
24 24
         // User Settings
25 25
         public DbSet<UserSettings> UserSettings { get; set; }
26 26
         public DbSet<BlogSettings> BlogSettings { get; set; }
27 27
         public DbSet<UploadSettings> UploadSettings { get; set; }
28
+        // Features
29
+        public DbSet<Feature> Features { get; set; }
28 30
         // Blogs
29 31
         public DbSet<Blog> Blogs { get; set; }
30 32
         public DbSet<BlogPost> BlogPosts { get; set; }
@@ -70,13 +72,13 @@ namespace Teknik.Data
70 72
             modelBuilder.Entity<User>().OwnsOne(u => u.UserSettings);
71 73
             modelBuilder.Entity<User>().OwnsOne(u => u.BlogSettings);
72 74
             modelBuilder.Entity<User>().OwnsOne(u => u.UploadSettings);
75
+            modelBuilder.Entity<User>().HasMany(u => u.Features).WithOne(u => u.User);
73 76
             modelBuilder.Entity<User>().HasMany(u => u.Uploads).WithOne(u => u.User);
74 77
             modelBuilder.Entity<User>().HasMany(u => u.Pastes).WithOne(u => u.User);
75 78
             modelBuilder.Entity<User>().HasMany(u => u.ShortenedUrls).WithOne(u => u.User);
76 79
             modelBuilder.Entity<User>().HasMany(u => u.Vaults).WithOne(u => u.User);
77 80
             modelBuilder.Entity<User>().HasMany(u => u.OwnedInviteCodes).WithOne(i => i.Owner);
78 81
             modelBuilder.Entity<User>().HasOne(u => u.ClaimedInviteCode).WithOne(i => i.ClaimedUser);
79
-            modelBuilder.Entity<User>().HasMany(u => u.Logins).WithOne(r => r.User);
80 82
             modelBuilder.Entity<User>().HasOne(u => u.ClaimedInviteCode).WithOne(t => t.ClaimedUser); // Legacy???
81 83
             modelBuilder.Entity<User>().HasMany(u => u.OwnedInviteCodes).WithOne(t => t.Owner); // Legacy???
82 84
 
@@ -84,6 +86,10 @@ namespace Teknik.Data
84 86
             //modelBuilder.Entity<InviteCode>().HasOne(t => t.ClaimedUser).WithOne(u => u.ClaimedInviteCode).HasPrincipalKey("ClaimedUserId").HasForeignKey("ClaimedUser_UserId"); // Legacy???
85 87
             //modelBuilder.Entity<InviteCode>().HasOne(t => t.Owner).WithMany(u => u.OwnedInviteCodes).HasPrincipalKey("ClaimedUserId").HasForeignKey("Owner_UserId"); // Legacy???
86 88
 
89
+            // Features
90
+            modelBuilder.Entity<UserFeature>().HasOne(f => f.Feature);
91
+            modelBuilder.Entity<UserFeature>().HasOne(f => f.User);
92
+
87 93
             // Blogs
88 94
             modelBuilder.Entity<BlogPost>().HasMany(p => p.Comments).WithOne(c => c.BlogPost);
89 95
 
@@ -107,12 +113,14 @@ namespace Teknik.Data
107 113
 
108 114
             // Users
109 115
             modelBuilder.Entity<User>().ToTable("Users");
110
-            modelBuilder.Entity<LoginInfo>().ToTable("UserLogins");
111 116
             modelBuilder.Entity<InviteCode>().ToTable("InviteCodes");
117
+            modelBuilder.Entity<UserFeature>().ToTable("UserFeatures");
112 118
             // User Settings
113 119
             modelBuilder.Entity<UserSettings>().ToTable("Users");
114 120
             modelBuilder.Entity<BlogSettings>().ToTable("Users");
115 121
             modelBuilder.Entity<UploadSettings>().ToTable("Users");
122
+            // Features
123
+            modelBuilder.Entity<Feature>().ToTable("Features");
116 124
             // Blogs
117 125
             modelBuilder.Entity<Blog>().ToTable("Blogs");
118 126
             modelBuilder.Entity<BlogPost>().ToTable("BlogPosts");

Loading…
Cancel
Save