Added new node manager. Added new login/register screen. AuditLog. Permissions
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using GravatarSharp;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Moonlight.App.Repositories;
|
||||
|
||||
namespace Moonlight.App.Http.Controllers.Api.Moonlight;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/moonlight/avatar")]
|
||||
public class AvatarController : Controller
|
||||
{
|
||||
private readonly UserRepository UserRepository;
|
||||
|
||||
public AvatarController(UserRepository userRepository)
|
||||
{
|
||||
UserRepository = userRepository;
|
||||
}
|
||||
|
||||
[HttpGet("{id:int}")]
|
||||
public async Task<ActionResult> GetAvatar([FromRoute] int id)
|
||||
{
|
||||
var user = UserRepository.Get().FirstOrDefault(x => x.Id == id);
|
||||
|
||||
if (user == null)
|
||||
return NotFound();
|
||||
|
||||
try
|
||||
{
|
||||
var url = GravatarController.GetImageUrl(user.Email, 100);
|
||||
|
||||
using var client = new HttpClient();
|
||||
var res = await client.GetByteArrayAsync(url);
|
||||
|
||||
return File(res, "image/png");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return BadRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace Moonlight.App.Http.Controllers.Api.Moonlight;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/moonlight/resources")]
|
||||
public class Resources : Controller
|
||||
public class ResourcesController : Controller
|
||||
{
|
||||
[HttpGet("images/{name}")]
|
||||
public ActionResult GetImage([FromRoute] string name)
|
||||
@@ -16,8 +16,14 @@ public class Resources : Controller
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var fs = new FileStream($"resources/public/images/{name}", FileMode.Open);
|
||||
if (System.IO.File.Exists($"resources/public/images/{name}"))
|
||||
{
|
||||
var fs = new FileStream($"resources/public/images/{name}", FileMode.Open);
|
||||
|
||||
return File(fs, "application/octet-stream", name);
|
||||
return File(fs, MimeTypes.GetMimeType(name), name);
|
||||
}
|
||||
|
||||
Logger.Debug("404 on resources");
|
||||
return NotFound();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user