Merge branch 'Pierre' into 'master'
Edit the rules See merge request limited_dev/imageboard!1
This commit is contained in:
commit
41c943322d
11 changed files with 167 additions and 6 deletions
|
@ -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>
|
5
ImageBoardServerApp/App.razor.css
Normal file
5
ImageBoardServerApp/App.razor.css
Normal file
|
@ -0,0 +1,5 @@
|
|||
.Error404{
|
||||
text-align: center;
|
||||
align-items:center;
|
||||
font-style: italic;
|
||||
}
|
|
@ -15,4 +15,7 @@ public class AccountData
|
|||
|
||||
[Required]
|
||||
public string Password { get; set; }
|
||||
|
||||
[Required]
|
||||
public int PermissionInteger { get; set; }
|
||||
}
|
53
ImageBoardServerApp/Data/Repository/AccountsRepository.cs
Normal file
53
ImageBoardServerApp/Data/Repository/AccountsRepository.cs
Normal 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;
|
||||
}
|
||||
}
|
|
@ -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>
|
||||
|
|
58
ImageBoardServerApp/Pages/Login.razor
Normal file
58
ImageBoardServerApp/Pages/Login.razor
Normal 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;
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
|
||||
|
|
12
ImageBoardServerApp/Pages/Rules.razor.css
Normal file
12
ImageBoardServerApp/Pages/Rules.razor.css
Normal 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.*/
|
||||
}
|
|
@ -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 -->
|
||||
|
|
4
ImageBoardServerApp/Shared/Components/Board.razor.css
Normal file
4
ImageBoardServerApp/Shared/Components/Board.razor.css
Normal file
|
@ -0,0 +1,4 @@
|
|||
.boardHeader{
|
||||
text-align: center;
|
||||
|
||||
}
|
BIN
ImageBoardServerApp/wwwroot/static/1.jpeg
Normal file
BIN
ImageBoardServerApp/wwwroot/static/1.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 54 KiB |
Loading…
Reference in a new issue