@ -97,13 +97,16 @@ namespace Ombi.Services.Jobs
var needToUpdate = false ;
var needToUpdate = false ;
var usernameChanged = false ;
var usernameChanged = false ;
// Do we need up update any info?
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
if ( ! dbUser . EmailAddress . Equals ( user . Email , StringComparison . CurrentCultureIgnoreCase ) )
{
{
dbUser . EmailAddress = user . Email ;
// Do we need up update any info?
needToUpdate = true ;
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 . Titl e, StringComparison . CurrentCultureIgnoreCase ) )
{
{
needToUpdate = true ;
needToUpdate = true ;
usernameChanged = true ;
usernameChanged = true ;
@ -114,8 +117,8 @@ namespace Ombi.Services.Jobs
if ( usernameChanged )
if ( usernameChanged )
{
{
// The username has changed, let's check if the username matches any local users
// The username has changed, let's check if the username matches any local users
var localUser = localUsers . FirstOrDefault ( x = > x . UserName . Equals ( user . Usernam e, StringComparison . CurrentCultureIgnoreCase ) ) ;
var localUser = localUsers . FirstOrDefault ( x = > x . UserName . Equals ( user . Titl e, StringComparison . CurrentCultureIgnoreCase ) ) ;
dbUser . Username = user . Usernam e;
dbUser . Username = user . Titl e;
if ( localUser ! = null )
if ( localUser ! = null )
{
{
// looks like we have a local user with the same name...
// 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 ( ) ;
var requestsWithThisUser = requests . Where ( x = > x . RequestedUsers . Contains ( user . Username ) ) . ToList ( ) ;
foreach ( var r in requestsWithThisUser )
foreach ( var r in requestsWithThisUser )
{
{
r . RequestedUsers . Remove ( user . Usernam e) ; // Remove old
r . RequestedUsers . Remove ( user . Titl e) ; // Remove old
r . RequestedUsers . Add ( dbUser . Username ) ; // Add new
r . RequestedUsers . Add ( dbUser . Username ) ; // Add new
}
}
@ -157,7 +160,7 @@ namespace Ombi.Services.Jobs
Features = UserManagementHelper . GetFeatures ( userManagementSettings ) ,
Features = UserManagementHelper . GetFeatures ( userManagementSettings ) ,
UserAlias = string . Empty ,
UserAlias = string . Empty ,
EmailAddress = user . Email ,
EmailAddress = user . Email ,
Username = user . Usernam e,
Username = user . Titl e,
LoginId = Guid . NewGuid ( ) . ToString ( )
LoginId = Guid . NewGuid ( ) . ToString ( )
} ;
} ;