fix: fixed auth issues
Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
parent
766e6054dc
commit
6630b4963e
11 changed files with 308 additions and 243 deletions
|
@ -8,14 +8,14 @@ namespace ImageBoardServerApp.Auth;
|
||||||
public class CustomAuthenticationStateProvider : AuthenticationStateProvider
|
public class CustomAuthenticationStateProvider : AuthenticationStateProvider
|
||||||
{
|
{
|
||||||
private readonly ProtectedLocalStorage _sessionStorage;
|
private readonly ProtectedLocalStorage _sessionStorage;
|
||||||
|
|
||||||
private ClaimsPrincipal _anonymous = new ClaimsPrincipal(new ClaimsIdentity());
|
private ClaimsPrincipal _anonymous = new ClaimsPrincipal(new ClaimsIdentity());
|
||||||
|
|
||||||
public CustomAuthenticationStateProvider(ProtectedLocalStorage sessionStorage)
|
public CustomAuthenticationStateProvider(ProtectedLocalStorage sessionStorage)
|
||||||
{
|
{
|
||||||
_sessionStorage = sessionStorage;
|
_sessionStorage = sessionStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<AuthenticationState> GetAuthenticationStateAsync()
|
public override async Task<AuthenticationState> GetAuthenticationStateAsync()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -30,11 +30,12 @@ public class CustomAuthenticationStateProvider : AuthenticationStateProvider
|
||||||
new Claim(ClaimTypes.Name, userSession.UserID.ToString()),
|
new Claim(ClaimTypes.Name, userSession.UserID.ToString()),
|
||||||
new Claim(ClaimTypes.Role, userSession.Role)
|
new Claim(ClaimTypes.Role, userSession.Role)
|
||||||
}, "CustomAuth"));
|
}, "CustomAuth"));
|
||||||
return await Task.FromResult(new AuthenticationState(claimsPrincipal));
|
return new AuthenticationState(claimsPrincipal);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
return await Task.FromResult(new AuthenticationState(_anonymous));
|
Console.WriteLine("Returned Anon Auth due to err");
|
||||||
|
return new AuthenticationState(_anonymous);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ public class CustomAuthenticationStateProvider : AuthenticationStateProvider
|
||||||
await _sessionStorage.DeleteAsync("UserSession");
|
await _sessionStorage.DeleteAsync("UserSession");
|
||||||
claimsPrincipal = _anonymous;
|
claimsPrincipal = _anonymous;
|
||||||
}
|
}
|
||||||
|
|
||||||
NotifyAuthenticationStateChanged(Task.FromResult(new AuthenticationState(claimsPrincipal)));
|
NotifyAuthenticationStateChanged(Task.FromResult(new AuthenticationState(claimsPrincipal)));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -13,7 +13,7 @@
|
||||||
<span>Email: @mail</span>
|
<span>Email: @mail</span>
|
||||||
<br/>
|
<br/>
|
||||||
<span>Email: </span>
|
<span>Email: </span>
|
||||||
<input type="email" id="email" @bind="newMail" />
|
<input type="email" id="email" @bind="newMail"/>
|
||||||
<a @onclick="changeEmail" href="javascript:void(0)">[Change Email]</a>
|
<a @onclick="changeEmail" href="javascript:void(0)">[Change Email]</a>
|
||||||
<br/>
|
<br/>
|
||||||
<a href="/sys/resetpw">[Change Password]</a>
|
<a href="/sys/resetpw">[Change Password]</a>
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
</AuthorizeView>
|
</AuthorizeView>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
|
||||||
private string mail { get; set; } = "";
|
private string mail { get; set; } = "";
|
||||||
private string newMail { get; set; }
|
private string newMail { get; set; }
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
mail = user.User.Identity.Name;
|
mail = user.User.Identity.Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task changeEmail()
|
private async Task changeEmail()
|
||||||
{
|
{
|
||||||
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
||||||
|
@ -51,7 +51,6 @@
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int userID = foundusr.UserID;
|
|
||||||
if (newMail == null || newMail == "" || !newMail.Contains("@"))
|
if (newMail == null || newMail == "" || !newMail.Contains("@"))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -60,4 +59,5 @@
|
||||||
foundusr.lastActionTimeStamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
foundusr.lastActionTimeStamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||||
await UsersRepository.updateUserAsync(foundusr);
|
await UsersRepository.updateUserAsync(foundusr);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
@page "/"
|
@page "/"
|
||||||
@using ImageBoardServerApp.Data.Repository
|
@using ImageBoardServerApp.Data.Repository
|
||||||
@using ImageBoardServerApp.Auth
|
|
||||||
@inject AuthenticationStateProvider authStateProvider
|
@inject AuthenticationStateProvider authStateProvider
|
||||||
|
|
||||||
<h1>BulletBoard</h1>
|
<h1>BulletBoard</h1>
|
||||||
|
@ -18,29 +17,20 @@
|
||||||
|
|
||||||
@code{
|
@code{
|
||||||
private string Details { get; set; }
|
private string Details { get; set; }
|
||||||
|
|
||||||
private int amountOfPosts = -1;
|
private int amountOfPosts = -1;
|
||||||
private int amountOfComments = -1;
|
private int amountOfComments = -1;
|
||||||
private int amountOfUsers = -1;
|
private int amountOfUsers = -1;
|
||||||
protected override async Task OnInitializedAsync()
|
|
||||||
|
protected override async Task OnParametersSetAsync()
|
||||||
{
|
{
|
||||||
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
|
||||||
var user = await cauthStateProvder.GetAuthenticationStateAsync();
|
|
||||||
if (user.User.Identity.IsAuthenticated)
|
|
||||||
{
|
|
||||||
var usr = user.User.Identity.Name;
|
|
||||||
Details = $"Welcome {usr}";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Details = "Please log in first.";
|
|
||||||
}
|
|
||||||
var posts = await PostsRepository.getPostsAsync();
|
var posts = await PostsRepository.getPostsAsync();
|
||||||
amountOfPosts = posts.Count;
|
amountOfPosts = posts.Count;
|
||||||
var comments = await CommentsRepository.getCommentsAsync();
|
var comments = await CommentsRepository.getCommentsAsync();
|
||||||
amountOfComments = comments.Count;
|
amountOfComments = comments.Count;
|
||||||
var users = await UsersRepository.getUsersAsync();
|
var users = await UsersRepository.getUsersAsync();
|
||||||
amountOfUsers = users.Count;
|
amountOfUsers = users.Count;
|
||||||
|
await base.OnParametersSetAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -6,7 +6,7 @@
|
||||||
<AuthorizeView Roles="Admin,Mod">
|
<AuthorizeView Roles="Admin,Mod">
|
||||||
<Authorized>
|
<Authorized>
|
||||||
<h3>ModMenu</h3>
|
<h3>ModMenu</h3>
|
||||||
<span>Welcome @mail to the mod menu</span>
|
<span>Welcome User #@mail to the mod menu</span>
|
||||||
<div>
|
<div>
|
||||||
<a href="/sys/modmenu/reports">[Reports]</a>
|
<a href="/sys/modmenu/reports">[Reports]</a>
|
||||||
<a href="/sys/modmenu/users">[Users]</a>
|
<a href="/sys/modmenu/users">[Users]</a>
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
<DeadLink/>
|
<DeadLink/>
|
||||||
</NotAuthorized>
|
</NotAuthorized>
|
||||||
</AuthorizeView>
|
</AuthorizeView>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string mail { get; set; } = "";
|
private string mail { get; set; } = "";
|
||||||
|
|
||||||
|
@ -29,4 +30,10 @@
|
||||||
mail = user.User.Identity.Name;
|
mail = user.User.Identity.Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
await base.OnAfterRenderAsync(firstRender);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -6,104 +6,101 @@
|
||||||
@inject AuthenticationStateProvider authStateProvider
|
@inject AuthenticationStateProvider authStateProvider
|
||||||
<div class="comment">
|
<div class="comment">
|
||||||
<div class="threadHeader">
|
<div class="threadHeader">
|
||||||
<span>[</span>
|
<span>[</span>
|
||||||
<a class="toggleOpened" onclick="@ToggleOpened">@toggleText</a>
|
<a class="toggleOpened" onclick="@ToggleOpened">@toggleText</a>
|
||||||
<span>]</span>
|
<span>]</span>
|
||||||
<span class="name">@comment.Username</span>
|
<span class="name">@comment.Username</span>
|
||||||
@if (@role != "User")
|
@if (@role != "User")
|
||||||
{
|
|
||||||
<span class="@role" >##@role</span>
|
|
||||||
}
|
|
||||||
<span class="date">@getTimeFromUnix(comment.CreatedAt)</span>
|
|
||||||
<span class="post-id">No.@comment.GET</span>
|
|
||||||
</div>
|
|
||||||
@if (opened)
|
|
||||||
{
|
|
||||||
<div class="threadContent">
|
|
||||||
@if (image != null)
|
|
||||||
{
|
{
|
||||||
string isActiveClass = isActive ? "active" : "";
|
<span class="@role">##@role</span>
|
||||||
<div class="threadImage">
|
|
||||||
<img @onclick="() => isActive = !isActive" class="@isActiveClass" src="@($"{@image.ImageLocation}?size=258x258")" alt="No Image found" />
|
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
<div class="threadTextContainer">
|
<span class="date">@getTimeFromUnix(comment.CreatedAt)</span>
|
||||||
@for (var y = 0; y < comment.Content.Split("\n").Length; y++)
|
<span class="post-id">No.@comment.GET</span>
|
||||||
|
</div>
|
||||||
|
@if (opened)
|
||||||
|
{
|
||||||
|
<div class="threadContent">
|
||||||
|
@if (image != null)
|
||||||
{
|
{
|
||||||
var s = comment.Content.Split("\n")[y];
|
string isActiveClass = isActive ? "active" : "";
|
||||||
var className = "";
|
<div class="threadImage">
|
||||||
|
<img @onclick="() => isActive = !isActive" class="@isActiveClass" src="@($"{@image.ImageLocation}?size=258x258")" alt="No Image found"/>
|
||||||
@if (s.StartsWith(">") && !Regex.IsMatch(s, "^>{2,}"))
|
</div>
|
||||||
|
}
|
||||||
|
<div class="threadTextContainer">
|
||||||
|
@for (var y = 0; y < comment.Content.Split("\n").Length; y++)
|
||||||
{
|
{
|
||||||
className = "greenText";
|
var s = comment.Content.Split("\n")[y];
|
||||||
}
|
var className = "";
|
||||||
<span class='threadText @className'>
|
|
||||||
@for (var x = 0; x < s.Split(" ").Length; x++)
|
@if (s.StartsWith(">") && !Regex.IsMatch(s, "^>{2,}"))
|
||||||
{
|
{
|
||||||
var line = s.Split(" ")[x];
|
className = "greenText";
|
||||||
@if (@Regex.IsMatch(line, ">>\\d+"))
|
}
|
||||||
|
<span class='threadText @className'>
|
||||||
|
@for (var x = 0; x < s.Split(" ").Length; x++)
|
||||||
{
|
{
|
||||||
var className2 = "";
|
var line = s.Split(" ")[x];
|
||||||
var x1 = x;
|
@if (@Regex.IsMatch(line, ">>\\d+"))
|
||||||
var y1 = y;
|
|
||||||
var commentNumber = int.Parse(Regex.Match(s, ">>(\\d+)").Value.Substring(2));
|
|
||||||
className2 = "redText";
|
|
||||||
<span
|
|
||||||
@onmouseenter="() => onHover(x1, y1, commentNumber)"
|
|
||||||
@onmouseleave="() => onHover(x1, y1, -1)" class="threadMsg @className2"
|
|
||||||
>
|
|
||||||
@line
|
|
||||||
</span>
|
|
||||||
@if (hoveringOver.p != -1 && hoveringOver == (x, y, commentNumber) && (hoverComment.ContainsKey(commentNumber) || hoverPost.ContainsKey(commentNumber)))
|
|
||||||
{
|
{
|
||||||
@if (isComment[commentNumber])
|
var className2 = "";
|
||||||
|
var x1 = x;
|
||||||
|
var y1 = y;
|
||||||
|
var commentNumber = int.Parse(Regex.Match(s, ">>(\\d+)").Value.Substring(2));
|
||||||
|
className2 = "redText";
|
||||||
|
<span
|
||||||
|
@onmouseenter="() => onHover(x1, y1, commentNumber)"
|
||||||
|
@onmouseleave="() => onHover(x1, y1, -1)" class="threadMsg @className2">
|
||||||
|
@line
|
||||||
|
</span>
|
||||||
|
@if (hoveringOver.p != -1 && hoveringOver == (x, y, commentNumber) && (hoverComment.ContainsKey(commentNumber) || hoverPost.ContainsKey(commentNumber)))
|
||||||
{
|
{
|
||||||
<div>
|
@if (isComment[commentNumber])
|
||||||
<CommentHover comment="hoverComment[commentNumber]"/>
|
{
|
||||||
</div>
|
<div>
|
||||||
}
|
<CommentHover comment="hoverComment[commentNumber]"/>
|
||||||
else
|
</div>
|
||||||
{
|
}
|
||||||
<div>
|
else
|
||||||
<Post post="hoverPost[commentNumber]" showOpenThread="false"/>
|
{
|
||||||
</div>
|
<div>
|
||||||
|
<Post post="hoverPost[commentNumber]" showOpenThread="false"/>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<span class="threadMsg">
|
||||||
|
@line
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
<span> </span>
|
||||||
}
|
}
|
||||||
else
|
</span>
|
||||||
{
|
}
|
||||||
<span class="threadMsg">
|
</div>
|
||||||
@line
|
|
||||||
</span>
|
|
||||||
}
|
|
||||||
<span> </span>
|
|
||||||
|
|
||||||
}
|
|
||||||
</span>
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="threadFooter">
|
||||||
<div class="threadFooter">
|
<span>[</span>
|
||||||
<span>[</span>
|
<a class="repButton" href="@reportURL" target="_blank">Report</a>
|
||||||
<a class="repButton" href="@reportURL" target="_blank">Report</a>
|
@if (canDel)
|
||||||
@if (canDel)
|
{
|
||||||
{
|
<button class="delButton" onclick="@deletePost">Delete</button>
|
||||||
<button class="delButton" onclick="@deletePost">Delete</button>
|
}
|
||||||
}
|
<span>]</span>
|
||||||
<span>]</span>
|
</div>
|
||||||
</div>
|
}
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string reportURL { get; set; }
|
private string reportURL { get; set; }
|
||||||
|
|
||||||
private bool isActive { get; set; } = false;
|
private bool isActive { get; set; } = false;
|
||||||
|
|
||||||
private (int x, int y, int p) hoveringOver { get; set; } = (-1, -1, -1);
|
private (int x, int y, int p) hoveringOver { get; set; } = (-1, -1, -1);
|
||||||
private Dictionary<int, bool> isComment{ get; set; }
|
private Dictionary<int, bool> isComment { get; set; }
|
||||||
private Dictionary<int, CommentData> hoverComment { get; set; }
|
private Dictionary<int, CommentData> hoverComment { get; set; }
|
||||||
private Dictionary<int, PostData> hoverPost { get; set; }
|
private Dictionary<int, PostData> hoverPost { get; set; }
|
||||||
private Dictionary<int, int> nrToGet { get; set; }
|
private Dictionary<int, int> nrToGet { get; set; }
|
||||||
|
@ -112,13 +109,13 @@
|
||||||
{
|
{
|
||||||
if (hoverComment.ContainsKey(p) || hoverPost.ContainsKey(p))
|
if (hoverComment.ContainsKey(p) || hoverPost.ContainsKey(p))
|
||||||
{
|
{
|
||||||
hoveringOver= (x, y, -1);
|
hoveringOver = (x, y, -1);
|
||||||
}
|
}
|
||||||
hoveringOver = (x, y, p);
|
hoveringOver = (x, y, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool canDel { get; set; }
|
public bool canDel { get; set; } = false;
|
||||||
|
|
||||||
private async Task deletePost()
|
private async Task deletePost()
|
||||||
{
|
{
|
||||||
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
||||||
|
@ -130,12 +127,12 @@
|
||||||
await TheManager.deleteComment(comment);
|
await TheManager.deleteComment(comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static DateTime getTimeFromUnix(double javaTimeStamp)
|
private static DateTime getTimeFromUnix(double javaTimeStamp)
|
||||||
{
|
{
|
||||||
var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||||
dateTime = dateTime.AddMilliseconds( javaTimeStamp ).ToLocalTime();
|
dateTime = dateTime.AddMilliseconds(javaTimeStamp).ToLocalTime();
|
||||||
return dateTime;
|
return dateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,20 +142,8 @@
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
{
|
{
|
||||||
await base.OnParametersSetAsync();
|
await base.OnParametersSetAsync();
|
||||||
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
|
||||||
var user = await cauthStateProvder.GetAuthenticationStateAsync();
|
|
||||||
var usr = user.User;
|
|
||||||
UserData foundusr = await UsersRepository.getUserByIdAsync(int.Parse(usr.Identity.Name));
|
|
||||||
if (foundusr != null && (foundusr.Role != "User" || comment.UserID == foundusr.UserID))
|
|
||||||
{
|
|
||||||
canDel = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
canDel = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
hoverComment = new Dictionary<int, CommentData>();
|
hoverComment = new Dictionary<int, CommentData>();
|
||||||
hoverPost = new Dictionary<int, PostData>();
|
hoverPost = new Dictionary<int, PostData>();
|
||||||
nrToGet = new Dictionary<int, int>();
|
nrToGet = new Dictionary<int, int>();
|
||||||
|
@ -196,6 +181,23 @@
|
||||||
reportURL = $"/sys/report/comment/{comment.Board}/{comment.CommentID}";
|
reportURL = $"/sys/report/comment/{comment.Board}/{comment.CommentID}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
||||||
|
var user = await cauthStateProvder.GetAuthenticationStateAsync();
|
||||||
|
var usr = user.User;
|
||||||
|
UserData foundusr = await UsersRepository.getUserByIdAsync(int.Parse(usr.Identity.Name));
|
||||||
|
if (foundusr != null && (foundusr.Role != "User" || comment.UserID == foundusr.UserID))
|
||||||
|
{
|
||||||
|
canDel = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
canDel = false;
|
||||||
|
}
|
||||||
|
await base.OnAfterRenderAsync(firstRender);
|
||||||
|
}
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -215,7 +217,7 @@
|
||||||
var cmt = await CommentsRepository.getCommentByIdAsync(comment.CommentID);
|
var cmt = await CommentsRepository.getCommentByIdAsync(comment.CommentID);
|
||||||
role = cmt.User.Role;
|
role = cmt.User.Role;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool opened = true;
|
private bool opened = true;
|
||||||
|
|
||||||
private string toggleText = "-";
|
private string toggleText = "-";
|
||||||
|
@ -228,6 +230,7 @@
|
||||||
|
|
||||||
private string toggleText2 = "-";
|
private string toggleText2 = "-";
|
||||||
private bool showHover = false;
|
private bool showHover = false;
|
||||||
|
|
||||||
private void ToggleHovered(MouseEventArgs e, string id)
|
private void ToggleHovered(MouseEventArgs e, string id)
|
||||||
{
|
{
|
||||||
showHover = !showHover;
|
showHover = !showHover;
|
||||||
|
@ -237,4 +240,5 @@
|
||||||
[Parameter]
|
[Parameter]
|
||||||
[Required]
|
[Required]
|
||||||
public CommentData comment { get; set; }
|
public CommentData comment { get; set; }
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,57 +1,60 @@
|
||||||
@using System.Text.RegularExpressions
|
|
||||||
@using ImageBoardServerApp.Data.Repository
|
@using ImageBoardServerApp.Data.Repository
|
||||||
@using System.ComponentModel.DataAnnotations
|
@using System.ComponentModel.DataAnnotations
|
||||||
<span class="name">@comment.Username</span>
|
@using System.Text.RegularExpressions
|
||||||
@if (@role != "User")
|
<div class="comment">
|
||||||
{
|
|
||||||
<span class="@role" >##@role </span>
|
<span class="name">@comment.Username</span>
|
||||||
}
|
@if (@role != "User")
|
||||||
else
|
{
|
||||||
{
|
<span class="@role">##@role </span>
|
||||||
<span> </span>
|
}
|
||||||
}
|
else
|
||||||
<span class="date">@getTimeFromUnix(comment.CreatedAt)</span>
|
{
|
||||||
<span class="post-id">No.@comment.GET</span>
|
<span> </span>
|
||||||
<div class="threadContent">
|
}
|
||||||
<div class="threadImage">
|
<span class="date">@getTimeFromUnix(comment.CreatedAt)</span>
|
||||||
|
<span class="post-id">No.@comment.GET</span>
|
||||||
|
<div class="threadContent">
|
||||||
@if (image != null)
|
@if (image != null)
|
||||||
{
|
{
|
||||||
<img src="@($"{image.ImageLocation}?size=258x258")" alt="No Image found" />
|
<div class="threadImage">
|
||||||
|
<img src="@($"{image.ImageLocation}?size=258x258")" alt="No Image found"/>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
<div class="threadTextContainer">
|
||||||
<div class="threadTextContainer">
|
@foreach (string s in @comment.Content.Split("\n"))
|
||||||
@foreach (string s in @comment.Content.Split("\n"))
|
|
||||||
{
|
|
||||||
var className = "";
|
|
||||||
@if (s.StartsWith(">") && !Regex.IsMatch(s, "^>{2,}"))
|
|
||||||
{
|
{
|
||||||
className = "greenText";
|
var className = "";
|
||||||
}
|
@if (s.StartsWith(">") && !Regex.IsMatch(s, "^>{2,}"))
|
||||||
|
|
||||||
<span class='threadText @className'>
|
|
||||||
@foreach (string line in s.Split(" "))
|
|
||||||
{
|
{
|
||||||
var className2 = "";
|
className = "greenText";
|
||||||
@if (@Regex.IsMatch(line, ">>\\d+"))
|
|
||||||
{
|
|
||||||
className2 = "redText";
|
|
||||||
<a href="/@comment.Board/@comment.PostID/@Regex.Match(s, ">>(\\d+)").Value.Substring(2)" class="threadMsg @className2">
|
|
||||||
@line
|
|
||||||
</a>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<span class="threadMsg">
|
|
||||||
@line
|
|
||||||
</span>
|
|
||||||
}
|
|
||||||
<span> </span>
|
|
||||||
|
|
||||||
}
|
}
|
||||||
</span>
|
|
||||||
}
|
<span class='threadText @className'>
|
||||||
</div>
|
@foreach (string line in s.Split(" "))
|
||||||
|
{
|
||||||
|
var className2 = "";
|
||||||
|
@if (@Regex.IsMatch(line, ">>\\d+"))
|
||||||
|
{
|
||||||
|
className2 = "redText";
|
||||||
|
<a href="/@comment.Board/@comment.PostID/@Regex.Match(s, ">>(\\d+)").Value.Substring(2)" class="threadMsg @className2">
|
||||||
|
@line
|
||||||
|
</a>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<span class="threadMsg">
|
||||||
|
@line
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
<span> </span>
|
||||||
|
}
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private ImageData image;
|
private ImageData image;
|
||||||
private string role;
|
private string role;
|
||||||
|
@ -59,10 +62,10 @@ else
|
||||||
private static DateTime getTimeFromUnix(double javaTimeStamp)
|
private static DateTime getTimeFromUnix(double javaTimeStamp)
|
||||||
{
|
{
|
||||||
var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||||
dateTime = dateTime.AddMilliseconds( javaTimeStamp ).ToLocalTime();
|
dateTime = dateTime.AddMilliseconds(javaTimeStamp).ToLocalTime();
|
||||||
return dateTime;
|
return dateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
|
@ -87,4 +90,5 @@ else
|
||||||
[Parameter]
|
[Parameter]
|
||||||
[Required]
|
[Required]
|
||||||
public CommentData comment { get; set; }
|
public CommentData comment { get; set; }
|
||||||
|
|
||||||
}
|
}
|
|
@ -27,6 +27,9 @@
|
||||||
|
|
||||||
.threadHeader{
|
.threadHeader{
|
||||||
text-align: left;
|
text-align: left;
|
||||||
|
background-color: #241938;
|
||||||
|
border-bottom: 2px solid #2d2a42;
|
||||||
|
margin-inside: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.threadFooter{
|
.threadFooter{
|
||||||
|
@ -43,11 +46,13 @@
|
||||||
color: #50fa7b;
|
color: #50fa7b;
|
||||||
}
|
}
|
||||||
|
|
||||||
.threadImage{
|
.threadImage {
|
||||||
margin: 6px;
|
margin: 6px;
|
||||||
max-width: 500px;
|
max-width: 500px;
|
||||||
max-height: 500px;
|
max-height: 500px;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
|
border: 1px solid #2d2a42;
|
||||||
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.threadImage img{
|
.threadImage img{
|
||||||
|
@ -56,7 +61,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.threadImage img.active{
|
.threadImage img.active{
|
||||||
/*transform: scale(3);*/
|
|
||||||
max-width:500px;
|
max-width:500px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
@ -70,10 +74,65 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.Admin{
|
.Admin {
|
||||||
color: #ff5555;
|
color: #ff5555;
|
||||||
}
|
}
|
||||||
|
|
||||||
.Mod{
|
.Mod {
|
||||||
color: #bd93f9;
|
color: #bd93f9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comment {
|
||||||
|
border: 2px solid #2d2a42;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.threadFooter button {
|
||||||
|
border: none;
|
||||||
|
color: white;
|
||||||
|
padding: 4px 8px;
|
||||||
|
text-align: center;
|
||||||
|
text-decoration: none;
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 16px;
|
||||||
|
margin: 4px 2px;
|
||||||
|
transition-duration: 0.4s;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.threadFooter a {
|
||||||
|
border: none;
|
||||||
|
color: white;
|
||||||
|
padding: 4px 8px;
|
||||||
|
text-align: center;
|
||||||
|
text-decoration: none;
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 16px;
|
||||||
|
margin: 4px 2px;
|
||||||
|
transition-duration: 0.4s;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.delButton {
|
||||||
|
background-color: #433F6B;
|
||||||
|
color: white;
|
||||||
|
border: 2px solid #ff5555;
|
||||||
|
}
|
||||||
|
|
||||||
|
.delButton:hover {
|
||||||
|
background-color: #ff5555;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.repButton {
|
||||||
|
background-color: #433F6B;
|
||||||
|
color: white;
|
||||||
|
border: 2px solid #ffa255;
|
||||||
|
}
|
||||||
|
|
||||||
|
.repButton:hover {
|
||||||
|
background-color: #ffa255;
|
||||||
|
color: white;
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
{
|
{
|
||||||
<div class="pd centered">
|
<div class="pd centered">
|
||||||
<span>Comment on @post.Title in /@post.Board/</span>
|
<span>Comment on @post.Title in /@post.Board/</span>
|
||||||
|
|
||||||
<div class="centered formContent">
|
<div class="centered formContent">
|
||||||
<div>
|
<div>
|
||||||
<div class="pd centered marg">
|
<div class="pd centered marg">
|
||||||
|
@ -22,14 +22,14 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="pd centered marg">
|
<div class="pd centered marg">
|
||||||
<RadzenTextArea Placeholder="Comment..." @bind-Value="@postContent" Cols="30" Rows="6" Class="w-100"/>
|
<RadzenTextArea Placeholder="Comment..." @bind-Value="@postContent" Cols="30" Rows="6" Class="w-100"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@if (hasErr)
|
@if (hasErr)
|
||||||
{
|
{
|
||||||
<span class="postError">@postErr</span>
|
<span class="postError">@postErr</span>
|
||||||
}
|
}
|
||||||
<div class="pd centered marg">
|
<div class="pd centered marg">
|
||||||
<FormInfo/>
|
<FormInfo/>
|
||||||
<InputFile OnChange="@SingleUpload" type="file" accept="image/*"/>
|
<InputFile OnChange="@SingleUpload" type="file" accept="image/*"/>
|
||||||
|
@ -58,7 +58,7 @@
|
||||||
string postUsername { get; set; }
|
string postUsername { get; set; }
|
||||||
string postContent { get; set; } = "";
|
string postContent { get; set; } = "";
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
{
|
{
|
||||||
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
||||||
var user = await cauthStateProvder.GetAuthenticationStateAsync();
|
var user = await cauthStateProvder.GetAuthenticationStateAsync();
|
||||||
|
@ -71,17 +71,17 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
postUsername = foundusr.LastUsedName;
|
postUsername = foundusr.LastUsedName;
|
||||||
await base.OnParametersSetAsync();
|
await base.OnAfterRenderAsync(firstRender);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IBrowserFile selectedFile;
|
private IBrowserFile selectedFile;
|
||||||
|
|
||||||
private async Task SingleUpload(InputFileChangeEventArgs e)
|
private async Task SingleUpload(InputFileChangeEventArgs e)
|
||||||
{
|
{
|
||||||
selectedFile = e.GetMultipleFiles()[0];
|
selectedFile = e.GetMultipleFiles()[0];
|
||||||
this.StateHasChanged();
|
this.StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
string postErr { get; set; }
|
string postErr { get; set; }
|
||||||
bool hasErr { get; set; } = false;
|
bool hasErr { get; set; } = false;
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@
|
||||||
{
|
{
|
||||||
hasErr = true;
|
hasErr = true;
|
||||||
postErr = "You are banned and may not comment.";
|
postErr = "You are banned and may not comment.";
|
||||||
//Maybe redirect to /banned?
|
//Maybe redirect to /banned?
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
foundusr.lastActionTimeStamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
foundusr.lastActionTimeStamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||||
|
@ -148,7 +148,7 @@
|
||||||
await stream.CopyToAsync(fs);
|
await stream.CopyToAsync(fs);
|
||||||
stream.Close();
|
stream.Close();
|
||||||
fs.Close();
|
fs.Close();
|
||||||
|
|
||||||
var imageToUpload = new ImageData
|
var imageToUpload = new ImageData
|
||||||
{
|
{
|
||||||
Board = post.Board,
|
Board = post.Board,
|
||||||
|
@ -184,16 +184,17 @@
|
||||||
int commentId = await CommentsRepository.createCommentAsync(commentToCreate);
|
int commentId = await CommentsRepository.createCommentAsync(commentToCreate);
|
||||||
if (commentId == -1)
|
if (commentId == -1)
|
||||||
{
|
{
|
||||||
//Open comment unsucessfull
|
//Open comment unsucessfull
|
||||||
navigationManager.NavigateTo("/sys/UnSuccessfulPost");
|
navigationManager.NavigateTo("/sys/UnSuccessfulPost");
|
||||||
hasErr = true;
|
hasErr = true;
|
||||||
postErr = "There was an error and the comment could not be created. Please notify the admin.";
|
postErr = "There was an error and the comment could not be created. Please notify the admin.";
|
||||||
Console.WriteLine("Shit sucks and did not work.");
|
Console.WriteLine("Shit sucks and did not work.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//comment successfull
|
//comment successfull
|
||||||
Console.WriteLine("Post created");
|
Console.WriteLine("Post created");
|
||||||
navigationManager.NavigateTo($"/{post.Board}/thread/{post.PostID}", true, true);
|
navigationManager.NavigateTo($"/{post.Board}/thread/{post.PostID}", true, true);
|
||||||
opened = false;
|
opened = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -17,15 +17,15 @@
|
||||||
<span>Post to /@board.Tag/ - @board.Topic</span>
|
<span>Post to /@board.Tag/ - @board.Topic</span>
|
||||||
<div class="centered formContent">
|
<div class="centered formContent">
|
||||||
<div>
|
<div>
|
||||||
<div class="pd centered marg">
|
<div class="pd centered marg">
|
||||||
<RadzenTextBox Placeholder="Username (Anonymous)" MaxLength="15" @bind-Value="@postUsername" Class="w-100"/>
|
<RadzenTextBox Placeholder="Username (Anonymous)" MaxLength="15" @bind-Value="@postUsername" Class="w-100"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="pd centered marg">
|
<div class="pd centered marg">
|
||||||
<RadzenTextBox Placeholder="Title" MaxLength="128" @bind-Value="@postTitle" Class="w-100"/>
|
<RadzenTextBox Placeholder="Title" MaxLength="128" @bind-Value="@postTitle" Class="w-100"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="pd centered marg">
|
<div class="pd centered marg">
|
||||||
<RadzenTextArea Placeholder="Content..." @bind-Value="@postContent" Cols="30" Rows="6" Class="w-100"/>
|
<RadzenTextArea Placeholder="Content..." @bind-Value="@postContent" Cols="30" Rows="6" Class="w-100"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
<InputFile OnChange="@SingleUpload" type="file" accept="image/*"/>
|
<InputFile OnChange="@SingleUpload" type="file" accept="image/*"/>
|
||||||
<RadzenButton class="pd" Click="@onPostClick" Text="Post!"></RadzenButton>
|
<RadzenButton class="pd" Click="@onPostClick" Text="Post!"></RadzenButton>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
string postTitle { get; set; } = "";
|
string postTitle { get; set; } = "";
|
||||||
string postContent { get; set; } = "";
|
string postContent { get; set; } = "";
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
{
|
{
|
||||||
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
||||||
var user = await cauthStateProvder.GetAuthenticationStateAsync();
|
var user = await cauthStateProvder.GetAuthenticationStateAsync();
|
||||||
|
@ -77,13 +77,12 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
postUsername = foundusr.LastUsedName;
|
postUsername = foundusr.LastUsedName;
|
||||||
await base.OnParametersSetAsync();
|
await base.OnAfterRenderAsync(firstRender);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private IBrowserFile selectedFile;
|
private IBrowserFile selectedFile;
|
||||||
|
|
||||||
|
|
||||||
private async Task SingleUpload(InputFileChangeEventArgs e)
|
private async Task SingleUpload(InputFileChangeEventArgs e)
|
||||||
{
|
{
|
||||||
selectedFile = e.GetMultipleFiles()[0];
|
selectedFile = e.GetMultipleFiles()[0];
|
||||||
|
@ -110,15 +109,15 @@
|
||||||
{
|
{
|
||||||
foundusr.TimeBanned = -1;
|
foundusr.TimeBanned = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (foundusr.TimeBanned != -1)
|
if (foundusr.TimeBanned != -1)
|
||||||
{
|
{
|
||||||
hasErr = true;
|
hasErr = true;
|
||||||
postErr = "You are banned and may not post.";
|
postErr = "You are banned and may not post.";
|
||||||
//Maybe redirect to /banned?
|
//Maybe redirect to /banned?
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BoardData b = await BoardsRepository.getBoardByTagAsync(board.Tag);
|
BoardData b = await BoardsRepository.getBoardByTagAsync(board.Tag);
|
||||||
if (b.isLocked)
|
if (b.isLocked)
|
||||||
{
|
{
|
||||||
|
@ -126,7 +125,7 @@
|
||||||
postErr = "This board is currently locked.";
|
postErr = "This board is currently locked.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foundusr.lastActionTimeStamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
foundusr.lastActionTimeStamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||||
if (postUsername == null || postUsername == "")
|
if (postUsername == null || postUsername == "")
|
||||||
{
|
{
|
||||||
|
@ -134,17 +133,17 @@
|
||||||
}
|
}
|
||||||
foundusr.LastUsedName = postUsername;
|
foundusr.LastUsedName = postUsername;
|
||||||
await UsersRepository.updateUserAsync(foundusr);
|
await UsersRepository.updateUserAsync(foundusr);
|
||||||
|
|
||||||
|
|
||||||
//TODO Add check if data is image
|
//TODO Add check if data is image
|
||||||
|
|
||||||
if (selectedFile == null || selectedFile.Size >= 512000 * 4)
|
if (selectedFile == null || selectedFile.Size >= 512000 * 4)
|
||||||
{
|
{
|
||||||
hasErr = true;
|
hasErr = true;
|
||||||
postErr = "You did not attach a file or the selected file is bigger then the 2MiB file limit.";
|
postErr = "You did not attach a file or the selected file is bigger then the 2MiB file limit.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream stream = selectedFile.OpenReadStream(maxAllowedSize: 512000 * 8); // max 4MB
|
Stream stream = selectedFile.OpenReadStream(maxAllowedSize: 512000 * 8); // max 4MB
|
||||||
var file = Path.GetRandomFileName() + "." + selectedFile.Name.Split(".")[selectedFile.Name.Split(".").Length - 1];
|
var file = Path.GetRandomFileName() + "." + selectedFile.Name.Split(".")[selectedFile.Name.Split(".").Length - 1];
|
||||||
var path = $"{env.WebRootPath}/img/dynamic/op/{@board.Tag}/{@file}";
|
var path = $"{env.WebRootPath}/img/dynamic/op/{@board.Tag}/{@file}";
|
||||||
|
@ -152,7 +151,7 @@
|
||||||
await stream.CopyToAsync(fs);
|
await stream.CopyToAsync(fs);
|
||||||
stream.Close();
|
stream.Close();
|
||||||
fs.Close();
|
fs.Close();
|
||||||
|
|
||||||
var imageToUpload = new ImageData
|
var imageToUpload = new ImageData
|
||||||
{
|
{
|
||||||
Board = board.Tag,
|
Board = board.Tag,
|
||||||
|
@ -163,7 +162,7 @@
|
||||||
int thisGET = b.NumberOfGETs + 1;
|
int thisGET = b.NumberOfGETs + 1;
|
||||||
b.NumberOfGETs++;
|
b.NumberOfGETs++;
|
||||||
await BoardsRepository.updateBoardAsync(b);
|
await BoardsRepository.updateBoardAsync(b);
|
||||||
|
|
||||||
var postToPost = new PostData
|
var postToPost = new PostData
|
||||||
{
|
{
|
||||||
UserID = userID,
|
UserID = userID,
|
||||||
|
@ -181,17 +180,18 @@
|
||||||
int postId = await PostsRepository.createPostAsync(postToPost);
|
int postId = await PostsRepository.createPostAsync(postToPost);
|
||||||
if (postId != -1)
|
if (postId != -1)
|
||||||
{
|
{
|
||||||
//Open post successfull
|
//Open post successfull
|
||||||
NavigationManager.NavigateTo($"/{board.Tag}/thread/{postId}", true, true);
|
NavigationManager.NavigateTo($"/{board.Tag}/thread/{postId}", true, true);
|
||||||
await TheManager.bumpThreads(board);
|
await TheManager.bumpThreads(board);
|
||||||
Console.WriteLine("Post created");
|
Console.WriteLine("Post created");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Open post unsucessfull
|
//Open post unsucessfull
|
||||||
hasErr = true;
|
hasErr = true;
|
||||||
postErr = "There was an error and the post could not be created. Please notify the admin.";
|
postErr = "There was an error and the post could not be created. Please notify the admin.";
|
||||||
Console.WriteLine("Shit sucks and did not work.");
|
Console.WriteLine("Shit sucks and did not work.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,9 +18,9 @@
|
||||||
<span class="title">@post.Title</span>
|
<span class="title">@post.Title</span>
|
||||||
<span class="name">@post.Username </span>
|
<span class="name">@post.Username </span>
|
||||||
@if (post.User.Role != "User")
|
@if (post.User.Role != "User")
|
||||||
{
|
{
|
||||||
<span class="@post.User.Role">##@post.User.Role </span>
|
<span class="@post.User.Role">##@post.User.Role </span>
|
||||||
}
|
}
|
||||||
<span> </span>
|
<span> </span>
|
||||||
<span class="date"> @getTimeFromUnix(post.CreatedAt)</span>
|
<span class="date"> @getTimeFromUnix(post.CreatedAt)</span>
|
||||||
<span class="post-id">No.@post.GET</span>
|
<span class="post-id">No.@post.GET</span>
|
||||||
|
@ -33,14 +33,14 @@
|
||||||
<img src="img/static/sys/locked.png" alt="Locked"/>
|
<img src="img/static/sys/locked.png" alt="Locked"/>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@if (opened)
|
@if (opened)
|
||||||
{
|
{
|
||||||
<div class="threadContent">
|
<div class="threadContent">
|
||||||
<div class="threadImage">
|
<div class="threadImage">
|
||||||
@if (@post.Image != null)
|
@if (@post.Image != null)
|
||||||
{
|
{
|
||||||
string isActiveClass = isActive ? "active" : "";
|
string isActiveClass = isActive ? "active" : "";
|
||||||
<img @onclick="() => isActive = !isActive" class="@isActiveClass" src="@($"{@post.Image.ImageLocation}?size=258x258")" alt="No Image found" />
|
<img @onclick="() => isActive = !isActive" class="@isActiveClass" src="@($"{@post.Image.ImageLocation}?size=258x258")" alt="No Image found"/>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
className = "greenText";
|
className = "greenText";
|
||||||
}
|
}
|
||||||
<span class='threadText @className'>@s </span>
|
<span class='threadText @className'>@s </span>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -127,11 +127,11 @@
|
||||||
private string threadURL { get; set; }
|
private string threadURL { get; set; }
|
||||||
private string openThreadName { get; set; }
|
private string openThreadName { get; set; }
|
||||||
|
|
||||||
public bool canDel { get; set; }
|
public bool canDel { get; set; } = false;
|
||||||
public bool isActive { get; set; } = false;
|
public bool isActive { get; set; } = false;
|
||||||
|
|
||||||
private int linecnt = 0;
|
private int linecnt = 0;
|
||||||
|
|
||||||
private async void lockMe()
|
private async void lockMe()
|
||||||
{
|
{
|
||||||
post.IsLocked = !post.IsLocked;
|
post.IsLocked = !post.IsLocked;
|
||||||
|
@ -143,11 +143,11 @@
|
||||||
post.IsSticky = !post.IsSticky;
|
post.IsSticky = !post.IsSticky;
|
||||||
await PostsRepository.updatePostAsync(post);
|
await PostsRepository.updatePostAsync(post);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DateTime getTimeFromUnix(double javaTimeStamp)
|
private static DateTime getTimeFromUnix(double javaTimeStamp)
|
||||||
{
|
{
|
||||||
var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||||
dateTime = dateTime.AddMilliseconds( javaTimeStamp ).ToLocalTime();
|
dateTime = dateTime.AddMilliseconds(javaTimeStamp).ToLocalTime();
|
||||||
return dateTime;
|
return dateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,34 +178,45 @@
|
||||||
toggleText = opened ? "-" : "+";
|
toggleText = opened ? "-" : "+";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int usrid { get; set; }
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
await base.OnParametersSetAsync();
|
|
||||||
value = TheManager.getBumpValue(post) + "v";
|
value = TheManager.getBumpValue(post) + "v";
|
||||||
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
|
||||||
var user = await cauthStateProvder.GetAuthenticationStateAsync();
|
|
||||||
var usr = user.User;
|
|
||||||
UserData foundusr = await UsersRepository.getUserByIdAsync(int.Parse(usr.Identity.Name));
|
|
||||||
|
|
||||||
reportURL = $"/sys/report/op/{post.Board}/{post.PostID}";
|
reportURL = $"/sys/report/op/{post.Board}/{post.PostID}";
|
||||||
threadURL = $"/{post.Board}/thread/{post.PostID}";
|
threadURL = $"/{post.Board}/thread/{post.PostID}";
|
||||||
openThreadName = $"({post.Comments.Count}) View Thread";
|
openThreadName = $"({post.Comments.Count}) View Thread";
|
||||||
|
|
||||||
|
await base.OnInitializedAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task SetParametersAsync(ParameterView parameters)
|
||||||
|
{
|
||||||
|
if (usrid == null)
|
||||||
|
{
|
||||||
|
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
||||||
|
var user = await cauthStateProvder.GetAuthenticationStateAsync();
|
||||||
|
usrid = int.Parse(user.User.Identity.Name);
|
||||||
|
}
|
||||||
|
UserData foundusr = await UsersRepository.getUserByIdAsync(usrid);
|
||||||
if (foundusr != null && (foundusr.Role != "User" || post.UserID == foundusr.UserID))
|
if (foundusr != null && (foundusr.Role != "User" || post.UserID == foundusr.UserID))
|
||||||
{
|
{
|
||||||
canDel = true;
|
canDel = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
canDel = false;
|
canDel = false;
|
||||||
|
await base.SetParametersAsync(parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
[Required]
|
[Required]
|
||||||
public PostData post { get; set; }
|
public PostData post { get; set; }
|
||||||
|
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
[Required]
|
[Required]
|
||||||
public bool showOpenThread { get; set; }
|
public bool showOpenThread { get; set; }
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
@using ImageBoardServerApp.Auth
|
@inherits LayoutComponentBase
|
||||||
@inherits LayoutComponentBase
|
|
||||||
@inject AuthenticationStateProvider authStateProvider
|
@inject AuthenticationStateProvider authStateProvider
|
||||||
@inject NavigationManager navManager
|
@inject NavigationManager navManager
|
||||||
|
|
||||||
|
@ -20,15 +19,4 @@
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|
||||||
private string mail { get; set; } = "";
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
|
||||||
{
|
|
||||||
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
|
||||||
var user = await cauthStateProvder.GetAuthenticationStateAsync();
|
|
||||||
if (user.User.Identity.IsAuthenticated)
|
|
||||||
{
|
|
||||||
mail = $"Welcome User # {user.User.Identity.Name}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue