mirror of
https://github.com/yawaflua/yaflay.ru.git
synced 2026-02-04 19:04:12 +02:00
hotfix
This commit is contained in:
@@ -98,14 +98,15 @@ namespace yaflay.ru.Новая_папка
|
|||||||
JsonNode response = JsonNode.Parse(responseBody);
|
JsonNode response = JsonNode.Parse(responseBody);
|
||||||
if (response["user"] != null || response["user"]?["id"].ToString() == "945317832290336798")
|
if (response["user"] != null || response["user"]?["id"].ToString() == "945317832290336798")
|
||||||
{
|
{
|
||||||
Blogs article = new()
|
Author author = new()
|
||||||
{
|
|
||||||
Annotation = body.annotation,
|
|
||||||
author = new Author()
|
|
||||||
{
|
{
|
||||||
discordId = int.Parse(response["user"]["id"].ToString()),
|
discordId = int.Parse(response["user"]["id"].ToString()),
|
||||||
discordNickName = response["user"]["display_name"].ToString()
|
discordNickName = response["user"]["display_name"].ToString()
|
||||||
},
|
};
|
||||||
|
Blogs article = new()
|
||||||
|
{
|
||||||
|
Annotation = body.annotation,
|
||||||
|
author = author,
|
||||||
dateTime = DateTime.Now,
|
dateTime = DateTime.Now,
|
||||||
ImageUrl = body.image,
|
ImageUrl = body.image,
|
||||||
Text = body.text,
|
Text = body.text,
|
||||||
@@ -113,11 +114,11 @@ namespace yaflay.ru.Новая_папка
|
|||||||
};
|
};
|
||||||
await Startup.dbContext.Blogs.AddAsync(article);
|
await Startup.dbContext.Blogs.AddAsync(article);
|
||||||
await Startup.dbContext.SaveChangesAsync();
|
await Startup.dbContext.SaveChangesAsync();
|
||||||
return Ok();
|
return Ok(body);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return Unauthorized();
|
return Unauthorized(body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[HttpGet("logout")]
|
[HttpGet("logout")]
|
||||||
@@ -176,5 +177,25 @@ namespace yaflay.ru.Новая_папка
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
[HttpGet("static/{file}")]
|
||||||
|
public HttpResponseMessage Generate(string file)
|
||||||
|
{
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
// processing the stream.
|
||||||
|
|
||||||
|
var result = new HttpResponseMessage(System.Net.HttpStatusCode.OK)
|
||||||
|
{
|
||||||
|
Content = new ByteArrayContent(stream.ToArray())
|
||||||
|
};
|
||||||
|
result.Content.Headers.ContentDisposition =
|
||||||
|
new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
|
||||||
|
{
|
||||||
|
FileName = $"wwwroot/static/{file}"
|
||||||
|
};
|
||||||
|
result.Content.Headers.ContentType =
|
||||||
|
new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
@using System.Text.Json.Nodes
|
@using System.Text.Json.Nodes
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Authorize";
|
ViewData["Title"] = "Authorize";
|
||||||
<h4>code - @Model.code</h4>
|
|
||||||
if (Model.code == null)
|
if (Model.code == null)
|
||||||
{
|
{
|
||||||
if (Request.Cookies["melon"]?.ToString() == null)
|
if (Request.Cookies["melon"]?.ToString() == null)
|
||||||
|
|||||||
@@ -11,18 +11,20 @@ function updateAnnotation(value) {
|
|||||||
|
|
||||||
function sendArticleData () {
|
function sendArticleData () {
|
||||||
let melon = document.cookie.split(';')[0].replace("melon=", "");
|
let melon = document.cookie.split(';')[0].replace("melon=", "");
|
||||||
|
let body = `{
|
||||||
|
title: ${$("#titleInput").val()},
|
||||||
|
annotation: ${$("#annotationArea").val()},
|
||||||
|
text: ${$("#textArea").val()},
|
||||||
|
image: ${$("#imgInput").val()},
|
||||||
|
author: ${melon}
|
||||||
|
}`
|
||||||
fetch("/api/Blog", {
|
fetch("/api/Blog", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${melon}`
|
Authorization: `Bearer ${melon}`,
|
||||||
|
"Content-Type": "application/json"
|
||||||
},
|
},
|
||||||
body: {
|
body: body
|
||||||
title: $("#titleInput").val(),
|
|
||||||
annotation: $("#annotationArea").val(),
|
|
||||||
text: $("#textArea").val(),
|
|
||||||
image: $("#imgInput").val(),
|
|
||||||
author: melon
|
|
||||||
}
|
|
||||||
}).then(k => console.log(k));
|
}).then(k => console.log(k));
|
||||||
$("#titleInput").val('');
|
$("#titleInput").val('');
|
||||||
$("#annotationArea").val('');
|
$("#annotationArea").val('');
|
||||||
|
|||||||
BIN
wwwroot/static/pyVSdotnet.png
Normal file
BIN
wwwroot/static/pyVSdotnet.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.9 KiB |
Reference in New Issue
Block a user