Merge branch 'Pierre' into 'master'

Edit the rules

See merge request limited_dev/imageboard!1
This commit is contained in:
limited_dev 2023-01-25 12:37:39 +00:00
commit 41c943322d
11 changed files with 167 additions and 6 deletions

View file

@ -6,7 +6,11 @@
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
<h3>404</h3>
<div class="Error404">
<img src="static/1.jpeg" alt="noimageFound"/>
<p role="alert">Sorry, nothing found. Please go back to the main page. Or watch the tree and find the hidden Cat..</p>
</div>
</LayoutView>
</NotFound>
</Router>

View file

@ -0,0 +1,5 @@
.Error404{
text-align: center;
align-items:center;
font-style: italic;
}

View file

@ -15,4 +15,7 @@ public class AccountData
[Required]
public string Password { get; set; }
[Required]
public int PermissionInteger { get; set; }
}

View file

@ -0,0 +1,53 @@
using Microsoft.EntityFrameworkCore;
namespace ImageBoardServerApp.Data.Repository;
public static class AccountsRepository
{
public static async Task<List<AccountData>> getAccountsAsync()
{
await using var db = new AppDBContext();
return await db.Accounts.ToListAsync();
}
public static async Task<List<AccountData>> getAccountsByMailAsync(string email)
{
await using var db = new AppDBContext();
return await db.Accounts
.Where(acc => acc.Email.Equals(email))
.ToListAsync();
}
public static async Task<AccountData> getAccountByIdAsync(int accountId)
{
await using var db = new AppDBContext();
return await db.Accounts.FirstOrDefaultAsync(post => post.AccountID == accountId);
}
public static async Task<int> createAccountAsync(AccountData accountToCreate)
{
await using var db = new AppDBContext();
await db.Accounts.AddAsync(accountToCreate);
if (await db.SaveChangesAsync() >= 1)
{
Console.WriteLine($"Created post with ID: {accountToCreate.AccountID}");
return accountToCreate.AccountID;
}
return -1;
}
public static async Task<bool> updateAccountAsync(AccountData accountToUpdate)
{
await using var db = new AppDBContext();
db.Accounts.Update(accountToUpdate);
return await db.SaveChangesAsync() >= 1;
}
public static async Task<bool> deleteAccountAsync(int postId)
{
await using var db = new AppDBContext();
AccountData accountToDelete = await getAccountByIdAsync(postId);
db.Remove(accountToDelete);
return await db.SaveChangesAsync() >= 1;
}
}

View file

@ -7,6 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.13" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.13">
<PrivateAssets>all</PrivateAssets>
@ -17,4 +18,8 @@
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot\static" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,58 @@
@page "/Login"
@using ImageBoardServerApp.Data.Repository
<h3>Login</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>
<button type="submit" @onclick="SubmitForm">Submit</button>
</form>
@if (tried)
{
@if (verified)
{
<span>Verifed!</span>
}
else
{
<span>False login</span>
}
}
else
{
<span>Plz login</span>
}
</div>
@code {
private string Email { get; set; }
private string Password { get; set; }
private bool verified = false;
private bool tried = false;
private async Task SubmitForm()
{
tried = true;
AccountData target = (await AccountsRepository.getAccountsByMailAsync(Email))[0];
if (target == null)
{
verified = false;
return;
}
verified = BCrypt.Net.BCrypt.Verify(Password, target.Password);
if (verified)
{
verified = true;
return;
}
verified = false;
}
}

View file

@ -1,5 +1,18 @@
@page "/rules"
<h3>Rules</h3>
<div class="rules_headline">
<h3>Rules</h3>
</div>
<ul type="1" class="rules_list">
<li>nudes are forbidden!</li>
<li>nacket pictures are forbidden!</li>
<li>no political statements!</li>
<li>Trees are nice!</li>
<li>Cats are nice!</li>
<li>Be mentely Unstable!:-)</li>
</ul>
@code {

View file

@ -0,0 +1,12 @@
.rules_headline{
text-align: center;
font-weight: 1000;
/*the text have to be in a biger Pixel number I do not know how to do it */
}
.rules_list{
text-align:right;
display:block;
font-size: 14px;
font-weight: 60 ;
/*the text sice can stay like it is, if you do not want to change it.*/
}

View file

@ -2,11 +2,15 @@
@using ImageBoardServerApp.Data
@using ImageBoardServerApp.Data.Repository
<h3>@board.Topic Board</h3>
<PageTitle>/@board.Tag/ - @board.Topic - BulletBoard</PageTitle>
<PostForm board="@board"/>
<div class="boardHeader">
<h3>@board.Topic Board</h3>
<PostForm board="@board"/>
<PageFooter/>
</div>
<br/>
<br/>
@ -23,7 +27,7 @@
<hr/>
}
}
<PageFooter/>
<!--Admin -->
<!--Moderator -->

View file

@ -0,0 +1,4 @@
.boardHeader{
text-align: center;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB