feat: added docker stuff, started working on login system

This commit is contained in:
limited_dev 2023-02-01 21:49:02 +01:00
parent c2d40c172a
commit 7c0cef6f65
15 changed files with 216 additions and 143 deletions

View file

@ -87,13 +87,15 @@
{
var userToCreate = new UserData
{
Ipv4Address = "192.168.178.101",
Banned = false,
Email = "dev@limited-dev.de",
Password = "$2a$10$C/ZPY5aVGkImLGyIP0SySuQaEYIwnY0J99i/m6tqqf6tMkax89Eku",
PermissionInteger = 100,
TimeBanned = -1,
lastActionTimeStamp = DateTime.Now.Millisecond
};
int userID;
UserData foundusr = await UsersRepository.getUserByIPAsync(userToCreate.Ipv4Address);
UserData foundusr = await UsersRepository.getUserByEmailAsync(userToCreate.Email);
if (foundusr == null)
{
userID = await UsersRepository.createUserAsync(userToCreate);
@ -101,9 +103,9 @@
else
{
userID = foundusr.UserID;
if(foundusr.Banned)
if(foundusr.TimeBanned != -1)
return;
foundusr.lastActionTimeStamp = DateTime.Now.Millisecond;
foundusr.lastActionTimeStamp = DateTimeOffset.UnixEpoch.ToUnixTimeMilliseconds();
await UsersRepository.updateUserAsync(foundusr);
}

View file

@ -100,13 +100,15 @@
{
var userToCreate = new UserData
{
Ipv4Address = "192.168.178.101",
Banned = false,
Email = "test@mail.org",
Password = "$2a$10$C/ZPY5aVGkImLGyIP0SySuQaEYIwnY0J99i/m6tqqf6tMkax89Eku",
PermissionInteger = 100,
TimeBanned = -1,
lastActionTimeStamp = DateTime.Now.Millisecond
};
int userID;
UserData foundusr = await UsersRepository.getUserByIPAsync(userToCreate.Ipv4Address);
UserData foundusr = await UsersRepository.getUserByEmailAsync(userToCreate.Email);
if (foundusr == null)
{
userID = await UsersRepository.createUserAsync(userToCreate);
@ -114,9 +116,9 @@
else
{
userID = foundusr.UserID;
if(foundusr.Banned)
if(foundusr.TimeBanned != -1)
return;
foundusr.lastActionTimeStamp = DateTime.Now.Millisecond;
foundusr.lastActionTimeStamp = DateTimeOffset.UnixEpoch.ToUnixTimeMilliseconds();
await UsersRepository.updateUserAsync(foundusr);
}

View file

@ -1,4 +1,7 @@
@inherits LayoutComponentBase
@using ImageBoardServerApp.Auth
@inject AuthenticationStateProvider authStateProvder
@inject NavigationManager navManager
<PageTitle>BulletBoard</PageTitle>
@ -11,10 +14,28 @@
<div class="top-row px-4">
<a href="/faq">[FAQ]</a>
<a href="/rules">[Rules]</a>
<AuthorizeView>
<Authorized>
<a @onclick="logout" href="javascript:void(0)">[Logout]</a>
</Authorized>
<NotAuthorized>
<a href="/login">[Login]</a>
</NotAuthorized>
</AuthorizeView>
</div>
<article class="content px-4">
@Body
</article>
</main>
</div>
</div>
@code
{
private async Task logout()
{
var customAuthStateProvider = (CustomAuthenticationStateProvider)authStateProvder;
await customAuthStateProvider.UpdateAuthenticationStateAsync(null);
navManager.NavigateTo("/", true);
}
}