diff --git a/SharpbinV2.Server/Program.cs b/SharpbinV2.Server/Program.cs index fddbd22..1825454 100644 --- a/SharpbinV2.Server/Program.cs +++ b/SharpbinV2.Server/Program.cs @@ -45,6 +45,7 @@ namespace SharpbinV2.Server "xml" }; public static string HMACSecret = "thisneedstobechanged"; + public static JObject Configuration { get; set; } static async Task Main(string[] args) { @@ -52,7 +53,14 @@ namespace SharpbinV2.Server var logger = new Logging(); var builder = WebApplication.CreateBuilder(args); builder.Configuration.AddEnvironmentVariables(); - builder.WebHost.UseUrls($"https://*:{Environment.GetEnvironmentVariable("HTTPS_Port") ?? "5820"}", $"http://*:{Environment.GetEnvironmentVariable("HTTP_Port") ?? "5810"}"); + if (Environment.GetEnvironmentVariable("HTTPS") == "true") + { + builder.WebHost.UseUrls($"https://*:{Environment.GetEnvironmentVariable("HTTPS_Port") ?? "5820"}"); + } + else + { + builder.WebHost.UseUrls($"http://*:{Environment.GetEnvironmentVariable("HTTP_Port") ?? "5810"}"); + } MaxFileSize = Environment.GetEnvironmentVariable("MAX_FILE_SIZE") != null ? Convert.ToInt64(Environment.GetEnvironmentVariable("MAX_FILE_SIZE")) : MaxFileSize; HMACSecret = Environment.GetEnvironmentVariable("HMAC_SECRET") ?? HMACSecret; if (HMACSecret == "thisneedstobechanged") @@ -229,6 +237,29 @@ namespace SharpbinV2.Server context.Response.Headers.Add("Content-Type", "text/html"); await context.Response.SendFileAsync("wwwroot/archive.html"); }); + app.MapGet("/dash", async (HttpContext context) => + { + context.Response.StatusCode = 200; + context.Response.Headers.Add("Content-Type", "text/html"); + await context.Response.SendFileAsync("wwwroot/dash.html"); + }); + app.MapGet("/dash.html", (HttpContext context) => + { + context.Response.Redirect("/dash"); + }); + app.MapGet("/login", async (HttpContext context) => + { + context.Response.StatusCode = 200; + context.Response.Headers.Add("Content-Type", "text/html"); + await context.Response.SendFileAsync("wwwroot/login.html"); + }); + app.MapGet("/register", async (HttpContext context) => + { + context.Response.StatusCode = 200; + context.Response.Headers.Add("Content-Type", "text/html"); + await context.Response.SendFileAsync("wwwroot/register.html"); + }); + #endregion #region API @@ -324,15 +355,17 @@ namespace SharpbinV2.Server logger.LogInfo($"Account {username} has been created."); return; }); - app.MapGet("/api/accounts/login", async (HttpContext context) => + app.MapPost("/api/accounts/login", async (HttpContext context) => { var requestdetails = GetRequestDetails(context); - if (!string.IsNullOrEmpty(requestdetails.Token) && Database.UserFromToken(requestdetails.Token) != null) + var __user = await Database.UserFromToken(requestdetails.Token); + if (!string.IsNullOrEmpty(requestdetails.Token) && __user != null) { - context.Response.StatusCode = 200; - await context.Response.WriteAsJsonAsync(new { success = true, message = "Already logged in." }); + context.Response.StatusCode = 400; + await context.Response.WriteAsJsonAsync(new { success = false, message = "Already logged in." }); return; } + var body = await new StreamReader(context.Request.Body).ReadToEndAsync(); if (body == null) { @@ -425,14 +458,14 @@ namespace SharpbinV2.Server if (string.IsNullOrEmpty(requestdetails.Token)) { context.Response.StatusCode = 400; - await context.Response.WriteAsJsonAsync(new { success = false, message = "Not authorized." }); + await context.Response.WriteAsJsonAsync(new { success = false, message = "No token provided, not authorized." }); return; } var user = await Database.UserFromToken(requestdetails.Token); if (user == null) { context.Response.StatusCode = 400; - await context.Response.WriteAsJsonAsync(new { success = false, message = "Not authorized." }); + await context.Response.WriteAsJsonAsync(new { success = false, message = "Invalid token." }); return; } var cleanuser = new User @@ -440,6 +473,7 @@ namespace SharpbinV2.Server UID = user.UID, UUID = user.UUID, Username = user.Username, + Email = user.Email, DisplayName = user.DisplayName, Created = user.Created, LastLogin = user.LastLogin @@ -448,6 +482,74 @@ namespace SharpbinV2.Server await context.Response.WriteAsJsonAsync(new { success = true, user = cleanuser }); return; }); + app.MapPost("/api/accounts/delete", async (HttpContext context) => + { + var requestdetails = GetRequestDetails(context); + if (string.IsNullOrEmpty(requestdetails.Token)) + { + context.Response.StatusCode = 400; + await context.Response.WriteAsJsonAsync(new { success = false, message = "No token provided, not authorized." }); + return; + } + var user = await Database.UserFromToken(requestdetails.Token); + if (user == null) + { + context.Response.StatusCode = 400; + await context.Response.WriteAsJsonAsync(new { success = false, message = "Invalid token." }); + return; + } + using (var connection = new SqliteConnection(MainDatabaseConnection)) + { + await connection.OpenAsync(); + using (var command = connection.CreateCommand()) + { + command.CommandText = "DELETE FROM users WHERE UUID = @UUID;"; + command.Parameters.AddWithValue("@UUID", user.UUID); + await command.ExecuteNonQueryAsync(); + } + await connection.CloseAsync(); + } + + using (var connection = new SqliteConnection(MainDatabaseConnection)) + { + await connection.OpenAsync(); + using (var command = connection.CreateCommand()) + { + command.CommandText = "DELETE FROM pastes WHERE AuthorUUID = @AuthorUUID;"; + command.Parameters.AddWithValue("@AuthorUUID", user.UUID); + await command.ExecuteNonQueryAsync(); + } + await connection.CloseAsync(); + } + + using (var connection = new SqliteConnection(MainDatabaseConnection)) + { + await connection.OpenAsync(); + using (var command = connection.CreateCommand()) + { + command.CommandText = "DELETE FROM sessions WHERE UserUUID = @UserUUID;"; + command.Parameters.AddWithValue("@UserUUID", user.UUID); + await command.ExecuteNonQueryAsync(); + } + await connection.CloseAsync(); + } + + using (var connection = new SqliteConnection(MainDatabaseConnection)) + { + await connection.OpenAsync(); + using (var command = connection.CreateCommand()) + { + command.CommandText = "UPDATE views SET UserUUID = @UserUUID WHERE UserUUID = @OldUserUUID;"; + command.Parameters.AddWithValue("@UserUUID", "0"); + command.Parameters.AddWithValue("@OldUserUUID", user.UUID); + await command.ExecuteNonQueryAsync(); + } + await connection.CloseAsync(); + } + context.Response.StatusCode = 200; + await context.Response.WriteAsJsonAsync(new { success = true, message = "Account deleted." }); + + }); app.MapPost("/api/pastes/create", async (HttpContext context) => { @@ -537,59 +639,7 @@ namespace SharpbinV2.Server paste.FilePath = null; context.Response.StatusCode = 200; await context.Response.WriteAsJsonAsync(new { success = true, message = "Paste created.", paste = paste }); - logger.LogInfo($"A Paste of {FormatBytes(paste.Size)} was created by {paste.UUID}"); - return; - }); - app.MapGet("/api/pastes/{pasteid}/info", async (HttpContext context) => - { - var pasteid = context.Request.RouteValues["pasteid"].ToString() ?? null; - if (string.IsNullOrEmpty(pasteid)) - { - context.Response.StatusCode = 400; - await context.Response.WriteAsJsonAsync(new { success = false, message = "Invalid Paste ID." }); - return; - } - var paste = await Database.GetPasteFromID(pasteid); - if (paste == null) - { - context.Response.StatusCode = 400; - await context.Response.WriteAsJsonAsync(new { success = false, message = "Paste not found." }); - return; - } - if (paste.AuthorUUID != "0") - { - var user = await Database.UserFromUUID(paste.AuthorUUID); - paste.AuthorUUID = user.Username; - } - else - { - paste.AuthorUUID = "Anonymous"; - } - paste.FilePath = null; - context.Response.StatusCode = 200; - await context.Response.WriteAsJsonAsync(new { success = true, paste = paste }); - }); - app.MapGet("/api/pastes/{pasteid}", async (HttpContext context) => - { - var pasteid = context.Request.RouteValues["pasteid"].ToString() ?? null; - if (string.IsNullOrEmpty(pasteid)) - { - context.Response.StatusCode = 400; - await context.Response.WriteAsJsonAsync(new { success = false, message = "Invalid Paste ID." }); - return; - } - var paste = await Database.GetPasteFromID(pasteid); - context.Response.StatusCode = 200; - context.Response.Headers.Add("Content-Type", "text/plain"); - if (paste.FilePath.EndsWith(".gz")) - { - context.Response.Headers.Add("Content-Encoding", "gzip"); - await context.Response.SendFileAsync(paste.FilePath); - } - else - { - await context.Response.SendFileAsync(paste.FilePath); - } + logger.LogInfo($"A Paste of {FormatBytes(paste.Size ?? 0)} was created by {paste.UUID}"); return; }); app.MapGet("/api/pastes/archive", async (HttpContext context) => @@ -660,6 +710,142 @@ namespace SharpbinV2.Server } } }); + app.MapGet("/api/pastes/my", async (HttpContext context) => + { + var requestdetails = GetRequestDetails(context); + if (string.IsNullOrEmpty(requestdetails.Token)) + { + context.Response.StatusCode = 400; + await context.Response.WriteAsJsonAsync(new { success = false, message = "Not authorized." }); + return; + } + + var user = await Database.UserFromToken(requestdetails.Token); + if (user == null) + { + context.Response.StatusCode = 400; + await context.Response.WriteAsJsonAsync(new { success = false, message = "Invalid token." }); + return; + } + var queries = context.Request.Query; + if (!queries.ContainsKey("page") && !queries.ContainsKey("limit")) + { + context.Response.StatusCode = 400; + await context.Response.WriteAsJsonAsync(new { success = false, message = "Missing required fields." }); + return; + } + var page = queries.ContainsKey("page") ? Convert.ToInt32(queries["page"]) : 0; + var limit = queries.ContainsKey("limit") ? Convert.ToInt32(queries["limit"]) : 10; + if (page < 0 || limit <= 0 || limit > 25) + { + context.Response.StatusCode = 400; + await context.Response.WriteAsJsonAsync(new { success = false, message = "Invalid page or limit." }); + return; + } + int pages = await Database.EnumerateUserPastes(user) / limit; + if (page > pages) + { + context.Response.StatusCode = 400; + await context.Response.WriteAsJsonAsync(new { success = false, message = "Page out of range.", pages }); + return; + } + using (var connection = new SqliteConnection(MainDatabaseConnection)) + { + await connection.OpenAsync(); + using (var command = connection.CreateCommand()) + { + command.CommandText = "SELECT * FROM pastes WHERE AuthorUUID = @AuthorUUID ORDER BY Created DESC LIMIT @Limit OFFSET @Offset;"; + command.Parameters.AddWithValue("@AuthorUUID", user.UUID); + command.Parameters.AddWithValue("@Limit", limit); + command.Parameters.AddWithValue("@Offset", page * limit); + using (var reader = await command.ExecuteReaderAsync()) + { + if (!reader.HasRows) + { + context.Response.StatusCode = 400; + await context.Response.WriteAsJsonAsync(new { success = false, error = true, message = "No pastes found." }); + return; + } + var pastes = new List(); + while (await reader.ReadAsync()) + { + pastes.Add(new Paste + { + UUID = reader.GetString(1), + ID = reader.GetString(2), + Visibility = reader.GetInt32(3), + Title = reader.IsDBNull(4) ? null : reader.GetString(4), + AuthorUUID = reader.GetString(5), + Created = reader.GetInt64(7), + Edited = reader.GetInt64(8), + Size = reader.GetInt32(9), + TrueSize = reader.GetInt32(10), + Views = reader.GetInt32(11), + Syntax = reader.IsDBNull(12) ? null : reader.GetString(12) + }); + } + + context.Response.StatusCode = 200; + await context.Response.WriteAsJsonAsync(new { success = true, pastes, pages }); + return; + } + } + } + + }); + app.MapGet("/api/pastes/{pasteid}/info", async (HttpContext context) => + { + var pasteid = context.Request.RouteValues["pasteid"].ToString() ?? null; + if (string.IsNullOrEmpty(pasteid)) + { + context.Response.StatusCode = 400; + await context.Response.WriteAsJsonAsync(new { success = false, message = "Invalid Paste ID." }); + return; + } + var paste = await Database.GetPasteFromID(pasteid); + if (paste == null) + { + context.Response.StatusCode = 400; + await context.Response.WriteAsJsonAsync(new { success = false, message = "Paste not found." }); + return; + } + if (paste.AuthorUUID != "0") + { + var user = await Database.UserFromUUID(paste.AuthorUUID); + paste.AuthorUUID = user.Username; + } + else + { + paste.AuthorUUID = "Anonymous"; + } + paste.FilePath = null; + context.Response.StatusCode = 200; + await context.Response.WriteAsJsonAsync(new { success = true, paste = paste }); + }); + app.MapGet("/api/pastes/{pasteid}", async (HttpContext context) => + { + var pasteid = context.Request.RouteValues["pasteid"].ToString() ?? null; + if (string.IsNullOrEmpty(pasteid)) + { + context.Response.StatusCode = 400; + await context.Response.WriteAsJsonAsync(new { success = false, message = "Invalid Paste ID." }); + return; + } + var paste = await Database.GetPasteFromID(pasteid); + context.Response.StatusCode = 200; + context.Response.Headers.Add("Content-Type", "text/plain"); + if (paste.FilePath.EndsWith(".gz")) + { + context.Response.Headers.Add("Content-Encoding", "gzip"); + await context.Response.SendFileAsync(paste.FilePath); + } + else + { + await context.Response.SendFileAsync(paste.FilePath); + } + return; + }); + #endregion @@ -933,7 +1119,6 @@ namespace SharpbinV2.Server return null; using (var connection = new SqliteConnection(Program.MainDatabaseConnection)) { - await connection.OpenAsync(); using (var command = connection.CreateCommand()) { @@ -944,7 +1129,7 @@ namespace SharpbinV2.Server if (!reader.HasRows) return null; await reader.ReadAsync(); - return await UserFromUUID(reader.GetString(2)); + return await UserFromUUID(reader.GetString(1)); } } } @@ -961,6 +1146,21 @@ namespace SharpbinV2.Server } } } + public static async Task EnumerateUserPastes(User user) + { + if (user == null) + return 0; + using (var connection = new SqliteConnection(Program.MainDatabaseConnection)) + { + await connection.OpenAsync(); + using (var command = connection.CreateCommand()) + { + command.CommandText = "SELECT COUNT(*) FROM pastes WHERE AuthorUUID = @AuthorUUID;"; + command.Parameters.AddWithValue("@AuthorUUID", user.UUID); + return Convert.ToInt32(await command.ExecuteScalarAsync()); + } + } + } public static async Task GetPasteFromID(string id) { if (string.IsNullOrEmpty(id)) @@ -1053,6 +1253,45 @@ namespace SharpbinV2.Server await connection.CloseAsync(); } } + public static async Task > PastesFromUser(User user) + { + if (user == null) + return null; + using (var connection = new SqliteConnection(Program.MainDatabaseConnection)) + { + await connection.OpenAsync(); + using (var command = connection.CreateCommand()) + { + command.CommandText = "SELECT * FROM pastes WHERE AuthorUUID = @AuthorUUID;"; + command.Parameters.AddWithValue("@AuthorUUID", user.UUID); + using (var reader = await command.ExecuteReaderAsync()) + { + if (!reader.HasRows) + return null; + var pastes = new List(); + while (await reader.ReadAsync()) + { + pastes.Add(new Paste + { + UUID = reader.GetString(1), + ID = reader.GetString(2), + Visibility = reader.GetInt32(3), + Title = reader.IsDBNull(4) ? null : reader.GetString(4), + AuthorUUID = reader.GetString(5), + FilePath = reader.GetString(6), + Created = reader.GetInt64(7), + Edited = reader.GetInt64(8), + Size = reader.GetInt32(9), + TrueSize = reader.GetInt32(10), + Views = reader.GetInt32(11), + Syntax = reader.IsDBNull(12) ? null : reader.GetString(12) + }); + } + return pastes; + } + } + } + } } public class Logging { @@ -1122,7 +1361,6 @@ namespace SharpbinV2.Server } return compressedBytes; } - public static async Task DecompressByteArrayToString(byte[] compressedBytes) { string decompressedText; @@ -1138,7 +1376,6 @@ namespace SharpbinV2.Server } return decompressedText; } - public static async Task DecompressByteArray(byte[] compressedBytes) { byte[] decompressedBytes; @@ -1169,7 +1406,6 @@ namespace SharpbinV2.Server return compressionRatio < ratioThreshold; } - public static bool IsCompressed(byte[] data) { return data.Length >= 2 && data[0] == 0x1F && data[1] == 0x8B; @@ -1177,45 +1413,45 @@ namespace SharpbinV2.Server } class User { - public int UID { get; set; } - public string UUID { get; set; } - public int Type { get; set; } - public string Email { get; set; } - public string Username { get; set; } - public string DisplayName { get; set; } - public string Password { get; set; } - public long Created { get; set; } - public long LastLogin { get; set; } + public int? UID { get; set; } + public string? UUID { get; set; } + public int? Type { get; set; } + public string? Email { get; set; } + public string? Username { get; set; } + public string? DisplayName { get; set; } + public string? Password { get; set; } + public long? Created { get; set; } + public long? LastLogin { get; set; } } class Paste { - public string UUID { get; set; } - public string ID { get; set; } - public int Visibility { get; set; } - public string Title { get; set; } - public string AuthorUUID { get; set; } - public string FilePath { get; set; } - public long Created { get; set; } - public long Edited { get; set; } - public int Size { get; set; } - public int TrueSize { get; set; } - public int Views { get; set; } - public string Syntax { get; set; } + public string? UUID { get; set; } + public string? ID { get; set; } + public int? Visibility { get; set; } + public string? Title { get; set; } + public string? AuthorUUID { get; set; } + public string? FilePath { get; set; } + public long? Created { get; set; } + public long? Edited { get; set; } + public int? Size { get; set; } + public int? TrueSize { get; set; } + public int? Views { get; set; } + public string? Syntax { get; set; } } class Session { - public string UUID { get; set; } - public string UserUUID { get; set; } - public string Token { get; set; } - public long Created { get; set; } - public long Expirary { get; set; } - public string Ip { get; set; } - public string UserAgent { get; set; } + public string? UUID { get; set; } + public string? UserUUID { get; set; } + public string? Token { get; set; } + public long? Created { get; set; } + public long? Expirary { get; set; } + public string? Ip { get; set; } + public string? UserAgent { get; set; } } class RequestDetails { - public string Ip { get; set; } - public string UserAgent { get; set; } - public string Token { get; set; } + public string? Ip { get; set; } + public string? UserAgent { get; set; } + public string? Token { get; set; } } } \ No newline at end of file diff --git a/SharpbinV2.Server/SharpbinV2.Server.sln b/SharpbinV2.Server/SharpbinV2.Server.sln new file mode 100644 index 0000000..df4a5eb --- /dev/null +++ b/SharpbinV2.Server/SharpbinV2.Server.sln @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.2.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpbinV2.Server", "SharpbinV2.Server.csproj", "{68738FF4-A603-C797-2A44-D510EF342839}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {68738FF4-A603-C797-2A44-D510EF342839}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {68738FF4-A603-C797-2A44-D510EF342839}.Debug|Any CPU.Build.0 = Debug|Any CPU + {68738FF4-A603-C797-2A44-D510EF342839}.Release|Any CPU.ActiveCfg = Release|Any CPU + {68738FF4-A603-C797-2A44-D510EF342839}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4E1CB94E-6A3B-4EDF-95C2-479B8817C596} + EndGlobalSection +EndGlobal diff --git a/SharpbinV2.Server/wwwroot/archive.html b/SharpbinV2.Server/wwwroot/archive.html index ca8824a..fc1e4ec 100644 --- a/SharpbinV2.Server/wwwroot/archive.html +++ b/SharpbinV2.Server/wwwroot/archive.html @@ -24,21 +24,15 @@

Syntax

    -
- +

0/0

- +
+ + + - - \ No newline at end of file diff --git a/SharpbinV2.Server/wwwroot/css/archive.css b/SharpbinV2.Server/wwwroot/css/archive.css index d1961ca..828ffed 100644 --- a/SharpbinV2.Server/wwwroot/css/archive.css +++ b/SharpbinV2.Server/wwwroot/css/archive.css @@ -1,62 +1,205 @@ +.main-container { + max-width: 80%; + margin: 2rem auto; + padding: 1.5rem; + background-color: var(--neutral-900); + border-radius: 8px; + box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3); +} + +#archive-header { + font-size: 2rem; + font-weight: 700; + margin-bottom: 1.5rem; + color: var(--neutral-50); + text-align: center; + letter-spacing: 0.5px; +} + +.archive-information { + display: grid; + grid-template-columns: 2fr 1fr 1fr; + gap: 1rem; + padding: 0.75rem 1rem; + margin-bottom: 1rem; + background-color: var(--neutral-800); + border-radius: 6px; + font-weight: 600; + color: var(--neutral-200); + border-bottom: 2px solid var(--neutral-700); + width: 100%; +} + +.archive-information p { + margin: 0; +} + .archive-list { list-style-type: none; margin: 0; padding: 0; width: 100%; - max-height: 100%; - overflow-y: scroll; + max-height: 70vh; + overflow-y: auto; + border-radius: 6px; + scrollbar-width: thin; + scrollbar-color: var(--neutral-700) var(--neutral-900); } + +.archive-list::-webkit-scrollbar { + width: 8px; +} + +.archive-list::-webkit-scrollbar-track { + background: var(--neutral-900); + border-radius: 6px; +} + +.archive-list::-webkit-scrollbar-thumb { + background-color: var(--neutral-700); + border-radius: 6px; +} + .archive-list li { - margin: 5px 0 5px 0; - padding: 0; - width: 100%; + margin: 0.75rem 0; + transition: transform 0.2s ease; } + +.archive-list li:hover { + transform: translateY(-2px); +} + .archive-list li a { - display: block; - padding: 1rem; + display: grid; + grid-template-columns: 2fr 1fr 1fr; + gap: 1rem; + padding: 1rem 1.25rem; background-color: var(--neutral-800); color: var(--neutral-50); text-decoration: none; - transition: background-color 0.3s; - border-radius: 5px; + transition: all 0.3s ease; + border-radius: 6px; border: 1px solid var(--neutral-700); - width: 100%; - display: flex; - justify-content: space-between; -} -#archive-title { - min-width: 50%; - max-width: 50%; -} -.archive-information { - padding: 0 2px 0 2px; - width: 100%; - display: flex; - justify-content: space-between; -} -.main-container { - max-height: 80% !important; -} -.paste-actions { - width: 100%; - margin-top: 5px; - display: flex; - justify-content: space-between; - align-items: center; + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); } -button { - padding: 10px 40px 10px 40px; - margin: 5px 0; - border-radius: 5px; - border: 1px solid var(--neutral-800); +.archive-list li a:hover { + background-color: var(--neutral-750); + border-color: var(--neutral-600); + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); +} + +.archive-list li a p { + margin: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +#archive-title { + font-weight: 500; + color: var(--neutral-100); +} + +#archive-date { + color: var(--neutral-300); + font-size: 0.9rem; + text-align: center; +} + +#archive-syntax { + color: var(--neutral-300); + font-size: 0.9rem; + text-align: right; +} + +.paste-actions { + width: 100%; + margin-top: 1.5rem; + display: flex; + justify-content: center; + align-items: center; + gap: 1.5rem; +} + +.paste-actions button { + padding: 0.6rem 1.2rem; + border-radius: 6px; + border: 1px solid var(--neutral-700); background-color: var(--neutral-800); color: var(--neutral-50); cursor: pointer; - transition: background-color 0.3s; + transition: all 0.2s ease; font-size: 1rem; + min-width: 100px; + display: flex; + align-items: center; + justify-content: center; } -button:hover { +.paste-actions button:hover:not(:disabled) { background-color: var(--neutral-700); + transform: translateY(-2px); + box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2); +} + +.paste-actions button:disabled { + opacity: 0.5; + cursor: not-allowed; +} + +#paste-pages { + font-weight: 500; + color: var(--neutral-300); + font-size: 1.1rem; + margin: 0; + padding: 0.5rem 1rem; + background-color: var(--neutral-800); + border-radius: 6px; + min-width: 80px; + text-align: center; +} + +@media (max-width: 768px) { + .archive-information, + .archive-list li a { + grid-template-columns: 3fr 2fr; + } + + #archive-syntax { + display: none; + } + + .archive-information p:last-child { + display: none; + } + + .paste-actions button { + padding: 0.5rem 1rem; + min-width: 80px; + } +} + +@media (max-width: 480px) { + .main-container { + padding: 1rem; + margin: 1rem; + } + + #archive-header { + font-size: 1.5rem; + } + + .archive-list { + max-height: 60vh; + } + + .paste-actions { + gap: 0.75rem; + } + + #paste-pages { + min-width: 60px; + font-size: 0.9rem; + } } \ No newline at end of file diff --git a/SharpbinV2.Server/wwwroot/css/auth.css b/SharpbinV2.Server/wwwroot/css/auth.css new file mode 100644 index 0000000..b3b6920 --- /dev/null +++ b/SharpbinV2.Server/wwwroot/css/auth.css @@ -0,0 +1,149 @@ +.auth-container { + display: flex; + justify-content: center; + align-items: center; + min-height: 100vh; + padding: 20px; + background-color: var(--neutral-950); +} + +.auth-form-container { + background-color: var(--neutral-900); + border-radius: 8px; + padding: 30px; + box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); + width: 100%; + max-width: 450px; + border: 1px solid var(--neutral-800); +} + +.auth-title { + text-align: center; + font-size: 1.8rem; + font-weight: 600; + margin-bottom: 24px; + color: var(--neutral-100); +} + +.auth-form { + display: flex; + flex-direction: column; + gap: 20px; +} + +.form-group { + display: flex; + flex-direction: column; + gap: 6px; +} + +.form-group label { + font-size: 0.9rem; + font-weight: 500; + color: var(--neutral-300); +} + +.form-group input { + padding: 12px 16px; + border-radius: 6px; + border: 1px solid var(--neutral-700); + background-color: var(--neutral-800); + color: var(--neutral-100); + font-size: 1rem; + transition: all 0.2s ease; +} + +.form-group input:focus { + outline: none; + border-color: var(--neutral-500); + box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1); +} + +.auth-button { + margin-top: 10px; + padding: 12px; + border-radius: 6px; + border: none; + background-color: var(--neutral-700); + color: var(--neutral-50); + font-size: 1rem; + font-weight: 500; + cursor: pointer; + transition: all 0.2s ease; +} + +.auth-button:hover { + background-color: var(--neutral-600); + transform: translateY(-2px); + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); +} + +.auth-links { + margin-top: 24px; + text-align: center; + display: flex; + flex-direction: column; + gap: 10px; +} + +.auth-links p { + color: var(--neutral-400); + margin: 0; +} + +.auth-links a { + color: var(--neutral-300); + text-decoration: none; + font-weight: 500; + transition: color 0.2s ease; +} + +.auth-links a:hover { + color: var(--neutral-100); + text-decoration: underline; +} + +.error-message { + background-color: rgba(220, 38, 38, 0.1); + color: #ef4444; + padding: 10px 16px; + border-radius: 6px; + margin-bottom: 16px; + font-size: 0.9rem; + display: none; + border: 1px solid rgba(220, 38, 38, 0.2); +} + +.error-message.visible { + display: block; + animation: fadeIn 0.3s ease; +} + +@keyframes fadeIn { + from { + opacity: 0; + transform: translateY(-10px); + } + to { + opacity: 1; + transform: translateY(0); + } +} + +@media (max-width: 480px) { + .auth-form-container { + padding: 20px; + } + + .auth-title { + font-size: 1.6rem; + } + + .form-group input { + padding: 10px 12px; + } + + .auth-button { + padding: 10px; + } +} diff --git a/SharpbinV2.Server/wwwroot/css/dash.css b/SharpbinV2.Server/wwwroot/css/dash.css new file mode 100644 index 0000000..37c224a --- /dev/null +++ b/SharpbinV2.Server/wwwroot/css/dash.css @@ -0,0 +1,455 @@ +body { + background-color: var(--neutral-950); + color: var(--neutral-100); +} + +.main-container { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: stretch; + margin-top: 2rem; + min-height: 400px; + padding: 20px; + gap: 25px; +} + +.account-info, .paste-list { + width: 48%; + border-radius: 8px; + padding: 25px; + box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); + background-color: var(--neutral-900); + border: 1px solid var(--neutral-700); + transition: all 0.3s ease; +} + +.paste-list { + display: flex; + flex-direction: column; +} + +.account-info { + display: flex; + flex-direction: column; +} + +.account-info:hover, .paste-list:hover { + box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); + border-color: var(--neutral-700); +} + +.account-info h1, .paste-list h1 { + margin-bottom: 25px; + color: var(--neutral-100); + text-align: center; + font-size: 1.8rem; + border-bottom: 2px solid var(--neutral-700); + padding-bottom: 10px; +} + +.account-info p { + margin: 12px 0; + padding: 8px; + border-bottom: 1px solid var(--neutral-800); + font-size: 1.05rem; + display: flex; + justify-content: space-between; + color: var(--neutral-300); +} + +.paste-information { + display: flex; + justify-content: space-between; + width: 100%; + padding: 10px 0; + border-bottom: 2px solid var(--neutral-700); + font-weight: bold; + margin-bottom: 15px; + color: var(--neutral-300); +} + +#pastes { + list-style-type: none; + width: 100%; + max-height: 90%; + overflow-y: auto; + padding: 0; + border-radius: 4px; + scrollbar-width: thin; + scrollbar-color: var(--neutral-700) var(--neutral-900); + border: none; +} + +#pastes li { + margin: 0.75rem 0; + transition: transform 0.2s ease; +} + +#pastes li:hover { + transform: translateY(-2px); +} + +#pastes li a { + display: grid; + grid-template-columns: 2fr 1fr 1fr; + gap: 0.5rem; + padding: 0.5rem 0.75rem; + background-color: var(--neutral-800); + color: var(--neutral-50); + text-decoration: none; + transition: all 0.3s ease; + border-radius: 6px; + border: 1px solid var(--neutral-700); + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); +} + +#pastes li a:hover { + background-color: var(--neutral-750); + border-color: var(--neutral-600); + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); +} + +#pastes li a p { + margin: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +#paste-title { + font-weight: 500; + color: var(--neutral-100); +} + +#paste-date { + color: var(--neutral-300); + font-size: 0.9rem; + text-align: center; +} + +#paste-syntax { + color: var(--neutral-300); + font-size: 0.9rem; + text-align: right; +} + +@media (max-width: 768px) { + #pastes li a { + grid-template-columns: 3fr 2fr; + } + #paste-syntax { + display: none; + } +} + +@media (max-width: 576px) { + #pastes li a { + padding: 0.7rem 0.8rem; + } +} + +.paste-actions { + display: flex; + justify-content: center; + align-items: center; + margin-top: auto; + padding-top: 15px; + border-top: 1px solid var(--neutral-800); +} + +.paste-actions button { + background-color: var(--neutral-700); + color: var(--neutral-50); + border: none; + border-radius: 6px; + padding: 8px 15px; + margin: 0 10px; + cursor: pointer; + transition: all 0.2s ease; + font-weight: 500; +} + +.paste-actions button:hover { + background-color: var(--neutral-600); + transform: translateY(-2px); + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15); +} + +.paste-actions button:active { + transform: translateY(0); +} + +.paste-actions button:disabled { + background-color: var(--neutral-800); + color: var(--neutral-500); + cursor: not-allowed; + opacity: 0.7; + box-shadow: none; + transform: none; +} + +#paste-pages { + margin: 0 15px; + font-weight: bold; + min-width: 40px; + text-align: center; + color: var(--neutral-300); +} + +#pastes::-webkit-scrollbar { + width: 8px; +} + +#pastes::-webkit-scrollbar-track { + background: var(--neutral-900); + border-radius: 6px; +} + +#pastes::-webkit-scrollbar-thumb { + background-color: var(--neutral-700); + border-radius: 6px; +} + +#pastes::-webkit-scrollbar-thumb:hover { + background-color: var(--neutral-600); +} + +@media (max-width: 992px) { + .main-container { + padding: 15px; + } + + .account-info, .paste-list { + padding: 20px; + } +} + +@media (max-width: 768px) { + .main-container { + flex-direction: column; + gap: 20px; + } + + .account-info, .paste-list { + width: 100%; + } +} + +@media (max-width: 576px) { + .main-container { + padding: 10px; + } + + .account-info, .paste-list { + padding: 15px; + } + + .account-info h1, .paste-list h1 { + font-size: 1.5rem; + } + + #pastes li { + flex-direction: column; + align-items: flex-start; + } + + #pastes li span { + margin-top: 5px; + font-size: 0.8rem; + } +} + +.logout-modal-overlay { + position: fixed; + top: 0; + left: 0; + width: 100vw; + height: 100vh; + background: rgba(0,0,0,0.5); + display: flex; + justify-content: center; + align-items: center; + z-index: 2000; +} +.logout-modal-box { + background: var(--neutral-900); + color: var(--neutral-100); + padding: 2rem 2.5rem; + border-radius: 10px; + box-shadow: 0 8px 32px rgba(0,0,0,0.25); + text-align: center; + min-width: 300px; + max-width: 90vw; +} +.logout-modal-box h2 { + margin-bottom: 1rem; + font-size: 1.4rem; + color: var(--neutral-50); +} +.logout-modal-box p { + margin-bottom: 2rem; + color: var(--neutral-300); +} +.logout-modal-box button { + margin: 0 0.5rem; + padding: 0.7rem 1.5rem; + border-radius: 6px; + font-weight: 600; + border: none; + cursor: pointer; + font-size: 1rem; + transition: background 0.2s, color 0.2s; +} +#confirm-logout { + background: #e74c3c; + color: #fff; +} +#confirm-logout:hover { + background: #c0392b; +} +#cancel-logout { + background: var(--neutral-700); + color: #fff; +} +#cancel-logout:hover { + background: var(--neutral-600); +} + +#logout-button { + background-color: var(--neutral-700); + color: var(--neutral-50); + border: none; + border-radius: 6px; + padding: 10px 24px; + margin-top: auto; + font-size: 1.08rem; + font-weight: 500; + cursor: pointer; + transition: background 0.2s, color 0.2s, box-shadow 0.2s, transform 0.2s; + box-shadow: 0 2px 8px rgba(0,0,0,0.08); + letter-spacing: 0.5px; +} +#logout-button:hover { + background-color: var(--neutral-600); + color: var(--neutral-10); + transform: translateY(-2px); + box-shadow: 0 4px 16px rgba(0,0,0,0.13); +} +#logout-button:active { + background-color: var(--neutral-800); + color: var(--neutral-200); + transform: none; + box-shadow: none; +} + +#delete-account-button { + background-color: #e74c3c; + color: #fff; + border: none; + border-radius: 6px; + padding: 10px 24px; + font-size: 1.08rem; + font-weight: 500; + cursor: pointer; + transition: background 0.2s, color 0.2s, box-shadow 0.2s, transform 0.2s; + box-shadow: 0 2px 8px rgba(0,0,0,0.08); + letter-spacing: 0.5px; + margin-top: 10px; +} +#delete-account-button:hover { + background-color: #c0392b; + color: #fff; + transform: translateY(-2px); + box-shadow: 0 4px 16px rgba(0,0,0,0.13); +} +#delete-account-button:active { + background-color: #a93226; + color: #fff; + transform: none; + box-shadow: none; +} + +.delete-modal-overlay { + position: fixed; + top: 0; + left: 0; + width: 100vw; + height: 100vh; + background: rgba(0,0,0,0.5); + display: flex; + justify-content: center; + align-items: center; + z-index: 2100; +} +.delete-modal-box { + background: var(--neutral-900); + color: var(--neutral-100); + padding: 2rem 2.5rem; + border-radius: 10px; + box-shadow: 0 8px 32px rgba(0,0,0,0.25); + text-align: center; + min-width: 320px; + max-width: 95vw; +} +.delete-modal-box h2 { + margin-bottom: 1rem; + font-size: 1.4rem; + color: #e74c3c; +} +.delete-modal-box p { + margin-bottom: 1.2rem; + color: var(--neutral-300); +} +.delete-modal-box input { + margin-bottom: 0.7rem; + width: 90%; + padding: 8px; + border-radius: 5px; + border: 1px solid var(--neutral-700); + background: var(--neutral-800); + color: var(--neutral-100); + font-size: 1rem; + outline: none; + transition: border 0.2s; +} +.delete-modal-box input:focus { + border: 1.5px solid #e74c3c; +} +.delete-modal-box button { + margin: 0 0.5rem; + padding: 0.7rem 1.5rem; + border-radius: 6px; + font-weight: 600; + border: none; + cursor: pointer; + font-size: 1rem; + transition: background 0.2s, color 0.2s; +} +#confirm-delete-account { + background: #e74c3c; + color: #fff; +} +#confirm-delete-account:hover { + background: #c0392b; +} +#confirm-delete-account:disabled { + background: var(--neutral-800); + color: var(--neutral-500); + cursor: not-allowed; + opacity: 0.7; + box-shadow: none; + transform: none; +} +#cancel-delete-account { + background: var(--neutral-700); + color: #fff; +} +#cancel-delete-account:hover { + background: var(--neutral-600); +} +#delete-error { + color: #e74c3c; + font-size: 1rem; + margin-top: 1rem; +} diff --git a/SharpbinV2.Server/wwwroot/css/navbar_raw.css b/SharpbinV2.Server/wwwroot/css/navbar_raw.css index 3940773..3a1c77f 100644 --- a/SharpbinV2.Server/wwwroot/css/navbar_raw.css +++ b/SharpbinV2.Server/wwwroot/css/navbar_raw.css @@ -2,101 +2,151 @@ display: flex; justify-content: space-between; align-items: center; - padding: 1rem 2rem; + padding: 0.75rem 2rem; background-color: var(--neutral-900); color: #fff; position: fixed; width: 100%; top: 0; - left: 0; - right: 0; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); + z-index: 1000; } -.nav-link { + +.nav-brand { + flex: 0 0 auto; + z-index: 15; +} + +.brand-link { + font-size: 1.5rem; + font-weight: 700; color: #fff; text-decoration: none; - font-size: 1.2rem; - transition: color 0.3s; -} -.nav-link:hover { - color: var(--neutral-300); + letter-spacing: 0.5px; + transition: transform 0.2s ease; } -.nav-links .nav-link { - width: auto; - padding: 0 1rem; - border-bottom: none; +.brand-link:hover { + transform: scale(1.05); } -.nav-links .nav-link:last-child { - border-bottom: none; -} - -.hamburger { - display: none; - background: none; - border: none; - font-size: 2rem; - cursor: pointer; - margin: 0 auto; +.nav-center { + position: absolute; + left: 0; + right: 0; + display: flex; + justify-content: center; + align-items: center; } .nav-links { display: flex; flex-direction: row; - position: static; - background-color: transparent; - padding: 0; - max-height: none; - transition: none; + align-items: center; + justify-content: center; + gap: 1rem; } -.nav-links.show { - display: flex; +.nav-link { + color: rgba(255, 255, 255, 0.85); + text-decoration: none; + font-size: 1.1rem; + padding: 0.6rem 1.2rem; + border-radius: 6px; + transition: all 0.3s ease; + font-weight: 500; + border: 1px solid rgba(255, 255, 255, 0.2); +} + +.nav-link:hover { + color: #fff; + background-color: rgba(255, 255, 255, 0.1); + transform: translateY(-2px); +} + +#nav-bar-selected { + color: #fff; + background-color: rgba(255, 255, 255, 0.15); + font-weight: 500; +} + +.hamburger { + display: none; flex-direction: column; - position: absolute; - top: 100%; - left: 0; - right: 0; - background-color: var(--neutral-900); - padding: 1rem 2rem; - max-height: 500px; - transition: max-height 0.3s ease-out; - overflow: hidden; + justify-content: space-between; + width: 30px; + height: 21px; + background: transparent; + border: none; + cursor: pointer; + padding: 0; + z-index: 15; +} + +.hamburger-line { + display: block; + height: 3px; + width: 100%; + border-radius: 10px; + background: #fff; + transition: all 0.3s ease; } @media (max-width: 800px) { + .nav-center { + position: static; + } + .nav-links { - display: none; - flex-direction: column; - width: 100%; - position: absolute; - top: 100%; + position: fixed; + top: 60px; left: 0; right: 0; - border-top: 1px solid var(--neutral-800); background-color: var(--neutral-900); - padding: 1rem 2rem; - max-height: 0; - transition: max-height 0.3s ease-out; - overflow: hidden; - } - .nav-link{ - width: 100% !important; - padding: 1rem 0 !important; - text-align: center; - border-bottom: 1px solid var(--neutral-800) !important; - } - .nav-links.show { - display: flex; - max-height: 500px; flex-direction: column; align-items: center; + padding: 0; + max-height: 0; + overflow: hidden; + transition: max-height 0.3s ease-out, padding 0.3s ease; + box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); } + + .nav-links.show { + max-height: 300px; + padding: 1rem 0; + } + + .nav-link { + width: 90%; + text-align: center; + padding: 1rem; + border-bottom: 1px solid var(--neutral-800); + } + + .home-link { + border: none; + border-bottom: 1px solid var(--neutral-800); + order: -1; + } + + .nav-link:last-child { + border-bottom: none; + } + .hamburger { - display: block; - margin: 0 auto; + display: flex; } - .nav-bar { - justify-content: center; + + .hamburger.active .hamburger-line:nth-child(1) { + transform: translateY(9px) rotate(45deg); + } + + .hamburger.active .hamburger-line:nth-child(2) { + opacity: 0; + } + + .hamburger.active .hamburger-line:nth-child(3) { + transform: translateY(-9px) rotate(-45deg); } } \ No newline at end of file diff --git a/SharpbinV2.Server/wwwroot/css/paste.css b/SharpbinV2.Server/wwwroot/css/paste.css index a9211af..9ddad5b 100644 --- a/SharpbinV2.Server/wwwroot/css/paste.css +++ b/SharpbinV2.Server/wwwroot/css/paste.css @@ -112,9 +112,6 @@ pre code.hljs { code.hljs { padding: 3px 5px } -/* -SLIGHTLY MODIFIED GITHUB DARK THEME -*/ .hljs { color: #c9d1d9; background: var(--neutral-900); @@ -205,4 +202,19 @@ SLIGHTLY MODIFIED GITHUB DARK THEME .hljs-deletion { color: #ffdcd7; background-color: #67060c +} + +.throbber { + border: 4px solid var(--neutral-700); + border-top: 4px solid var(--neutral-50); + border-radius: 50%; + width: 24px; + height: 24px; + animation: spin 1s linear infinite; + margin: auto; +} + +@keyframes spin { + 0% { transform: rotate(0deg); } + 100% { transform: rotate(360deg); } } \ No newline at end of file diff --git a/SharpbinV2.Server/wwwroot/css/style.css b/SharpbinV2.Server/wwwroot/css/style.css index a8f04ef..958c782 100644 --- a/SharpbinV2.Server/wwwroot/css/style.css +++ b/SharpbinV2.Server/wwwroot/css/style.css @@ -7,8 +7,7 @@ } :root { - /* TailwindCSS Neutral Colors */ - --neutral-50: #fafafa; + --neutral-50: #fafafa; --neutral-100: #f5f5f5; --neutral-200: #e5e5e5; --neutral-300: #d4d4d4; diff --git a/SharpbinV2.Server/wwwroot/dash.html b/SharpbinV2.Server/wwwroot/dash.html new file mode 100644 index 0000000..330fba4 --- /dev/null +++ b/SharpbinV2.Server/wwwroot/dash.html @@ -0,0 +1,52 @@ + + + + + + + Dashboard - Sharpbin + + + + + + + + + + + +
+ +
+

Your Pastes

+
+

Title

+

Date

+

Syntax

+
+
    + +
+
+ +

0/0

+ +
+
+
+ + + + \ No newline at end of file diff --git a/SharpbinV2.Server/wwwroot/index.html b/SharpbinV2.Server/wwwroot/index.html index 410c92f..f032b3e 100644 --- a/SharpbinV2.Server/wwwroot/index.html +++ b/SharpbinV2.Server/wwwroot/index.html @@ -18,7 +18,7 @@
- +
+
+ + + + `; + modalOverlay.appendChild(modalBox); + document.body.appendChild(modalOverlay); + + document.getElementById('cancel-delete-account').onclick = function () { + document.body.removeChild(modalOverlay); + }; + + const userInput = document.getElementById('delete-username'); + const countInput = document.getElementById('delete-pastecount'); + const confirmBtn = document.getElementById('confirm-delete-account'); + function validateInputs() { + if (userInput.value.trim() === username && countInput.value.trim() === String(pasteCount)) { + confirmBtn.disabled = false; + } else { + confirmBtn.disabled = true; + } + } + userInput.addEventListener('input', validateInputs); + countInput.addEventListener('input', validateInputs); + + confirmBtn.onclick = async function () { + if (confirmBtn.disabled) return; + try { + await fetch('/api/accounts/delete', { method: 'POST', credentials: 'include' }); + } catch { } + window.location.href = '/register'; + }; +} diff --git a/SharpbinV2.Server/wwwroot/js/login.js b/SharpbinV2.Server/wwwroot/js/login.js new file mode 100644 index 0000000..c0d1411 --- /dev/null +++ b/SharpbinV2.Server/wwwroot/js/login.js @@ -0,0 +1,89 @@ +document.addEventListener('DOMContentLoaded', function () { + const loginForm = document.getElementById('login-form'); + const errorMessage = document.getElementById('error-message'); + + + checkAuthStatus(); + + loginForm.addEventListener('submit', async function (event) { + event.preventDefault(); + + + const username = document.getElementById('username').value.trim(); + const password = document.getElementById('password').value; + + + if (!username || !password) { + showError('Please fill in all required fields'); + return; + } + + try { + + const submitButton = loginForm.querySelector('button[type="submit"]'); + const originalButtonText = submitButton.textContent; + submitButton.disabled = true; + submitButton.textContent = 'Logging in...'; + + + const isEmail = username.includes('@'); + const requestData = isEmail + ? { email: username, password: password } + : { username: username, password: password }; + + + const response = await fetch('/api/accounts/login', { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(requestData) + }); + + const data = await response.json(); + + if (data.success) { + + window.location.href = '/dash'; + } else { + showError(data.message || 'Login failed. Please check your credentials.'); + submitButton.disabled = false; + submitButton.textContent = originalButtonText; + } + } catch (error) { + console.error('Login error:', error); + showError('An unexpected error occurred. Please try again later.'); + + const submitButton = loginForm.querySelector('button[type="submit"]'); + submitButton.disabled = false; + submitButton.textContent = 'Login'; + } + }); + + + function showError(message) { + errorMessage.textContent = message; + errorMessage.classList.add('visible'); + + + setTimeout(() => { + errorMessage.classList.remove('visible'); + }, 5000); + } + + + async function checkAuthStatus() { + try { + const response = await fetch('/api/accounts/authorized'); + const data = await response.json(); + + if (data.success) { + + window.location.href = '/dash'; + } + } catch (error) { + + console.log('Not logged in'); + } + } +}); diff --git a/SharpbinV2.Server/wwwroot/js/navbar.js b/SharpbinV2.Server/wwwroot/js/navbar.js index 53c5c05..b90f945 100644 --- a/SharpbinV2.Server/wwwroot/js/navbar.js +++ b/SharpbinV2.Server/wwwroot/js/navbar.js @@ -1,22 +1,214 @@ const navbarHTML = `
diff --git a/SharpbinV2.Server/wwwroot/register.html b/SharpbinV2.Server/wwwroot/register.html new file mode 100644 index 0000000..76f2423 --- /dev/null +++ b/SharpbinV2.Server/wwwroot/register.html @@ -0,0 +1,52 @@ + + + + + + + Register - Sharpbin + + + + + + + + + + +
+
+

Create an Account

+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ +
+
+ + + + + +