feat: ban message now shows the ban reason and time when unbanned
Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
parent
bc1d632e4c
commit
3abc1ba7ab
4 changed files with 26 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
|||
@using System.ComponentModel.DataAnnotations
|
||||
@using ImageBoardServerApp.Auth
|
||||
@using ImageBoardServerApp.Data.Repository
|
||||
@using ImageBoardServerApp.Util
|
||||
@inject NavigationManager navigationManager
|
||||
@inject IWebHostEnvironment env
|
||||
@inject AuthenticationStateProvider authStateProvider
|
||||
|
@ -110,6 +111,12 @@
|
|||
postErr = "You are not logged in.";
|
||||
return;
|
||||
}
|
||||
if (!foundusr.ConfirmedEmail)
|
||||
{
|
||||
hasErr = true;
|
||||
postErr = "You cannot post without an verified email.";
|
||||
return;
|
||||
}
|
||||
int userID = foundusr.UserID;
|
||||
if (DateTimeOffset.Now.ToUnixTimeMilliseconds() - foundusr.TimeBanned < 0)
|
||||
{
|
||||
|
@ -118,9 +125,9 @@
|
|||
|
||||
if (foundusr.TimeBanned != -1)
|
||||
{
|
||||
var dt = TheManager.ConvertToDateTime(foundusr.TimeBanned);
|
||||
hasErr = true;
|
||||
postErr = "You are banned and may not comment.";
|
||||
//Maybe redirect to /banned?
|
||||
postErr = "You are banned for " + foundusr.BanReason + " and may not comment until " + dt.Year + "." + dt.Month + "." + dt.Day + " " + dt.Hour + ":" + dt.Minute + "::" + dt.Second;
|
||||
return;
|
||||
}
|
||||
foundusr.lastActionTimeStamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
|
|
|
@ -117,6 +117,12 @@
|
|||
postErr = "You are not logged in.";
|
||||
return;
|
||||
}
|
||||
if (!foundusr.ConfirmedEmail)
|
||||
{
|
||||
hasErr = true;
|
||||
postErr = "You cannot post without an verified email.";
|
||||
return;
|
||||
}
|
||||
int userID = foundusr.UserID;
|
||||
if (DateTimeOffset.Now.ToUnixTimeMilliseconds() - foundusr.TimeBanned < 0)
|
||||
{
|
||||
|
@ -125,9 +131,9 @@
|
|||
|
||||
if (foundusr.TimeBanned != -1)
|
||||
{
|
||||
var dt = TheManager.ConvertToDateTime(foundusr.TimeBanned);
|
||||
hasErr = true;
|
||||
postErr = "You are banned and may not post.";
|
||||
//Maybe redirect to /banned?
|
||||
postErr = "You are banned for " + foundusr.BanReason + " and may not post until " + dt.Year + "." + dt.Month + "." + dt.Day + " " + dt.Hour + ":" + dt.Minute + "::" + dt.Second;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,9 @@
|
|||
<option value="Admin">Admin</option>
|
||||
</select>
|
||||
<a onclick="@updateRole()" href="javascript:void(0)">Update Role</a>
|
||||
<br/>
|
||||
<span> </span>
|
||||
<a onclick="@unban()" href="javascript:void(0)">Unban (if banned)</a>
|
||||
<br/>
|
||||
<span> </span>
|
||||
<span>@user.Role</span>
|
||||
<br/>
|
||||
|
|
|
@ -106,4 +106,11 @@ public class TheManager
|
|||
|
||||
return BitConverter.ToString(bytes).Replace("-", "").ToLower();
|
||||
}
|
||||
|
||||
public static DateTime ConvertToDateTime(long timestamp)
|
||||
{
|
||||
DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
DateTime date = unixEpoch.AddSeconds(timestamp);
|
||||
return date;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue