Merge branch 'Eric-maybe_borked' into 'Eric'
Eric maybe borked See merge request limited_dev/imageboard!3
This commit is contained in:
commit
c093b06d03
17 changed files with 145 additions and 23 deletions
|
@ -1,7 +1,5 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using ImageBoardServerApp.Shared.Components;
|
||||
|
||||
namespace ImageBoardServerApp.Data;
|
||||
|
||||
|
|
|
@ -18,18 +18,9 @@
|
|||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AdditionalFiles Include="Shared\Components\Forms\CommentForm.razor" />
|
||||
<AdditionalFiles Include="Shared\Components\Forms\PostForm.razor" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="wwwroot\img\dynamic\comment\b" />
|
||||
<Folder Include="wwwroot\img\dynamic\op\b" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="wwwroot\img\dynamic\op\1663306837979603.jpg" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -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
|
||||
|
|
67
ImageBoardServerApp/Pages/Accounts/Register.razor
Normal file
67
ImageBoardServerApp/Pages/Accounts/Register.razor
Normal file
|
@ -0,0 +1,67 @@
|
|||
@page "/register"
|
||||
@using ImageBoardServerApp.Data.Repository
|
||||
@using ImageBoardServerApp.Auth
|
||||
@inject IJSRuntime js
|
||||
@inject AuthenticationStateProvider authStateProvider
|
||||
@inject NavigationManager navManager
|
||||
|
||||
<h3>Register to bulletbroards</h3>
|
||||
<div>
|
||||
<form>
|
||||
<div>
|
||||
<label for="email">Email:</label>
|
||||
<input type="email" id="email" @bind="Email" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="password">Password:</label>
|
||||
<input type="password" id="password" @bind="Password" />
|
||||
</div>
|
||||
<a @onclick="login" href="javascript:void(0)">[Register]</a>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
@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 {
|
||||
|
||||
}
|
|
@ -6,8 +6,8 @@
|
|||
<h1>BulletBoard</h1>
|
||||
<span>This is a simple Imageboard made in Razor.</span>
|
||||
<br/>
|
||||
<span>We're currently hosting @amountOfPosts Threads with @amountOfComments Comments from @amountOfUsers Users.</span>
|
||||
<br/>
|
||||
<span>We're currently hosting @amountOfPosts Threads, @amountOfComments Comments and @amountOfUsers Users.</span>
|
||||
<sr/>
|
||||
<span>@Details</span>
|
||||
|
||||
@code{
|
||||
|
|
32
ImageBoardServerApp/Pages/Moderation/ModMenu.razor
Normal file
32
ImageBoardServerApp/Pages/Moderation/ModMenu.razor
Normal file
|
@ -0,0 +1,32 @@
|
|||
@page "/modmenu"
|
||||
@using ImageBoardServerApp.Auth
|
||||
@inject AuthenticationStateProvider authStateProvider
|
||||
@inject NavigationManager navManager
|
||||
|
||||
|
||||
<h3>ModMenu</h3>
|
||||
<AuthorizeView>
|
||||
<Authorized>
|
||||
<span>Welcome @mail to the mod menu</span>
|
||||
<div>
|
||||
<a href="/modmenu/reports">[Reports]</a>
|
||||
<a href="/modmenu/users">[Users]</a>
|
||||
</div>
|
||||
</Authorized>
|
||||
<NotAuthorized>
|
||||
<a href="/login">You do not have permission to view this menu.</a>
|
||||
</NotAuthorized>
|
||||
</AuthorizeView>
|
||||
@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;
|
||||
}
|
||||
}
|
||||
}
|
5
ImageBoardServerApp/Pages/Moderation/ReportsPage.razor
Normal file
5
ImageBoardServerApp/Pages/Moderation/ReportsPage.razor
Normal file
|
@ -0,0 +1,5 @@
|
|||
@page "/modmenu/reports"
|
||||
<Reports />
|
||||
@code {
|
||||
|
||||
}
|
6
ImageBoardServerApp/Pages/Moderation/UsersPage.razor
Normal file
6
ImageBoardServerApp/Pages/Moderation/UsersPage.razor
Normal file
|
@ -0,0 +1,6 @@
|
|||
@page "/modmenu/users"
|
||||
<h3>UsersPage</h3>
|
||||
|
||||
@code {
|
||||
|
||||
}
|
|
@ -9,6 +9,10 @@
|
|||
<a class="toggleOpened" onclick="@ToggleOpened">@toggleText</a>
|
||||
<span>]</span>
|
||||
<span class="name">@comment.Username</span>
|
||||
@if (@comment.User.Role != "User")
|
||||
{
|
||||
<span class="@comment.User.Role" >##@comment.User.Role</span>
|
||||
}
|
||||
<span class="date">@getTimeFromUnix(comment.CreatedAt)</span>
|
||||
<span class="post-id">No.@comment.CommentID</span>
|
||||
</div>
|
||||
|
|
|
@ -58,4 +58,13 @@
|
|||
|
||||
.threadTextContainer{
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
|
||||
.Admin{
|
||||
color: #ff191c;
|
||||
}
|
||||
|
||||
.Mod{
|
||||
color: #af13d7;
|
||||
}
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -13,7 +13,10 @@
|
|||
}
|
||||
<span class="title">@post.Title</span>
|
||||
<span class="name">@post.Username</span>
|
||||
<span class="roleAdmin" >##@post.User.Role</span>
|
||||
@if (post.User.Role != "User")
|
||||
{
|
||||
<span class="@post.User.Role" >##@post.User.Role</span>
|
||||
}
|
||||
<span class="date">@getTimeFromUnix(post.CreatedAt)</span>
|
||||
<span class="post-id">No.@post.PostID</span>
|
||||
</div>
|
||||
|
@ -33,7 +36,7 @@
|
|||
<div class="threadTextContainer">
|
||||
@foreach (string s in @post.Content.Split("\n"))
|
||||
{
|
||||
@if (s.StartsWith(">"))
|
||||
@if (@s.StartsWith(">"))
|
||||
{
|
||||
<span class="threadText greenText">@s</span>
|
||||
}
|
||||
|
|
|
@ -16,10 +16,14 @@
|
|||
color: #339305;
|
||||
}
|
||||
|
||||
.roleAdmin{
|
||||
.Admin{
|
||||
color: #ff191c;
|
||||
}
|
||||
|
||||
.Mod{
|
||||
color: #af13d7;
|
||||
}
|
||||
|
||||
.threadHeader{
|
||||
text-align: left;
|
||||
}
|
||||
|
|
5
ImageBoardServerApp/Shared/Components/Reports.razor
Normal file
5
ImageBoardServerApp/Shared/Components/Reports.razor
Normal file
|
@ -0,0 +1,5 @@
|
|||
<h3>Reports</h3>
|
||||
|
||||
@code {
|
||||
|
||||
}
|
|
@ -20,6 +20,7 @@
|
|||
<a @onclick="logout" href="javascript:void(0)">[Logout @mail]</a>
|
||||
</Authorized>
|
||||
<NotAuthorized>
|
||||
<a href="/register">[Register]</a>
|
||||
<a href="/login">[Login]</a>
|
||||
</NotAuthorized>
|
||||
</AuthorizeView>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue