Skip to content

Commit

Permalink
* userManagementController.js: fixed #881
Browse files Browse the repository at this point in the history
* UserManagementModule.cs:
  • Loading branch information
TidusJar committed Jan 2, 2017
1 parent 34e00e1 commit f074f28
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,16 @@
}
}

if(Array.isArray($scope.users)){

var existingUsername = $scope.users.some(function (u) {
return u.username === $scope.user.username;
});

if (existingUsername) {
return generateNotify("A user with the username " + $scope.user.username + " already exists!", 'danger');
}
}

userManagementService.addUser($scope.user, $scope.selectedPermissions, $scope.selectedFeatures)
.then(function (data) {
Expand All @@ -92,6 +95,8 @@
clearCheckboxes();
};
});


};

// Watch the checkboxes for updates (Creating a user)
Expand Down
31 changes: 14 additions & 17 deletions Ombi.UI/Modules/UserManagementModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,20 @@ private async Task<Response> LoadUsers()
{
//Get Plex Users
var plexUsers = PlexApi.GetUsers(plexSettings.PlexAuthToken);

foreach (var u in plexUsers.User)
{
var dbUser = plexDbUsers.FirstOrDefault(x => x.PlexUserId == u.Id);
var userDb = userLogins.FirstOrDefault(x => x.UserId == u.Id);

// We don't have the user in the database yet
if (dbUser == null)
{
model.Add(MapPlexUser(u, null, userDb?.LastLoggedIn ?? DateTime.MinValue));
}
else
{
// The Plex User is in the database
model.Add(MapPlexUser(u, dbUser, userDb?.LastLoggedIn ?? DateTime.MinValue));
}
}
if (plexUsers != null && plexUsers.User != null) {
foreach (var u in plexUsers.User) {
var dbUser = plexDbUsers.FirstOrDefault (x => x.PlexUserId == u.Id);
var userDb = userLogins.FirstOrDefault (x => x.UserId == u.Id);

// We don't have the user in the database yet
if (dbUser == null) {
model.Add (MapPlexUser (u, null, userDb?.LastLoggedIn ?? DateTime.MinValue));
} else {
// The Plex User is in the database
model.Add (MapPlexUser (u, dbUser, userDb?.LastLoggedIn ?? DateTime.MinValue));
}
}
}

// Also get the server admin
var account = PlexApi.GetAccount(plexSettings.PlexAuthToken);
Expand Down

0 comments on commit f074f28

Please sign in to comment.