diff --git a/ImageBoardServerApp/Data/CommentData.cs b/ImageBoardServerApp/Data/CommentData.cs index bcaf8a1..14a5c5d 100644 --- a/ImageBoardServerApp/Data/CommentData.cs +++ b/ImageBoardServerApp/Data/CommentData.cs @@ -1,7 +1,5 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using System.Diagnostics.CodeAnalysis; -using ImageBoardServerApp.Shared.Components; namespace ImageBoardServerApp.Data; diff --git a/ImageBoardServerApp/ImageBoardServerApp.csproj b/ImageBoardServerApp/ImageBoardServerApp.csproj index 7866871..756ebf0 100644 --- a/ImageBoardServerApp/ImageBoardServerApp.csproj +++ b/ImageBoardServerApp/ImageBoardServerApp.csproj @@ -18,18 +18,9 @@ - - - - - - - - - diff --git a/ImageBoardServerApp/Pages/Accounts/Login.razor b/ImageBoardServerApp/Pages/Accounts/Login.razor index 3c53718..5483640 100644 --- a/ImageBoardServerApp/Pages/Accounts/Login.razor +++ b/ImageBoardServerApp/Pages/Accounts/Login.razor @@ -1,7 +1,6 @@ @page "/login" @using ImageBoardServerApp.Data.Repository @using ImageBoardServerApp.Auth -@using System.Runtime.InteropServices @inject IJSRuntime js @inject AuthenticationStateProvider authStateProvider @inject NavigationManager navManager diff --git a/ImageBoardServerApp/Pages/Accounts/Register.razor b/ImageBoardServerApp/Pages/Accounts/Register.razor new file mode 100644 index 0000000..b422d38 --- /dev/null +++ b/ImageBoardServerApp/Pages/Accounts/Register.razor @@ -0,0 +1,67 @@ +@page "/register" +@using ImageBoardServerApp.Data.Repository +@using ImageBoardServerApp.Auth +@inject IJSRuntime js +@inject AuthenticationStateProvider authStateProvider +@inject NavigationManager navManager + +

Register to bulletbroards

+
+
+
+ + +
+
+ + +
+ [Register] +
+ +
+@code { + private string Email { get; set; } + private string Password { get; set; } + + private bool verified; + + private async Task login() + { + Console.WriteLine("Registering..."); + UserData userToCreate = new UserData() + { + Email = Email, + Password = BCrypt.Net.BCrypt.HashPassword(Password), + Role = "User", + PermissionInteger = 1, + TimeBanned = -1 + }; + if (await UsersRepository.getUserByEmailAsync(Email) != null) + { + return; + } + await UsersRepository.createUserAsync(userToCreate); + Console.WriteLine("loggin you in..."); + var user = await UsersRepository.getUserByEmailAsync(Email); + if (user == null) + { + await js.InvokeVoidAsync("alert", "User does not exist"); + verified = false; + return; + } + verified = BCrypt.Net.BCrypt.Verify(Password, user.Password); + if (verified) + { + verified = true; + var customAuthStateProvider = (CustomAuthenticationStateProvider)authStateProvider; + await customAuthStateProvider.UpdateAuthenticationStateAsync(user); + navManager.NavigateTo("/", true); + return; + } + await js.InvokeVoidAsync("alert", $"Wrong Password"); + } +} +@code { + +} \ No newline at end of file diff --git a/ImageBoardServerApp/Pages/Basic/Index.razor b/ImageBoardServerApp/Pages/Basic/Index.razor index 513b766..99a6427 100644 --- a/ImageBoardServerApp/Pages/Basic/Index.razor +++ b/ImageBoardServerApp/Pages/Basic/Index.razor @@ -6,8 +6,8 @@

BulletBoard

This is a simple Imageboard made in Razor.
-We're currently hosting @amountOfPosts Threads with @amountOfComments Comments from @amountOfUsers Users. -
+We're currently hosting @amountOfPosts Threads, @amountOfComments Comments and @amountOfUsers Users. + @Details @code{ diff --git a/ImageBoardServerApp/Pages/Moderation/ModMenu.razor b/ImageBoardServerApp/Pages/Moderation/ModMenu.razor new file mode 100644 index 0000000..ed7579a --- /dev/null +++ b/ImageBoardServerApp/Pages/Moderation/ModMenu.razor @@ -0,0 +1,32 @@ +@page "/modmenu" +@using ImageBoardServerApp.Auth +@inject AuthenticationStateProvider authStateProvider +@inject NavigationManager navManager + + +

ModMenu

+ + + Welcome @mail to the mod menu +
+ [Reports] + [Users] +
+
+ + You do not have permission to view this menu. + +
+@code { + private string mail { get; set; } = ""; + + protected override async Task OnInitializedAsync() + { + var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider; + var user = await cauthStateProvder.GetAuthenticationStateAsync(); + if (user.User.Identity.IsAuthenticated) + { + mail = user.User.Identity.Name; + } + } +} \ No newline at end of file diff --git a/ImageBoardServerApp/Pages/Moderation/ReportsPage.razor b/ImageBoardServerApp/Pages/Moderation/ReportsPage.razor new file mode 100644 index 0000000..aaebd07 --- /dev/null +++ b/ImageBoardServerApp/Pages/Moderation/ReportsPage.razor @@ -0,0 +1,5 @@ +@page "/modmenu/reports" + +@code { + +} \ No newline at end of file diff --git a/ImageBoardServerApp/Pages/Moderation/UsersPage.razor b/ImageBoardServerApp/Pages/Moderation/UsersPage.razor new file mode 100644 index 0000000..871b4c0 --- /dev/null +++ b/ImageBoardServerApp/Pages/Moderation/UsersPage.razor @@ -0,0 +1,6 @@ +@page "/modmenu/users" +

UsersPage

+ +@code { + +} \ No newline at end of file diff --git a/ImageBoardServerApp/Shared/Components/Comment.razor b/ImageBoardServerApp/Shared/Components/Comment.razor index 7b2ea75..1225ce6 100644 --- a/ImageBoardServerApp/Shared/Components/Comment.razor +++ b/ImageBoardServerApp/Shared/Components/Comment.razor @@ -9,6 +9,10 @@ @toggleText ] @comment.Username + @if (@comment.User.Role != "User") + { + ##@comment.User.Role + } @getTimeFromUnix(comment.CreatedAt) No.@comment.CommentID diff --git a/ImageBoardServerApp/Shared/Components/Comment.razor.css b/ImageBoardServerApp/Shared/Components/Comment.razor.css index b69acda..4de11ba 100644 --- a/ImageBoardServerApp/Shared/Components/Comment.razor.css +++ b/ImageBoardServerApp/Shared/Components/Comment.razor.css @@ -58,4 +58,13 @@ .threadTextContainer{ margin: 0; +} + + +.Admin{ + color: #ff191c; +} + +.Mod{ + color: #af13d7; } \ No newline at end of file diff --git a/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor b/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor index 0a81474..90bf2c6 100644 --- a/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor +++ b/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor @@ -100,7 +100,7 @@ { Stream stream = selectedFile.OpenReadStream(maxAllowedSize: 512000 * 4); // max 2MB var file = Path.GetRandomFileName() + "." + selectedFile.Name.Split(".")[selectedFile.Name.Split(".").Length - 1]; - var path = $"{env.WebRootPath}\\img\\dynamic\\comment\\{@post.Board}\\{file}"; + var path = $"{env.WebRootPath}/img/dynamic/comment/{@post.Board}/{@file}"; FileStream fs = File.Create(path); await stream.CopyToAsync(fs); stream.Close(); @@ -110,7 +110,7 @@ var imageToUpload = new ImageData { Board = post.Board, - ImageLocation = $"\\img\\dynamic\\comment\\{post.Board}\\{file}" + ImageLocation = $"/img/dynamic/comment/{@post.Board}/{@file}" }; int imageID = await ImagesRepository.createImageAsync(imageToUpload); commentToCreate = new CommentData() diff --git a/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor b/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor index 2389009..cf54db9 100644 --- a/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor +++ b/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor @@ -120,7 +120,7 @@ Stream stream = selectedFile.OpenReadStream(maxAllowedSize: 512000 * 4); // max 2MB var file = Path.GetRandomFileName() + "." + selectedFile.Name.Split(".")[selectedFile.Name.Split(".").Length - 1]; - var path = $"{env.WebRootPath}\\img\\dynamic\\op\\{board.Tag}\\{file}"; + var path = $"{env.WebRootPath}/img/dynamic/op/{@board.Tag}/{@file}"; FileStream fs = File.Create(path); await stream.CopyToAsync(fs); stream.Close(); @@ -129,7 +129,7 @@ var imageToUpload = new ImageData { Board = board.Tag, - ImageLocation = $"\\img\\dynamic\\op\\{board.Tag}\\{file}" + ImageLocation = $"/img/dynamic/op/{@board.Tag}/{@file}" }; int imageID = await ImagesRepository.createImageAsync(imageToUpload); var postToPost = new PostData diff --git a/ImageBoardServerApp/Shared/Components/Post.razor b/ImageBoardServerApp/Shared/Components/Post.razor index af77439..2e493a2 100644 --- a/ImageBoardServerApp/Shared/Components/Post.razor +++ b/ImageBoardServerApp/Shared/Components/Post.razor @@ -13,7 +13,10 @@ } @post.Title @post.Username - ##@post.User.Role + @if (post.User.Role != "User") + { + ##@post.User.Role + } @getTimeFromUnix(post.CreatedAt) No.@post.PostID @@ -33,7 +36,7 @@
@foreach (string s in @post.Content.Split("\n")) { - @if (s.StartsWith(">")) + @if (@s.StartsWith(">")) { @s } diff --git a/ImageBoardServerApp/Shared/Components/Post.razor.css b/ImageBoardServerApp/Shared/Components/Post.razor.css index 0233d02..2cee082 100644 --- a/ImageBoardServerApp/Shared/Components/Post.razor.css +++ b/ImageBoardServerApp/Shared/Components/Post.razor.css @@ -16,10 +16,14 @@ color: #339305; } -.roleAdmin{ +.Admin{ color: #ff191c; } +.Mod{ + color: #af13d7; +} + .threadHeader{ text-align: left; } diff --git a/ImageBoardServerApp/Shared/Components/Reports.razor b/ImageBoardServerApp/Shared/Components/Reports.razor new file mode 100644 index 0000000..0fe0732 --- /dev/null +++ b/ImageBoardServerApp/Shared/Components/Reports.razor @@ -0,0 +1,5 @@ +

Reports

+ +@code { + +} \ No newline at end of file diff --git a/ImageBoardServerApp/Shared/MainLayout.razor b/ImageBoardServerApp/Shared/MainLayout.razor index b4d94cf..141e9c6 100644 --- a/ImageBoardServerApp/Shared/MainLayout.razor +++ b/ImageBoardServerApp/Shared/MainLayout.razor @@ -20,6 +20,7 @@ [Logout @mail] + [Register] [Login] diff --git a/ImageBoardServerApp/_Imports.razor b/ImageBoardServerApp/_Imports.razor index 3e6f6b8..3613cc4 100644 --- a/ImageBoardServerApp/_Imports.razor +++ b/ImageBoardServerApp/_Imports.razor @@ -6,8 +6,6 @@ @using Microsoft.AspNetCore.Components.Web @using Microsoft.AspNetCore.Components.Web.Virtualization @using Microsoft.JSInterop -@using ImageBoardServerApp -@using ImageBoardServerApp.Shared @using Radzen @using Radzen.Blazor @using ImageBoardServerApp