Fix: Computer authorized enrolment

Computer Accounts could not enrol
This commit is contained in:
Gary Sharp
2013-10-21 20:02:40 +11:00
parent 5f9a49bca3
commit 4dfe9ad086
2 changed files with 7 additions and 5 deletions
+1 -1
View File
@@ -347,7 +347,7 @@ namespace Disco.BI.DeviceBI
{ {
if (!authenticatedToken.Has(Claims.Device.Actions.EnrolDevices)) if (!authenticatedToken.Has(Claims.Device.Actions.EnrolDevices))
{ {
if (authenticatedToken.Has(Claims.ComputerAccount)) if (!authenticatedToken.Has(Claims.ComputerAccount))
throw new EnrolSafeException(string.Format("Connection not correctly authenticated (SN: {0}; Auth User: {1})", Request.DeviceSerialNumber, authenticatedToken.User.Id)); throw new EnrolSafeException(string.Format("Connection not correctly authenticated (SN: {0}; Auth User: {1})", Request.DeviceSerialNumber, authenticatedToken.User.Id));
if (!authenticatedToken.User.Id.Equals(string.Format("{0}$", Request.DeviceComputerName), System.StringComparison.InvariantCultureIgnoreCase)) if (!authenticatedToken.User.Id.Equals(string.Format("{0}$", Request.DeviceComputerName), System.StringComparison.InvariantCultureIgnoreCase))
throw new EnrolSafeException(string.Format("Connection not correctly authenticated (SN: {0}; Auth User: {1})", Request.DeviceSerialNumber, authenticatedToken.User.Id)); throw new EnrolSafeException(string.Format("Connection not correctly authenticated (SN: {0}; Auth User: {1})", Request.DeviceSerialNumber, authenticatedToken.User.Id));
@@ -7,6 +7,7 @@ using System.Web;
using Disco.Data.Repository; using Disco.Data.Repository;
using Disco.Models.Repository; using Disco.Models.Repository;
using Disco.Services.Users; using Disco.Services.Users;
using Disco.Services.Authorization;
namespace Disco.BI.Extensions namespace Disco.BI.Extensions
{ {
@@ -43,12 +44,13 @@ namespace Disco.BI.Extensions
using (DiscoDataContext database = new DiscoDataContext()) using (DiscoDataContext database = new DiscoDataContext())
{ {
User user = UserService.GetUser(username, database, true); AuthorizationToken token = UserService.GetAuthorization(username, database, true);
WhoAmIResponse response = new WhoAmIResponse() WhoAmIResponse response = new WhoAmIResponse()
{ {
Username = user.Id, Username = token.User.Id,
DisplayName = user.DisplayName, DisplayName = token.User.DisplayName,
Type = "TODO!" Type = token.Has(Claims.ComputerAccount) ? "Computer Account" : "User Account"
}; };
return response; return response;
} }