Merge branch 'feature/oauth2.0' of github.com:ONLYOFFICE/AppServer into feature/oauth2.0

This commit is contained in:
Alexey Kostenko 2021-04-19 09:50:05 +03:00
commit c45cfe87a1

View File

@ -1554,18 +1554,41 @@ namespace ASC.Employee.Core.Controllers
} }
var thirdPartyProfile = new LoginProfile(Signature, InstanceCrypto, model.SerializedProfile); var thirdPartyProfile = new LoginProfile(Signature, InstanceCrypto, model.SerializedProfile);
var newUser = CreateNewUser(GetFirstName(model, thirdPartyProfile), GetLastName(model, thirdPartyProfile), GetEmailAddress(model, thirdPartyProfile), passwordHash, employeeType, false); if (!string.IsNullOrEmpty(thirdPartyProfile.AuthorizationError))
var messageAction = employeeType == EmployeeType.User ? MessageAction.UserCreatedViaInvite : MessageAction.GuestCreatedViaInvite;
MessageService.Send(MessageInitiator.System, messageAction, MessageTarget.Create(newUser.ID), newUser.DisplayUserName(false, DisplayUserSettingsHelper));
var userID = newUser.ID;
if (!string.IsNullOrEmpty(thirdPartyProfile.Avatar))
{ {
SaveContactImage(userID, thirdPartyProfile.Avatar); // ignore cancellation
if (thirdPartyProfile.AuthorizationError != "Canceled at provider")
throw new Exception(thirdPartyProfile.AuthorizationError);
return;
} }
GetLinker().AddLink(userID.ToString(), thirdPartyProfile); if (string.IsNullOrEmpty(thirdPartyProfile.EMail))
{
throw new Exception(Resource.ErrorNotCorrectEmail);
}
var userID = Guid.Empty;
try
{
SecurityContext.AuthenticateMe(ASC.Core.Configuration.Constants.CoreSystem);
var newUser = CreateNewUser(GetFirstName(model, thirdPartyProfile), GetLastName(model, thirdPartyProfile), GetEmailAddress(model, thirdPartyProfile), passwordHash, employeeType, false);
var messageAction = employeeType == EmployeeType.User ? MessageAction.UserCreatedViaInvite : MessageAction.GuestCreatedViaInvite;
MessageService.Send(MessageInitiator.System, messageAction, MessageTarget.Create(newUser.ID), newUser.DisplayUserName(false, DisplayUserSettingsHelper));
userID = newUser.ID;
if (!string.IsNullOrEmpty(thirdPartyProfile.Avatar))
{
SaveContactImage(userID, thirdPartyProfile.Avatar);
}
GetLinker().AddLink(userID.ToString(), thirdPartyProfile);
}
finally
{
SecurityContext.Logout();
}
var user = UserManager.GetUsers(userID); var user = UserManager.GetUsers(userID);
var cookiesKey = SecurityContext.AuthenticateMe(user.Email, passwordHash); var cookiesKey = SecurityContext.AuthenticateMe(user.Email, passwordHash);
@ -1581,6 +1604,7 @@ namespace ASC.Employee.Core.Controllers
UserHelpTourHelper.IsNewUser = true; UserHelpTourHelper.IsNewUser = true;
if (CoreBaseSettings.Personal) if (CoreBaseSettings.Personal)
PersonalSettingsHelper.IsNewUser = true; PersonalSettingsHelper.IsNewUser = true;
} }
[Create("phone")] [Create("phone")]