diff --git a/SharpbinV3.Client/src/routes/+page.server.ts b/SharpbinV3.Client/src/routes/+page.server.ts
index c31463e..ef17d69 100644
--- a/SharpbinV3.Client/src/routes/+page.server.ts
+++ b/SharpbinV3.Client/src/routes/+page.server.ts
@@ -1,11 +1,11 @@
import type { PageServerLoad } from './$types';
-export const load: PageServerLoad = async ({ fetch }) => {
+export const load: PageServerLoad = async ({ fetch,url }) => {
try {
const res = await fetch('/api/paste/create/options');
const options = await res.json();
- return { options };
+ return { options, url: url.href };
} catch {
- return { options: null };
+ return { options: null, url: url.href };
}
};
diff --git a/SharpbinV3.Client/src/routes/+page.svelte b/SharpbinV3.Client/src/routes/+page.svelte
index d0dd318..c97cdb7 100644
--- a/SharpbinV3.Client/src/routes/+page.svelte
+++ b/SharpbinV3.Client/src/routes/+page.svelte
@@ -90,6 +90,15 @@
}
+
+ Create a Paste - Sharpbin
+
+
+
+
+
+
+
diff --git a/SharpbinV3.Client/src/routes/[id]/+page.server.ts b/SharpbinV3.Client/src/routes/[id]/+page.server.ts
index 5f5d9c4..3888aff 100644
--- a/SharpbinV3.Client/src/routes/[id]/+page.server.ts
+++ b/SharpbinV3.Client/src/routes/[id]/+page.server.ts
@@ -1,7 +1,7 @@
import type { PageServerLoad } from './$types';
import type { Paste } from '$lib/types/paste';
-export const load: PageServerLoad = async ({ params, fetch }) => {
+export const load: PageServerLoad = async ({ params, fetch, url }) => {
const { id } = params;
const paste = await fetch(`/api/paste/${id}`);
@@ -17,5 +17,5 @@ export const load: PageServerLoad = async ({ params, fetch }) => {
const options = await pasteOptions.json();
const content = await pasteContent.text();
- return { paste: pasteData, content, options };
+ return { paste: pasteData, content, options, url: url.href };
};
diff --git a/SharpbinV3.Client/src/routes/[id]/+page.svelte b/SharpbinV3.Client/src/routes/[id]/+page.svelte
index b1dd864..b6a11c3 100644
--- a/SharpbinV3.Client/src/routes/[id]/+page.svelte
+++ b/SharpbinV3.Client/src/routes/[id]/+page.svelte
@@ -282,6 +282,31 @@
$: if (data?.paste && (data.paste.visibility !== 2 || decryptedContent !== null)) renderCode();
+
+ {data.paste ? (data.paste.title || 'Untitled Paste') + ' - Sharpbin' : 'Paste Not Found - Sharpbin'}
+ {#if data.paste}
+
+
+
+
+
+
+ {#if data.paste.editedAt}
+
+ {/if}
+ {#if data.paste.author}
+
+ {/if}
+ {/if}
+
+
diff --git a/SharpbinV3.Client/src/routes/user/[username]/+page.server.ts b/SharpbinV3.Client/src/routes/user/[username]/+page.server.ts
index e2babd3..453095c 100644
--- a/SharpbinV3.Client/src/routes/user/[username]/+page.server.ts
+++ b/SharpbinV3.Client/src/routes/user/[username]/+page.server.ts
@@ -2,7 +2,7 @@ import type { PageServerLoad } from './$types';
import { getServerToken } from '$lib/utils/auth';
import type { User } from '$lib/types/user';
-export const load: PageServerLoad = async ({ params, fetch, cookies }) => {
+export const load: PageServerLoad = async ({ params, fetch, cookies, url }) => {
const { username } = params;
const token = getServerToken(cookies);
const res = await fetch(`/api/user/${username}`, {
@@ -12,5 +12,5 @@ export const load: PageServerLoad = async ({ params, fetch, cookies }) => {
});
const user = (await res.json()) as User;
- return { user };
+ return { user, url: url.href };
};
diff --git a/SharpbinV3.Client/src/routes/user/[username]/+page.svelte b/SharpbinV3.Client/src/routes/user/[username]/+page.svelte
index 3305b8b..5ee730a 100644
--- a/SharpbinV3.Client/src/routes/user/[username]/+page.svelte
+++ b/SharpbinV3.Client/src/routes/user/[username]/+page.svelte
@@ -113,6 +113,17 @@
}
+
+ {data.user.displayName || data.user.username} - User Profile
+
+
+
+
+
+
+
+
+
diff --git a/SharpbinV3.Client/vite.config.ts b/SharpbinV3.Client/vite.config.ts
index 855cfa6..b929f57 100644
--- a/SharpbinV3.Client/vite.config.ts
+++ b/SharpbinV3.Client/vite.config.ts
@@ -10,9 +10,11 @@ const allowedHosts = process.env.VITE_ALLOWED_HOSTS
export default defineConfig({
plugins: [tailwindcss(), sveltekit()],
server: {
+ host: true,
proxy: {
'/api': apiUrl
- }
+ },
+ allowedHosts: allowedHosts
},
preview: {
allowedHosts: allowedHosts
diff --git a/SharpbinV3.Server/Data/Entities/Paste.cs b/SharpbinV3.Server/Data/Entities/Paste.cs
index d2fec33..1232d2f 100644
--- a/SharpbinV3.Server/Data/Entities/Paste.cs
+++ b/SharpbinV3.Server/Data/Entities/Paste.cs
@@ -18,7 +18,7 @@ namespace SharpbinV3.Server.Data.Entities
public required string ID { get; set; }
public string? Title { get; set; }
- public required Guid AuthorUUID { get; set; } = Guid.Empty; // uuid of the user who created the paste, or Guid.Empty for anonymous pastes
+ public Guid? AuthorUUID { get; set; } // uuid of the user who created the paste, or null for anonymous pastes
public User? User { get; set; }
public long? EditedAt { get; set; }
diff --git a/SharpbinV3.Server/Migrations/20260106211303_NullableAuthorUUID.Designer.cs b/SharpbinV3.Server/Migrations/20260106211303_NullableAuthorUUID.Designer.cs
new file mode 100644
index 0000000..c798772
--- /dev/null
+++ b/SharpbinV3.Server/Migrations/20260106211303_NullableAuthorUUID.Designer.cs
@@ -0,0 +1,191 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using SharpbinV3.Server.Data;
+
+#nullable disable
+
+namespace SharpbinV3.Server.Migrations
+{
+ [DbContext(typeof(AppDbContext))]
+ [Migration("20260106211303_NullableAuthorUUID")]
+ partial class NullableAuthorUUID
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "10.0.0");
+
+ modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Paste", b =>
+ {
+ b.Property("PID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AuthorUUID")
+ .HasColumnType("TEXT");
+
+ b.Property("Content")
+ .IsRequired()
+ .HasColumnType("BLOB");
+
+ b.Property("EditedAt")
+ .HasColumnType("INTEGER");
+
+ b.Property("ExpiresAt")
+ .HasColumnType("INTEGER");
+
+ b.Property("ID")
+ .HasColumnType("TEXT");
+
+ b.Property("IsCompressed")
+ .HasColumnType("INTEGER");
+
+ b.Property("Size")
+ .HasColumnType("INTEGER");
+
+ b.Property("Syntax")
+ .HasColumnType("TEXT");
+
+ b.Property("Title")
+ .HasColumnType("TEXT");
+
+ b.Property("TrueSize")
+ .HasColumnType("INTEGER");
+
+ b.Property("UUID")
+ .HasColumnType("TEXT");
+
+ b.Property("Views")
+ .HasColumnType("INTEGER");
+
+ b.Property("Visibility")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("PID");
+
+ b.HasIndex("AuthorUUID");
+
+ b.HasIndex("ExpiresAt");
+
+ b.HasIndex("ID")
+ .IsUnique();
+
+ b.HasIndex("PID")
+ .IsUnique();
+
+ b.HasIndex("UUID")
+ .IsUnique();
+
+ b.HasIndex("Views");
+
+ b.HasIndex("Visibility");
+
+ b.ToTable("Pastes");
+ });
+
+ modelBuilder.Entity("SharpbinV3.Server.Data.Entities.RefreshToken", b =>
+ {
+ b.Property("UserUUID")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedAt")
+ .HasColumnType("INTEGER");
+
+ b.Property("ExpiresAt")
+ .HasColumnType("INTEGER");
+
+ b.Property("JwtId")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Token")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Used")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("UserUUID");
+
+ b.ToTable("RefreshTokens");
+ });
+
+ modelBuilder.Entity("SharpbinV3.Server.Data.Entities.User", b =>
+ {
+ b.Property("UUID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("DisplayName")
+ .HasColumnType("TEXT");
+
+ b.Property("Email")
+ .HasColumnType("TEXT");
+
+ b.Property("LastLogin")
+ .HasColumnType("INTEGER");
+
+ b.Property("PasswordHash")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.PrimitiveCollection("Roles")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("UID")
+ .HasColumnType("INTEGER");
+
+ b.Property("Username")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Visibility")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("UUID");
+
+ b.HasIndex("UID");
+
+ b.HasIndex("UUID")
+ .IsUnique();
+
+ b.ToTable("Users");
+ });
+
+ modelBuilder.Entity("SharpbinV3.Server.Data.Entities.Paste", b =>
+ {
+ b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
+ .WithMany("Pastes")
+ .HasForeignKey("AuthorUUID")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("SharpbinV3.Server.Data.Entities.RefreshToken", b =>
+ {
+ b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
+ .WithMany("RefreshTokens")
+ .HasForeignKey("UserUUID")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("SharpbinV3.Server.Data.Entities.User", b =>
+ {
+ b.Navigation("Pastes");
+
+ b.Navigation("RefreshTokens");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/SharpbinV3.Server/Migrations/20260106211303_NullableAuthorUUID.cs b/SharpbinV3.Server/Migrations/20260106211303_NullableAuthorUUID.cs
new file mode 100644
index 0000000..289fdb0
--- /dev/null
+++ b/SharpbinV3.Server/Migrations/20260106211303_NullableAuthorUUID.cs
@@ -0,0 +1,37 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace SharpbinV3.Server.Migrations
+{
+ ///
+ public partial class NullableAuthorUUID : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AlterColumn(
+ name: "AuthorUUID",
+ table: "Pastes",
+ type: "TEXT",
+ nullable: true,
+ oldClrType: typeof(Guid),
+ oldType: "TEXT");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AlterColumn(
+ name: "AuthorUUID",
+ table: "Pastes",
+ type: "TEXT",
+ nullable: false,
+ defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
+ oldClrType: typeof(Guid),
+ oldType: "TEXT",
+ oldNullable: true);
+ }
+ }
+}
diff --git a/SharpbinV3.Server/Migrations/AppDbContextModelSnapshot.cs b/SharpbinV3.Server/Migrations/AppDbContextModelSnapshot.cs
index 040d9fa..40ccad3 100644
--- a/SharpbinV3.Server/Migrations/AppDbContextModelSnapshot.cs
+++ b/SharpbinV3.Server/Migrations/AppDbContextModelSnapshot.cs
@@ -23,7 +23,7 @@ namespace SharpbinV3.Server.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
- b.Property("AuthorUUID")
+ b.Property("AuthorUUID")
.HasColumnType("TEXT");
b.Property("Content")
@@ -160,8 +160,7 @@ namespace SharpbinV3.Server.Migrations
b.HasOne("SharpbinV3.Server.Data.Entities.User", "User")
.WithMany("Pastes")
.HasForeignKey("AuthorUUID")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
+ .OnDelete(DeleteBehavior.Cascade);
b.Navigation("User");
});
diff --git a/SharpbinV3.Server/Services/AuthService.cs b/SharpbinV3.Server/Services/AuthService.cs
index 1c33b56..2926082 100644
--- a/SharpbinV3.Server/Services/AuthService.cs
+++ b/SharpbinV3.Server/Services/AuthService.cs
@@ -30,7 +30,7 @@ namespace SharpbinV3.Server.Services
};
if (_authSettings.First_User_Admin && !await _db.Users.AnyAsync())
- user.Roles = [255];
+ user.Roles = [0,1,255];
_db.Users.Add(user);
await _db.SaveChangesAsync();
diff --git a/SharpbinV3.Server/Services/PasteService.cs b/SharpbinV3.Server/Services/PasteService.cs
index 06ebbf2..2c5bdb5 100644
--- a/SharpbinV3.Server/Services/PasteService.cs
+++ b/SharpbinV3.Server/Services/PasteService.cs
@@ -21,7 +21,7 @@ namespace SharpbinV3.Server.Services
UUID = Guid.CreateVersion7(),
ID = Utilities.GenerateRandomString(8),
Title = title,
- AuthorUUID = author?.UUID ?? Guid.Empty,
+ AuthorUUID = author?.UUID,
User = author,
Content = compressedData,
Size = compressedData.Length,