feature: custom details first-class

custom details (such as those from the UserDetails plugin) can now be more deeply integrated throughtout the system
This commit is contained in:
Gary Sharp
2021-02-07 18:15:52 +11:00
parent e11d0871c4
commit 3e57af394d
41 changed files with 2700 additions and 1279 deletions
@@ -6,11 +6,13 @@ using Disco.Services.Authorization;
using Disco.Services.Documents;
using Disco.Services.Interop;
using Disco.Services.Interop.ActiveDirectory;
using Disco.Services.Plugins.Features.DetailsProvider;
using Disco.Services.Users;
using Disco.Services.Web;
using System;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Disco.Web.Areas.API.Controllers
@@ -186,5 +188,29 @@ namespace Disco.Web.Areas.API.Controllers
return RedirectToAction(MVC.API.DocumentTemplatePackage.Generate(DocumentTemplatePackageId, userId));
}
public virtual ActionResult Photo(string userId)
{
if (string.IsNullOrEmpty(userId))
throw new ArgumentNullException(nameof(userId));
userId = ActiveDirectory.ParseDomainAccountId(userId);
var user = UserService.GetUser(userId);
if (user == null)
return HttpNotFound();
var service = new DetailsProviderService(Database);
if (!service.HasUserPhoto(user))
return HttpNotFound();
var photo = service.GetUserPhoto(user);
if (photo == null)
return HttpNotFound();
return File(photo, "image/jpg");
}
}
}