Merge pull request #907 from tidusjar/dev

Dev
pull/927/head^2
Jamie 8 years ago committed by GitHub
commit 497b887c8c

@ -97,13 +97,16 @@ namespace Ombi.Services.Jobs
var needToUpdate = false;
var usernameChanged = false;
// Do we need up update any info?
if (!dbUser.EmailAddress.Equals(user.Email, StringComparison.CurrentCultureIgnoreCase))
if (!string.IsNullOrEmpty(user.Username)) // If true then this is a managed user, we do not want to update the email since Managed Users do not have email addresses
{
dbUser.EmailAddress = user.Email;
needToUpdate = true;
// Do we need up update any info?
if (!dbUser.EmailAddress.Equals(user.Email, StringComparison.CurrentCultureIgnoreCase))
{
dbUser.EmailAddress = user.Email;
needToUpdate = true;
}
}
if (!dbUser.Username.Equals(user.Username, StringComparison.CurrentCultureIgnoreCase))
if (!dbUser.Username.Equals(user.Title, StringComparison.CurrentCultureIgnoreCase))
{
needToUpdate = true;
usernameChanged = true;
@ -114,8 +117,8 @@ namespace Ombi.Services.Jobs
if (usernameChanged)
{
// The username has changed, let's check if the username matches any local users
var localUser = localUsers.FirstOrDefault(x => x.UserName.Equals(user.Username, StringComparison.CurrentCultureIgnoreCase));
dbUser.Username = user.Username;
var localUser = localUsers.FirstOrDefault(x => x.UserName.Equals(user.Title, StringComparison.CurrentCultureIgnoreCase));
dbUser.Username = user.Title;
if (localUser != null)
{
// looks like we have a local user with the same name...
@ -133,7 +136,7 @@ namespace Ombi.Services.Jobs
var requestsWithThisUser = requests.Where(x => x.RequestedUsers.Contains(user.Username)).ToList();
foreach (var r in requestsWithThisUser)
{
r.RequestedUsers.Remove(user.Username); // Remove old
r.RequestedUsers.Remove(user.Title); // Remove old
r.RequestedUsers.Add(dbUser.Username); // Add new
}
@ -157,7 +160,7 @@ namespace Ombi.Services.Jobs
Features = UserManagementHelper.GetFeatures(userManagementSettings),
UserAlias = string.Empty,
EmailAddress = user.Email,
Username = user.Username,
Username = user.Title,
LoginId = Guid.NewGuid().ToString()
};

@ -47,21 +47,24 @@ namespace Ombi.Store.Repository
public UsersModel GetUser(string userGuid)
{
var sql = @"SELECT * FROM Users
WHERE Userguid = @UserGuid";
WHERE Userguid = @UserGuid
COLLATE NOCASE";
return Db.QueryFirstOrDefault<UsersModel>(sql, new {UserGuid = userGuid});
}
public UsersModel GetUserByUsername(string username)
{
var sql = @"SELECT * FROM Users
WHERE UserName = @UserName";
WHERE UserName = @UserName
COLLATE NOCASE";
return Db.QueryFirstOrDefault<UsersModel>(sql, new {UserName = username});
}
public async Task<UsersModel> GetUserAsync(string userguid)
{
var sql = @"SELECT * FROM Users
WHERE UserGuid = @UserGuid";
WHERE UserGuid = @UserGuid
COLLATE NOCASE";
return await Db.QueryFirstOrDefaultAsync<UsersModel>(sql, new {UserGuid = userguid});
}

@ -97,6 +97,8 @@ namespace Ombi.UI
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
ServicePointManager.ServerCertificateValidationCallback +=
(sender, certificate, chain, sslPolicyErrors) => true;
ServicePointManager.Expect100Continue = false;
}
#if DEBUG

@ -39,7 +39,7 @@
</div>
<strong>Email Address</strong>
<div class="form-group">
<input id="emailAddress" type="email" ng-model="selectedUser.emailAddress" ng-disabled="selectedUser.type === 0" class="form-control form-control-custom" />
<input id="emailAddress" type="email" ng-model="selectedUser.emailAddress" ng-disabled="selectedUser.emailDisabled" class="form-control form-control-custom" />
</div>
<strong>Alias</strong>

@ -31,6 +31,7 @@
});
$scope.selectedUser = user[0];
$scope.selectedUser.emailDisabled = $scope.selectedUser.type === 0 && $scope.selectedUser.managedUser == '';
openSidebar();
}

@ -24,6 +24,7 @@ namespace Ombi.UI.Models.UserManagement
public DateTime LastLoggedIn { get; set; }
public List<CheckBox> Permissions { get; set; }
public List<CheckBox> Features { get; set; }
public bool ManagedUser { get; set; }
}
public class UserManagementPlexInformation

@ -565,7 +565,7 @@ namespace Ombi.UI.Modules
};
try
{
if (ShouldAutoApprove(RequestType.Movie, settings, Username))
if (ShouldAutoApprove(RequestType.Movie))
{
model.Approved = true;
@ -885,7 +885,7 @@ namespace Ombi.UI.Modules
try
{
if (ShouldAutoApprove(RequestType.TvShow, settings, Username))
if (ShouldAutoApprove(RequestType.TvShow))
{
model.Approved = true;
var s = await sonarrSettings;
@ -981,7 +981,7 @@ namespace Ombi.UI.Modules
private bool ShouldSendNotification(RequestType type, PlexRequestSettings prSettings)
{
var sendNotification = ShouldAutoApprove(type, prSettings, Username)
var sendNotification = ShouldAutoApprove(type)
? !prSettings.IgnoreNotifyForAutoApprovedRequests
: true;
@ -1089,7 +1089,7 @@ namespace Ombi.UI.Modules
try
{
if (ShouldAutoApprove(RequestType.Album, settings, Username))
if (ShouldAutoApprove(RequestType.Album))
{
model.Approved = true;
var hpSettings = HeadphonesService.GetSettings();
@ -1363,7 +1363,7 @@ namespace Ombi.UI.Modules
return diff;
}
public bool ShouldAutoApprove(RequestType requestType, PlexRequestSettings prSettings, string username)
public bool ShouldAutoApprove(RequestType requestType)
{
var admin = Security.HasPermissions(Context.CurrentUser, Permissions.Administrator);
// if the user is an admin, they go ahead and allow auto-approval

@ -231,6 +231,7 @@ namespace Ombi.UI.Modules
await UpdateRequests(plexDbUser.Username, plexDbUser.UserAlias, model.Alias);
plexDbUser.UserAlias = model.Alias;
plexDbUser.EmailAddress = model.EmailAddress;
await PlexUsersRepository.UpdateAsync(plexDbUser);
@ -266,7 +267,7 @@ namespace Ombi.UI.Modules
UserAlias = model.Alias,
PlexUserId = plexUser.Id,
EmailAddress = plexUser.Email,
Username = plexUser.Username,
Username = plexUser.Title,
LoginId = Guid.NewGuid().ToString()
};
@ -417,7 +418,7 @@ namespace Ombi.UI.Modules
Id = plexInfo.Id,
PermissionsFormattedString = newUser ? "Processing..." :( permissions == 0 ? "None" : permissions.ToString()),
FeaturesFormattedString = newUser ? "Processing..." : features.ToString(),
Username = plexInfo.Username,
Username = plexInfo.Title,
Type = UserType.PlexUser,
EmailAddress = plexInfo.Email,
Alias = dbUser?.UserAlias ?? string.Empty,
@ -426,6 +427,7 @@ namespace Ombi.UI.Modules
{
Thumb = plexInfo.Thumb
},
ManagedUser = string.IsNullOrEmpty(plexInfo.Username)
};
m.Permissions.AddRange(GetPermissions(permissions));

Loading…
Cancel
Save