fix author url

add many ownersid
This commit is contained in:
Дмитрий Шиманский
2023-12-22 23:54:41 +03:00
parent f79e10f148
commit 782dea8c9d
7 changed files with 23 additions and 22 deletions

View File

@@ -44,7 +44,7 @@ namespace yaflay.ru.Новая_папка
}
string responseBody = await message.Content.ReadAsStringAsync();
JsonNode response = JsonNode.Parse(responseBody);
if (response["user"] != null || response["user"]?["id"].ToString() == Startup.ownerId)
if (response["user"] != null || Startup.ownerId.FirstOrDefault(k => k.Equals(response["user"]?["id"].ToString())) != null)
{
Redirects redirects = new()
{
@@ -73,7 +73,7 @@ namespace yaflay.ru.Новая_папка
}
string responseBody = await message.Content.ReadAsStringAsync();
JsonNode response = JsonNode.Parse(responseBody);
if (response["user"] != null || response["user"]?["id"].ToString() == Startup.ownerId)
if (response["user"] != null || Startup.ownerId.FirstOrDefault(k => k.Equals(response["user"]?["id"].ToString())) != null )
{
try
{

View File

@@ -8,7 +8,7 @@
@if (Request.Cookies["melon"] != null)
{
if (Request.Cookies["cable"] != Startup.ownerId)
if (Startup.ownerId.FirstOrDefault(k => k.Equals(Request.Cookies["cable"])) != null)
{
<h1 align="center">Вы не авторизованы! Сасни хуйца, олух</h1>
isAllowed = false;

View File

@@ -4,7 +4,7 @@
@{
ViewData["Title"] = "Authorize";
string authorizationUrl = $"https://discord.com/api/oauth2/authorize?client_id={Startup.clientId}&response_type=code&redirect_uri={Startup.redirectUrl}&scope=identify";
<p style="display:none;">Data: @Startup.clientId @Startup.redirectUrl @Startup.ownerId @Model.code</p>
<p style="display:none;">Data: @Startup.clientId @Startup.redirectUrl @String.Join(",", Startup.ownerId) @Model.code</p>
if (Model.code == null)
{
if (Request.Cookies["melon"]?.ToString() == null)

View File

@@ -33,7 +33,7 @@
<div id="blogId" style="display:none;">@Model.Id</div>
<p align="center"><img src="@Post.ImageUrl" style="width:50vmax;"/></p>
<p align="center">@Html.Raw(Post.Text)</p>
string userId = "https://discord.com/users/"+Post.author.Id;
string userId = "https://discord.com/users/"+Post.author.discordId;
<h6 align="left">Статья подготовлена <a href="@userId">@Post.author.discordNickName</a></h6>
<div class="container my-5 py-5 bg-dark text-muted">
<div class="row d-flex justify-content-center">

View File

@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using yaflay.ru;
public class Program
{
@@ -10,7 +11,7 @@ public class Program
Startup.clientSecret = parse("CLIENTSECRET");
Startup.redirectUrl = parse("REDIRECTURL");
Startup.connectionString = $"Host={parse("PSQL_HOST")};Username={parse("PSQL_USER")};Password={parse("PSQL_PASSWORD")};Database={parse("PSQL_DATABASE")}";
Startup.ownerId = parse("OWNERID");
Startup.ownerId = new[] { parse("OWNERID") };
Startup.readmeFile = parse("READMEFILE");
CreateHostBuilder()
.Build()

View File

@@ -17,11 +17,11 @@ namespace yaflay.ru
public static HttpClientHandler handler = new() { CookieContainer = cookieContainer};
public static HttpClient client = new(handler);
public static AppDbContext? dbContext;
public static string? clientId = null;
public static string? clientSecret = null;
public static string? redirectUrl = null;
public static string? ownerId = null;
public static string? readmeFile = null;
public static string? clientId { get; set; } = null;
public static string? clientSecret { get; set; } = null;
public static string? redirectUrl { get; set; } = null;
public static string[]? ownerId { get; set; } = null;
public static string? readmeFile { get; set; } = null;
public static string? connectionString { private get; set; } = null;
public Startup()
{
@@ -39,9 +39,9 @@ namespace yaflay.ru
{
connectionString = configuration.GetValue<string>("connectionString");
}
if (ownerId == null)
if (ownerId.Length == 0)
{
ownerId = configuration.GetValue<string>("ownerId");
ownerId = new[] { configuration.GetValue<string>("ownerId") };
}
if (readmeFile == null)
{

View File

@@ -9,20 +9,20 @@ function updateAnnotation(value) {
blogText.append(value);
}
function sendArticleData () {
function sendArticleData() {
let melon = document.cookie.split(';')[0].replace("melon=", "");
let body = `{
title: "${$("#titleInput").val().replace(/"/g, '\\"') }",
annotation: "${$("#annotationArea").val().replace(/\n/g, " \\n").replace(/"/g, '\\"') }}",
text: "${$("#textArea").val().replace(/\n/g, " \\n").replace(/"/g, '\\"') }",
image: "${$("#imgInput").val()}",
author: "${melon}"
}`
"title": "${$("#titleInput").val().replace(/"/g, '\"')}",
"annotation": "${$("#annotationArea").val().replace(/\n/g, " \\n").replace(/"/g, '\"')}}",
"text": "${$("#textArea").val().replace(/\n/g, " \\n").replace(/"/g, '\"')}",
"image": "${$("#imgInput").val()}",
"author": "${melon}"
}`;
fetch("/api/Blog", {
method: "POST",
headers: {
Authorization: `Bearer ${melon}`,
"Content-Type": "application/json"
"Content-Type": "application/json"
},
body: body
}).then(k => console.log(k));
@@ -45,7 +45,7 @@ function sendRedirectData() {
method: "POST",
headers: {
Authorization: `Bearer ${melon}`,
"Content-Type": "application/json"
"Content-Type": "application/json"
},
body: body
}).then(k => console.log(k));