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..bdea895 --- /dev/null +++ b/ImageBoardServerApp/Pages/Moderation/ModMenu.razor @@ -0,0 +1,31 @@ +@page "/modmenu" +@using ImageBoardServerApp.Auth +@inject AuthenticationStateProvider authStateProvider +@inject NavigationManager navManager + + +

ModMenu

+ + + Welcome @mail to the mod menu +
+ [Reports] +
+
+ + 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/Shared/Components/Comment.razor b/ImageBoardServerApp/Shared/Components/Comment.razor index 7b2ea75..192a56d 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..30f20bc 100644 --- a/ImageBoardServerApp/Shared/Components/Comment.razor.css +++ b/ImageBoardServerApp/Shared/Components/Comment.razor.css @@ -58,4 +58,11 @@ .threadTextContainer{ margin: 0; -} \ No newline at end of file +} + +.Admin{ + color: #ff191c; +} +.Mod{ + color: #af13d7; +} diff --git a/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor b/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor index 0a81474..883ab15 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..01338f2 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..b3d8f72 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 diff --git a/ImageBoardServerApp/Shared/Components/Post.razor.css b/ImageBoardServerApp/Shared/Components/Post.razor.css index 0233d02..2285ed7 100644 --- a/ImageBoardServerApp/Shared/Components/Post.razor.css +++ b/ImageBoardServerApp/Shared/Components/Post.razor.css @@ -16,9 +16,13 @@ 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]