diff --git a/Teknik/Areas/API/V1/Controllers/AccountAPIv1Controller.cs b/Teknik/Areas/API/V1/Controllers/AccountAPIv1Controller.cs index ce66bd8..22a5d42 100644 --- a/Teknik/Areas/API/V1/Controllers/AccountAPIv1Controller.cs +++ b/Teknik/Areas/API/V1/Controllers/AccountAPIv1Controller.cs @@ -12,7 +12,7 @@ using Teknik.Logging; namespace Teknik.Areas.API.V1.Controllers { - [Authorize(AuthenticationSchemes = "Bearer", Policy = "AnyAPI")] + [Authorize(Policy = "AnyAPI")] public class AccountAPIv1Controller : APIv1Controller { public AccountAPIv1Controller(ILogger logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { } diff --git a/Teknik/Areas/API/V1/Controllers/AdminAPIv1Controller.cs b/Teknik/Areas/API/V1/Controllers/AdminAPIv1Controller.cs index 008f0fe..ca33eaa 100644 --- a/Teknik/Areas/API/V1/Controllers/AdminAPIv1Controller.cs +++ b/Teknik/Areas/API/V1/Controllers/AdminAPIv1Controller.cs @@ -13,7 +13,7 @@ using Teknik.Logging; namespace Teknik.Areas.API.V1.Controllers { - [Authorize(AuthenticationSchemes = "Bearer", Roles = "Admin", Policy = "AnyAPI")] + [Authorize(Roles = "Admin", Policy = "AnyAPI")] public class AdminAPIv1Controller : APIv1Controller { public AdminAPIv1Controller(ILogger logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { } diff --git a/Teknik/Areas/API/V1/Controllers/PasteAPIv1Controller.cs b/Teknik/Areas/API/V1/Controllers/PasteAPIv1Controller.cs index 6ba6e11..4bdfd3f 100644 --- a/Teknik/Areas/API/V1/Controllers/PasteAPIv1Controller.cs +++ b/Teknik/Areas/API/V1/Controllers/PasteAPIv1Controller.cs @@ -17,20 +17,19 @@ using Teknik.Utilities; namespace Teknik.Areas.API.V1.Controllers { - [Authorize(AuthenticationSchemes = "Bearer", Policy = "WriteOnlyAPI")] + [Authorize(Policy = "WriteAPI")] public class PasteAPIv1Controller : APIv1Controller { public PasteAPIv1Controller(ILogger logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { } [HttpPost] - [AllowAnonymous] public IActionResult Paste(PasteAPIv1Model model) { try { if (model != null && model.code != null) { - Paste.Models.Paste paste = PasteHelper.CreatePaste(_config, _dbContext, model.code, model.title, model.syntax, model.expireUnit, model.expireLength, model.password, model.hide); + Paste.Models.Paste paste = PasteHelper.CreatePaste(_config, _dbContext, model.code, model.title, model.syntax, model.expireUnit, model.expireLength, model.password); // Associate this with the user if they are logged in if (User.Identity.IsAuthenticated) diff --git a/Teknik/Areas/API/V1/Controllers/ShortenAPIv1Controller.cs b/Teknik/Areas/API/V1/Controllers/ShortenAPIv1Controller.cs index 4a23d80..b859f80 100644 --- a/Teknik/Areas/API/V1/Controllers/ShortenAPIv1Controller.cs +++ b/Teknik/Areas/API/V1/Controllers/ShortenAPIv1Controller.cs @@ -18,13 +18,12 @@ using Teknik.Utilities; namespace Teknik.Areas.API.V1.Controllers { - [Authorize(AuthenticationSchemes = "Bearer", Policy = "WriteOnlyAPI")] + [Authorize(Policy = "WriteAPI")] public class ShortenAPIv1Controller : APIv1Controller { public ShortenAPIv1Controller(ILogger logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { } [HttpPost] - [AllowAnonymous] public IActionResult Shorten(ShortenAPIv1Model model) { try diff --git a/Teknik/Areas/API/V1/Controllers/UploadAPIv1Controller.cs b/Teknik/Areas/API/V1/Controllers/UploadAPIv1Controller.cs index dcd2ca9..95e147f 100644 --- a/Teknik/Areas/API/V1/Controllers/UploadAPIv1Controller.cs +++ b/Teknik/Areas/API/V1/Controllers/UploadAPIv1Controller.cs @@ -22,7 +22,7 @@ using Teknik.Utilities; namespace Teknik.Areas.API.V1.Controllers { - [Authorize(AuthenticationSchemes = "Bearer", Policy = "WriteOnlyAPI")] + [Authorize(Policy = "WriteAPI")] public class UploadAPIv1Controller : APIv1Controller { public UploadAPIv1Controller(ILogger logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { } @@ -47,6 +47,12 @@ namespace Teknik.Areas.API.V1.Controllers maxUploadSize = _config.UploadConfig.MaxUploadSizePremium; } } + else + { + // Non-logged in users are defaulted to 1 day expiration + model.expirationUnit = ExpirationUnit.Days; + model.expirationLength = 1; + } if (model.file.Length <= maxUploadSize) { // convert file to bytes @@ -156,6 +162,8 @@ namespace Teknik.Areas.API.V1.Controllers keySize = upload.KeySize, iv = upload.IV, blockSize = upload.BlockSize, + maxDownloads = upload.MaxDownloads, + expirationDate = upload.ExpireDate, deletionKey = upload.DeleteKey }; diff --git a/Teknik/Areas/API/V1/Models/PasteAPIv1Model.cs b/Teknik/Areas/API/V1/Models/PasteAPIv1Model.cs index f0add52..f4dab17 100644 --- a/Teknik/Areas/API/V1/Models/PasteAPIv1Model.cs +++ b/Teknik/Areas/API/V1/Models/PasteAPIv1Model.cs @@ -14,8 +14,6 @@ public string password { get; set; } - public bool hide { get; set; } - public PasteAPIv1Model() { code = null; @@ -24,7 +22,6 @@ expireUnit = "never"; expireLength = 1; password = string.Empty; - hide = false; } } } \ No newline at end of file diff --git a/Teknik/Areas/Paste/Controllers/PasteController.cs b/Teknik/Areas/Paste/Controllers/PasteController.cs index d448ef3..95ceded 100644 --- a/Teknik/Areas/Paste/Controllers/PasteController.cs +++ b/Teknik/Areas/Paste/Controllers/PasteController.cs @@ -143,7 +143,7 @@ namespace Teknik.Areas.Paste.Controllers [HttpPost] [AllowAnonymous] [DisableRequestSizeLimit] - public IActionResult Paste([Bind("Content, Title, Syntax, ExpireLength, ExpireUnit, Password, Hide")]PasteCreateViewModel model) + public IActionResult Paste([Bind("Content, Title, Syntax, ExpireLength, ExpireUnit, Password")]PasteCreateViewModel model) { if (ModelState.IsValid) { @@ -151,7 +151,7 @@ namespace Teknik.Areas.Paste.Controllers { try { - Models.Paste paste = PasteHelper.CreatePaste(_config, _dbContext, model.Content, model.Title, model.Syntax, model.ExpireUnit, model.ExpireLength ?? 1, model.Password, model.Hide); + Models.Paste paste = PasteHelper.CreatePaste(_config, _dbContext, model.Content, model.Title, model.Syntax, model.ExpireUnit, model.ExpireLength ?? 1, model.Password); if (model.ExpireUnit == "view") { diff --git a/Teknik/Areas/Paste/Models/Paste.cs b/Teknik/Areas/Paste/Models/Paste.cs index 448b2cb..d8d0eba 100644 --- a/Teknik/Areas/Paste/Models/Paste.cs +++ b/Teknik/Areas/Paste/Models/Paste.cs @@ -51,8 +51,6 @@ namespace Teknik.Areas.Paste.Models [CaseSensitive] public string DeleteKey { get; set; } - public bool Hide { get; set; } - public int MaxViews { get; set; } public int Views { get; set; } diff --git a/Teknik/Areas/Paste/PasteHelper.cs b/Teknik/Areas/Paste/PasteHelper.cs index 68db696..50c6336 100644 --- a/Teknik/Areas/Paste/PasteHelper.cs +++ b/Teknik/Areas/Paste/PasteHelper.cs @@ -14,7 +14,7 @@ namespace Teknik.Areas.Paste { public static class PasteHelper { - public static Models.Paste CreatePaste(Config config, TeknikEntities db, string content, string title = "", string syntax = "text", string expireUnit = "never", int expireLength = 1, string password = "", bool hide = false) + public static Models.Paste CreatePaste(Config config, TeknikEntities db, string content, string title = "", string syntax = "text", string expireUnit = "never", int expireLength = 1, string password = "") { Models.Paste paste = new Models.Paste(); paste.DatePosted = DateTime.Now; @@ -88,7 +88,6 @@ namespace Teknik.Areas.Paste //paste.Content = content; paste.Title = title; paste.Syntax = syntax; - paste.Hide = hide; paste.DeleteKey = delKey; return paste; diff --git a/Teknik/Areas/Paste/ViewModels/PasteCreateViewModel.cs b/Teknik/Areas/Paste/ViewModels/PasteCreateViewModel.cs index 0d28afd..e9bab26 100644 --- a/Teknik/Areas/Paste/ViewModels/PasteCreateViewModel.cs +++ b/Teknik/Areas/Paste/ViewModels/PasteCreateViewModel.cs @@ -19,8 +19,6 @@ namespace Teknik.Areas.Paste.ViewModels public string Password { get; set; } - public bool Hide { get; set; } - public string CurrentSub { get; set; } } } diff --git a/Teknik/Areas/Paste/Views/Paste/Index.cshtml b/Teknik/Areas/Paste/Views/Paste/Index.cshtml index d8ccb3d..b76cc27 100644 --- a/Teknik/Areas/Paste/Views/Paste/Index.cshtml +++ b/Teknik/Areas/Paste/Views/Paste/Index.cshtml @@ -62,15 +62,6 @@ -
-
-
- -
-
-
diff --git a/Teknik/Areas/Upload/Controllers/UploadController.cs b/Teknik/Areas/Upload/Controllers/UploadController.cs index 6ad7b25..26c5417 100644 --- a/Teknik/Areas/Upload/Controllers/UploadController.cs +++ b/Teknik/Areas/Upload/Controllers/UploadController.cs @@ -72,6 +72,12 @@ namespace Teknik.Areas.Upload.Controllers maxUploadSize = _config.UploadConfig.MaxUploadSizePremium; } } + else + { + // Non-logged in users are defaulted to 1 day expiration + uploadFile.options.ExpirationUnit = ExpirationUnit.Days; + uploadFile.options.ExpirationLength = 1; + } if (uploadFile.file.Length <= maxUploadSize) { // convert file to bytes @@ -135,7 +141,16 @@ namespace Teknik.Areas.Upload.Controllers _dbContext.SaveChanges(); } } - return Json(new { result = new { name = upload.Url, url = Url.SubRouteUrl("u", "Upload.Download", new { file = upload.Url }), contentType = upload.ContentType, contentLength = StringHelper.GetBytesReadable(upload.ContentLength), deleteUrl = Url.SubRouteUrl("u", "Upload.DeleteByKey", new { file = upload.Url, key = upload.DeleteKey }) } }); + return Json(new { result = new + { + name = upload.Url, + url = Url.SubRouteUrl("u", "Upload.Download", new { file = upload.Url }), + contentType = upload.ContentType, + contentLength = StringHelper.GetBytesReadable(upload.ContentLength), + deleteUrl = Url.SubRouteUrl("u", "Upload.DeleteByKey", new { file = upload.Url, key = upload.DeleteKey }), + expirationUnit = uploadFile.options.ExpirationUnit.ToString(), + expirationLength = uploadFile.options.ExpirationLength + } }); } } return Json(new { error = new { message = "Unable to upload file" } }); diff --git a/Teknik/Areas/Upload/Views/Upload/Index.cshtml b/Teknik/Areas/Upload/Views/Upload/Index.cshtml index 1c39252..dc07a15 100644 --- a/Teknik/Areas/Upload/Views/Upload/Index.cshtml +++ b/Teknik/Areas/Upload/Views/Upload/Index.cshtml @@ -109,6 +109,8 @@ + @if (User.Identity.IsAuthenticated) + {
@@ -129,6 +131,7 @@
+ } diff --git a/Teknik/Areas/User/Views/User/Settings/DeveloperSettings.cshtml b/Teknik/Areas/User/Views/User/Settings/DeveloperSettings.cshtml index b737152..6c6f3d5 100644 --- a/Teknik/Areas/User/Views/User/Settings/DeveloperSettings.cshtml +++ b/Teknik/Areas/User/Views/User/Settings/DeveloperSettings.cshtml @@ -21,8 +21,9 @@
+ +

-
    @if (Model.Clients.Any()) diff --git a/Teknik/Areas/User/Views/User/Settings/UploadSettings.cshtml b/Teknik/Areas/User/Views/User/Settings/UploadSettings.cshtml index 0e6bbad..ec21578 100644 --- a/Teknik/Areas/User/Views/User/Settings/UploadSettings.cshtml +++ b/Teknik/Areas/User/Views/User/Settings/UploadSettings.cshtml @@ -14,33 +14,29 @@
    -
    +
    +

    Encrypt in Browser

    +
    +
    - +
    -
    -
    -
    -

    Expiration

    -
    -
    -
    - -
    - -
    -
    +
    +
    +
    +

    Expiration

    +
    + +
    +
    diff --git a/Teknik/Data/Migrations/20190121042731_PasteCleanup.Designer.cs b/Teknik/Data/Migrations/20190121042731_PasteCleanup.Designer.cs new file mode 100644 index 0000000..b2d5024 --- /dev/null +++ b/Teknik/Data/Migrations/20190121042731_PasteCleanup.Designer.cs @@ -0,0 +1,747 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Teknik.Data; + +namespace Teknik.Data.Migrations +{ + [DbContext(typeof(TeknikEntities))] + [Migration("20190121042731_PasteCleanup")] + partial class PasteCleanup + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.2.0-preview3-35497") + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.Blog", b => + { + b.Property("BlogId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("UserId"); + + b.HasKey("BlogId"); + + b.HasIndex("UserId"); + + b.ToTable("Blogs"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPost", b => + { + b.Property("BlogPostId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Article"); + + b.Property("BlogId"); + + b.Property("DateEdited"); + + b.Property("DatePosted"); + + b.Property("DatePublished"); + + b.Property("Published"); + + b.Property("System"); + + b.Property("Title"); + + b.HasKey("BlogPostId"); + + b.HasIndex("BlogId"); + + b.ToTable("BlogPosts"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPostComment", b => + { + b.Property("BlogPostCommentId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Article"); + + b.Property("BlogPostId"); + + b.Property("DateEdited"); + + b.Property("DatePosted"); + + b.Property("UserId"); + + b.HasKey("BlogPostCommentId"); + + b.HasIndex("BlogPostId"); + + b.HasIndex("UserId"); + + b.ToTable("BlogPostComments"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPostTag", b => + { + b.Property("BlogPostTagId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("BlogPostId"); + + b.Property("Description"); + + b.Property("Name"); + + b.HasKey("BlogPostTagId"); + + b.HasIndex("BlogPostId"); + + b.ToTable("BlogPostTags"); + }); + + modelBuilder.Entity("Teknik.Areas.Contact.Models.Contact", b => + { + b.Property("ContactId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("DateAdded"); + + b.Property("Email"); + + b.Property("Message"); + + b.Property("Name"); + + b.Property("Subject"); + + b.HasKey("ContactId"); + + b.ToTable("Contact"); + }); + + modelBuilder.Entity("Teknik.Areas.Paste.Models.Paste", b => + { + b.Property("PasteId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("BlockSize"); + + b.Property("Content"); + + b.Property("DatePosted"); + + b.Property("DeleteKey") + .HasAnnotation("CaseSensitive", true); + + b.Property("ExpireDate"); + + b.Property("FileName") + .HasAnnotation("CaseSensitive", true); + + b.Property("HashedPassword") + .HasAnnotation("CaseSensitive", true); + + b.Property("IV") + .HasAnnotation("CaseSensitive", true); + + b.Property("Key") + .HasAnnotation("CaseSensitive", true); + + b.Property("KeySize"); + + b.Property("MaxViews"); + + b.Property("Syntax"); + + b.Property("Title"); + + b.Property("Url") + .HasAnnotation("CaseSensitive", true); + + b.Property("UserId"); + + b.Property("Views"); + + b.HasKey("PasteId"); + + b.HasIndex("UserId"); + + b.ToTable("Pastes"); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.Podcast", b => + { + b.Property("PodcastId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("DateEdited"); + + b.Property("DatePosted"); + + b.Property("DatePublished"); + + b.Property("Description"); + + b.Property("Episode"); + + b.Property("Published"); + + b.Property("Title"); + + b.HasKey("PodcastId"); + + b.ToTable("Podcasts"); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastComment", b => + { + b.Property("PodcastCommentId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Article"); + + b.Property("DateEdited"); + + b.Property("DatePosted"); + + b.Property("PodcastId"); + + b.Property("UserId"); + + b.HasKey("PodcastCommentId"); + + b.HasIndex("PodcastId"); + + b.HasIndex("UserId"); + + b.ToTable("PodcastComments"); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastFile", b => + { + b.Property("PodcastFileId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("ContentLength"); + + b.Property("ContentType"); + + b.Property("FileName"); + + b.Property("Path"); + + b.Property("PodcastId"); + + b.Property("Size"); + + b.HasKey("PodcastFileId"); + + b.HasIndex("PodcastId"); + + b.ToTable("PodcastFiles"); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastTag", b => + { + b.Property("PodcastTagId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Description"); + + b.Property("Name"); + + b.Property("PodcastId"); + + b.HasKey("PodcastTagId"); + + b.HasIndex("PodcastId"); + + b.ToTable("PodcastTags"); + }); + + modelBuilder.Entity("Teknik.Areas.Shortener.Models.ShortenedUrl", b => + { + b.Property("ShortenedUrlId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("DateAdded"); + + b.Property("OriginalUrl"); + + b.Property("ShortUrl") + .HasAnnotation("CaseSensitive", true); + + b.Property("UserId"); + + b.Property("Views"); + + b.HasKey("ShortenedUrlId"); + + b.HasIndex("UserId"); + + b.ToTable("ShortenedUrls"); + }); + + modelBuilder.Entity("Teknik.Areas.Stats.Models.Takedown", b => + { + b.Property("TakedownId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("ActionTaken"); + + b.Property("DateActionTaken"); + + b.Property("DateRequested"); + + b.Property("Reason"); + + b.Property("Requester"); + + b.Property("RequesterContact"); + + b.HasKey("TakedownId"); + + b.ToTable("Takedowns"); + }); + + modelBuilder.Entity("Teknik.Areas.Stats.Models.Transaction", b => + { + b.Property("TransactionId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Amount") + .HasColumnType("decimal(19, 5)"); + + b.Property("Currency"); + + b.Property("DateSent"); + + b.Property("Reason"); + + b.HasKey("TransactionId"); + + b.ToTable("Transactions"); + }); + + modelBuilder.Entity("Teknik.Areas.Upload.Models.Upload", b => + { + b.Property("UploadId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("BlockSize"); + + b.Property("ContentLength"); + + b.Property("ContentType"); + + b.Property("DateUploaded"); + + b.Property("DeleteKey") + .HasAnnotation("CaseSensitive", true); + + b.Property("Downloads"); + + b.Property("ExpireDate"); + + b.Property("FileName") + .HasAnnotation("CaseSensitive", true); + + b.Property("IV") + .HasAnnotation("CaseSensitive", true); + + b.Property("Key") + .HasAnnotation("CaseSensitive", true); + + b.Property("KeySize"); + + b.Property("MaxDownloads"); + + b.Property("Takedown_TakedownId"); + + b.Property("Url") + .HasAnnotation("CaseSensitive", true); + + b.Property("UserId"); + + b.HasKey("UploadId"); + + b.HasIndex("Takedown_TakedownId"); + + b.HasIndex("UserId"); + + b.ToTable("Uploads"); + }); + + modelBuilder.Entity("Teknik.Areas.Users.Models.InviteCode", b => + { + b.Property("InviteCodeId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Active"); + + b.Property("ClaimedUserId"); + + b.Property("Code") + .HasAnnotation("CaseSensitive", true); + + b.Property("OwnerId"); + + b.HasKey("InviteCodeId"); + + b.HasIndex("ClaimedUserId") + .IsUnique() + .HasFilter("[ClaimedUserId] IS NOT NULL"); + + b.HasIndex("OwnerId"); + + b.ToTable("InviteCodes"); + }); + + modelBuilder.Entity("Teknik.Areas.Users.Models.LoginInfo", b => + { + b.Property("LoginInfoId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("LoginProvider"); + + b.Property("ProviderDisplayName"); + + b.Property("ProviderKey"); + + b.Property("UserId"); + + b.HasKey("LoginInfoId"); + + b.HasIndex("UserId"); + + b.ToTable("UserLogins"); + }); + + modelBuilder.Entity("Teknik.Areas.Users.Models.User", b => + { + b.Property("UserId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Username"); + + b.HasKey("UserId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.Vault", b => + { + b.Property("VaultId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("DateCreated"); + + b.Property("DateEdited"); + + b.Property("Description"); + + b.Property("Title"); + + b.Property("Url"); + + b.Property("UserId"); + + b.Property("Views"); + + b.HasKey("VaultId"); + + b.HasIndex("UserId"); + + b.ToTable("Vaults"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.VaultItem", b => + { + b.Property("VaultItemId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("DateAdded"); + + b.Property("Description"); + + b.Property("Discriminator") + .IsRequired(); + + b.Property("Title"); + + b.Property("VaultId"); + + b.HasKey("VaultItemId"); + + b.HasIndex("VaultId"); + + b.ToTable("VaultItems"); + + b.HasDiscriminator("Discriminator").HasValue("VaultItem"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.PasteVaultItem", b => + { + b.HasBaseType("Teknik.Areas.Vault.Models.VaultItem"); + + b.Property("PasteId"); + + b.HasIndex("PasteId"); + + b.HasDiscriminator().HasValue("PasteVaultItem"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.UploadVaultItem", b => + { + b.HasBaseType("Teknik.Areas.Vault.Models.VaultItem"); + + b.Property("UploadId"); + + b.HasIndex("UploadId"); + + b.HasDiscriminator().HasValue("UploadVaultItem"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.Blog", b => + { + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPost", b => + { + b.HasOne("Teknik.Areas.Blog.Models.Blog", "Blog") + .WithMany("BlogPosts") + .HasForeignKey("BlogId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPostComment", b => + { + b.HasOne("Teknik.Areas.Blog.Models.BlogPost", "BlogPost") + .WithMany("Comments") + .HasForeignKey("BlogPostId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany() + .HasForeignKey("UserId"); + }); + + modelBuilder.Entity("Teknik.Areas.Blog.Models.BlogPostTag", b => + { + b.HasOne("Teknik.Areas.Blog.Models.BlogPost", "BlogPost") + .WithMany("Tags") + .HasForeignKey("BlogPostId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Teknik.Areas.Paste.Models.Paste", b => + { + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany("Pastes") + .HasForeignKey("UserId"); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastComment", b => + { + b.HasOne("Teknik.Areas.Podcast.Models.Podcast", "Podcast") + .WithMany("Comments") + .HasForeignKey("PodcastId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastFile", b => + { + b.HasOne("Teknik.Areas.Podcast.Models.Podcast", "Podcast") + .WithMany("Files") + .HasForeignKey("PodcastId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Teknik.Areas.Podcast.Models.PodcastTag", b => + { + b.HasOne("Teknik.Areas.Podcast.Models.Podcast", "Podcast") + .WithMany("Tags") + .HasForeignKey("PodcastId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Teknik.Areas.Shortener.Models.ShortenedUrl", b => + { + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany("ShortenedUrls") + .HasForeignKey("UserId"); + }); + + modelBuilder.Entity("Teknik.Areas.Upload.Models.Upload", b => + { + b.HasOne("Teknik.Areas.Stats.Models.Takedown") + .WithMany("Attachments") + .HasForeignKey("Takedown_TakedownId"); + + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany("Uploads") + .HasForeignKey("UserId"); + }); + + modelBuilder.Entity("Teknik.Areas.Users.Models.InviteCode", b => + { + b.HasOne("Teknik.Areas.Users.Models.User", "ClaimedUser") + .WithOne("ClaimedInviteCode") + .HasForeignKey("Teknik.Areas.Users.Models.InviteCode", "ClaimedUserId"); + + b.HasOne("Teknik.Areas.Users.Models.User", "Owner") + .WithMany("OwnedInviteCodes") + .HasForeignKey("OwnerId"); + }); + + modelBuilder.Entity("Teknik.Areas.Users.Models.LoginInfo", b => + { + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany("Logins") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Teknik.Areas.Users.Models.User", b => + { + b.OwnsOne("Teknik.Areas.Users.Models.BlogSettings", "BlogSettings", b1 => + { + b1.Property("UserId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.Property("Description") + .HasColumnName("Description"); + + b1.Property("Title") + .HasColumnName("Title"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.HasOne("Teknik.Areas.Users.Models.User") + .WithOne("BlogSettings") + .HasForeignKey("Teknik.Areas.Users.Models.BlogSettings", "UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + b.OwnsOne("Teknik.Areas.Users.Models.UploadSettings", "UploadSettings", b1 => + { + b1.Property("UserId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.Property("Encrypt") + .HasColumnName("Encrypt"); + + b1.Property("ExpirationLength") + .HasColumnName("ExpirationLength"); + + b1.Property("ExpirationUnit") + .HasColumnName("ExpirationUnit"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.HasOne("Teknik.Areas.Users.Models.User") + .WithOne("UploadSettings") + .HasForeignKey("Teknik.Areas.Users.Models.UploadSettings", "UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + b.OwnsOne("Teknik.Areas.Users.Models.UserSettings", "UserSettings", b1 => + { + b1.Property("UserId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.Property("About") + .HasColumnName("About"); + + b1.Property("Quote") + .HasColumnName("Quote"); + + b1.Property("Website") + .HasColumnName("Website"); + + b1.HasKey("UserId"); + + b1.ToTable("Users"); + + b1.HasOne("Teknik.Areas.Users.Models.User") + .WithOne("UserSettings") + .HasForeignKey("Teknik.Areas.Users.Models.UserSettings", "UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.Vault", b => + { + b.HasOne("Teknik.Areas.Users.Models.User", "User") + .WithMany("Vaults") + .HasForeignKey("UserId"); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.VaultItem", b => + { + b.HasOne("Teknik.Areas.Vault.Models.Vault", "Vault") + .WithMany("VaultItems") + .HasForeignKey("VaultId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.PasteVaultItem", b => + { + b.HasOne("Teknik.Areas.Paste.Models.Paste", "Paste") + .WithMany("PasteVaultItems") + .HasForeignKey("PasteId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Teknik.Areas.Vault.Models.UploadVaultItem", b => + { + b.HasOne("Teknik.Areas.Upload.Models.Upload", "Upload") + .WithMany("UploadVaultItems") + .HasForeignKey("UploadId") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Teknik/Data/Migrations/20190121042731_PasteCleanup.cs b/Teknik/Data/Migrations/20190121042731_PasteCleanup.cs new file mode 100644 index 0000000..a703dfd --- /dev/null +++ b/Teknik/Data/Migrations/20190121042731_PasteCleanup.cs @@ -0,0 +1,23 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Teknik.Data.Migrations +{ + public partial class PasteCleanup : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Hide", + table: "Pastes"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Hide", + table: "Pastes", + nullable: false, + defaultValue: false); + } + } +} diff --git a/Teknik/Data/Migrations/TeknikEntitiesModelSnapshot.cs b/Teknik/Data/Migrations/TeknikEntitiesModelSnapshot.cs index a7f4f16..cb28738 100644 --- a/Teknik/Data/Migrations/TeknikEntitiesModelSnapshot.cs +++ b/Teknik/Data/Migrations/TeknikEntitiesModelSnapshot.cs @@ -151,8 +151,6 @@ namespace Teknik.Data.Migrations b.Property("HashedPassword") .HasAnnotation("CaseSensitive", true); - b.Property("Hide"); - b.Property("IV") .HasAnnotation("CaseSensitive", true); diff --git a/Teknik/Scripts/Upload/Upload.js b/Teknik/Scripts/Upload/Upload.js index 7599cda..7c8c280 100644 --- a/Teknik/Scripts/Upload/Upload.js +++ b/Teknik/Scripts/Upload/Upload.js @@ -428,6 +428,8 @@ function uploadComplete(fileID, key, options, token, evt) { var contentType = obj.result.contentType; var contentLength = obj.result.contentLength; var deleteUrl = obj.result.deleteUrl; + var expirationUnit = obj.result.expirationUnit; + var expirationLength = obj.result.expirationLength; // Set progress bar setProgress(fileID, 100, 'progress-bar-success', '', 'Complete'); @@ -442,9 +444,9 @@ function uploadComplete(fileID, key, options, token, evt) { itemDiv.find('#upload-contentType').html(contentType); itemDiv.find('#upload-contentLength').html(contentLength); - var expirationMessage = options.expirationUnit; - if (options.expirationUnit !== "Never") { - expirationMessage = options.expirationLength + ' ' + options.expirationUnit; + var expirationMessage = expirationUnit; + if (expirationUnit !== "Never") { + expirationMessage = expirationLength + ' ' + expirationUnit; } itemDiv.find('#upload-expiration').html(expirationMessage); diff --git a/Teknik/Scripts/User/UploadSettings.js b/Teknik/Scripts/User/UploadSettings.js index 272bef6..8a212fa 100644 --- a/Teknik/Scripts/User/UploadSettings.js +++ b/Teknik/Scripts/User/UploadSettings.js @@ -47,12 +47,12 @@ $(document).ready(function () { function setExpireWidth(unit) { if (unit === "Never") { $('#length-div').addClass("hidden"); - $('#unit-div').removeClass("col-sm-8"); - $('#unit-div').addClass("col-sm-12"); + $('#unit-div').removeClass("col-sm-7"); + $('#unit-div').addClass("col-sm-9"); } else { $('#length-div').removeClass("hidden"); - $('#unit-div').removeClass("col-sm-12"); - $('#unit-div').addClass("col-sm-8"); + $('#unit-div').removeClass("col-sm-9"); + $('#unit-div').addClass("col-sm-7"); } } \ No newline at end of file diff --git a/Teknik/Startup.cs b/Teknik/Startup.cs index 28c5356..70c6e8c 100644 --- a/Teknik/Startup.cs +++ b/Teknik/Startup.cs @@ -210,19 +210,23 @@ namespace Teknik { options.AddPolicy("FullAPI", p => { + p.AddAuthenticationSchemes("Bearer"); p.RequireScope("teknik-api.read"); p.RequireScope("teknik-api.write"); }); - options.AddPolicy("ReadOnlyAPI", p => + options.AddPolicy("ReadAPI", p => { + p.AddAuthenticationSchemes("Bearer"); p.RequireScope("teknik-api.read"); }); - options.AddPolicy("WriteOnlyAPI", p => + options.AddPolicy("WriteAPI", p => { - p.RequireScope("teknik-api.read"); + p.AddAuthenticationSchemes("Bearer"); + p.RequireScope("teknik-api.write"); }); options.AddPolicy("AnyAPI", p => { + p.AddAuthenticationSchemes("Bearer"); p.RequireScope("teknik-api.read", "teknik-api.write"); }); });