@@ -63,6 +66,9 @@
selectedFile = e.GetMultipleFiles()[0];
this.StateHasChanged();
}
+
+ string postErr { get; set; }
+ bool hasErr { get; set; } = false;
private async Task onPostClick()
{
@@ -70,9 +76,20 @@
var user = await cauthStateProvder.GetAuthenticationStateAsync();
var usr = user.User;
UserData foundusr = await UsersRepository.getUserByEmailAsync(usr.Identity.Name);
- int userID = foundusr.UserID;
- if(foundusr.TimeBanned != -1)
+ if (foundusr == null)
+ {
+ hasErr = true;
+ postErr = "You are not logged in.";
return;
+ }
+ int userID = foundusr.UserID;
+ if (foundusr.TimeBanned != -1)
+ {
+ hasErr = true;
+ postErr = "You are banned and may not comment.";
+ //Maybe redirect to /banned?
+ return;
+ }
foundusr.lastActionTimeStamp = DateTimeOffset.UnixEpoch.ToUnixTimeMilliseconds();
await UsersRepository.updateUserAsync(foundusr);
@@ -125,6 +142,8 @@
{
//Open comment unsucessfull
navigationManager.NavigateTo("/UnSuccessfulPost");
+ hasErr = true;
+ postErr = "There was an error and the comment could not be created. Please notify the admin.";
Console.WriteLine("Shit sucks and did not work.");
return;
}
diff --git a/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor.css b/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor.css
index 15998e9..3b0bbb0 100644
--- a/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor.css
+++ b/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor.css
@@ -37,4 +37,8 @@
.formContent{
text-align: left;
display: flex;
+}
+
+.postError{
+ color: #ff191c;
}
\ No newline at end of file
diff --git a/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor b/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor
index 203fa7d..2389009 100644
--- a/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor
+++ b/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor
@@ -37,14 +37,13 @@
-
-
-
-
- @if (hasErr)
+ @if (hasErr)
{
@postErr
}
+
+
+
@@ -101,7 +100,9 @@
int userID = foundusr.UserID;
if (foundusr.TimeBanned != -1)
{
-
+ hasErr = true;
+ postErr = "You are banned and may not post.";
+ //Maybe redirect to /banned?
return;
}
foundusr.lastActionTimeStamp = DateTimeOffset.UnixEpoch.ToUnixTimeMilliseconds();
@@ -112,6 +113,8 @@
if (selectedFile == null || selectedFile.Size >= 512000 * 4)
{
+ hasErr = true;
+ postErr = "You did not attach a file or the selected file is bigger then the 2MiB file limit.";
return;
}
@@ -150,7 +153,8 @@
else
{
//Open post unsucessfull
- NavigationManager.NavigateTo("/UnSuccessfulPost");
+ hasErr = true;
+ postErr = "There was an error and the post could not be created. Please notify the admin.";
Console.WriteLine("Shit sucks and did not work.");
}
}