improve user profile error logging for external login
This commit is contained in:
parent
5e4c91440e
commit
81030f468b
|
@ -439,24 +439,39 @@ namespace Oqtane.Extensions
|
|||
if (mapping.Contains(":"))
|
||||
{
|
||||
var claim = claimsPrincipal.Claims.FirstOrDefault(item => item.Type == mapping.Split(":")[0]);
|
||||
if (claim != null && !string.IsNullOrEmpty(claim.Value))
|
||||
if (claim != null)
|
||||
{
|
||||
var profile = profiles.FirstOrDefault(item => item.Name == mapping.Split(":")[1]);
|
||||
if (profile != null)
|
||||
{
|
||||
var setting = _settings.GetSetting(EntityNames.User, user.UserId, profile.Name);
|
||||
if (setting != null)
|
||||
if (!string.IsNullOrEmpty(claim.Value))
|
||||
{
|
||||
setting.SettingValue = claim.Value;
|
||||
_settings.UpdateSetting(setting);
|
||||
}
|
||||
else
|
||||
{
|
||||
setting = new Setting { EntityName = EntityNames.User, EntityId = user.UserId, SettingName = profile.Name, SettingValue = claim.Value, IsPrivate = profile.IsPrivate };
|
||||
_settings.AddSetting(setting);
|
||||
var setting = _settings.GetSetting(EntityNames.User, user.UserId, profile.Name);
|
||||
if (setting != null)
|
||||
{
|
||||
setting.SettingValue = claim.Value;
|
||||
_settings.UpdateSetting(setting);
|
||||
}
|
||||
else
|
||||
{
|
||||
setting = new Setting { EntityName = EntityNames.User, EntityId = user.UserId, SettingName = profile.Name, SettingValue = claim.Value, IsPrivate = profile.IsPrivate };
|
||||
_settings.AddSetting(setting);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, "ExternalLogin", Enums.LogFunction.Security, "The User Profile {ProfileName} Does Not Exist For The Site. Please Verify Your User Profile Definitions.", mapping.Split(":")[1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, "ExternalLogin", Enums.LogFunction.Security, "The User Profile Claim {ClaimType} Does Not Exist. The Valid Claims Are {Claims}.", mapping.Split(":")[0], claims);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, "ExternalLogin", Enums.LogFunction.Security, "The User Profile Claim Mapping {Mapping} Is Not Specified Correctly. It Should Be In The Format 'ClaimType:ProfileName'.", mapping);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user