Fix: AuthorizationRole.Subjects can be null #24

Fixes the resulting NullReferenceException.
This commit is contained in:
Gary Sharp
2013-10-17 11:05:22 +11:00
parent 51ebc673e7
commit fdb5d37ec8
@@ -114,7 +114,7 @@ namespace Disco.Web.Areas.API.Controllers
throw new ArgumentException(string.Format("Subjects not found: {0}", string.Join(", ", invalidSubjects)), "Subjects"); throw new ArgumentException(string.Format("Subjects not found: {0}", string.Join(", ", invalidSubjects)), "Subjects");
var proposedSubjects = subjects.Select(s => s.Item2.SamAccountName).OrderBy(s => s).ToArray(); var proposedSubjects = subjects.Select(s => s.Item2.SamAccountName).OrderBy(s => s).ToArray();
var currentSubjects = AuthorizationRole.SubjectIds.Split(','); var currentSubjects = AuthorizationRole.SubjectIds == null ? new string[0] : AuthorizationRole.SubjectIds.Split(',');
removedSubjects = currentSubjects.Except(proposedSubjects).ToArray(); removedSubjects = currentSubjects.Except(proposedSubjects).ToArray();
addedSubjects = proposedSubjects.Except(currentSubjects).ToArray(); addedSubjects = proposedSubjects.Except(currentSubjects).ToArray();