private static bool TryByHashId(AccountLinkControl accountLinkControl, string hashId, out Guid userId) { userId = Guid.Empty; if (accountLinkControl == null || string.IsNullOrEmpty(hashId)) { return false; } var accountsStrId = accountLinkControl.GetLinker().GetLinkedObjectsByHashId(hashId); userId = accountsStrId .Select(x => { try { return new Guid(x); } catch { return Guid.Empty; } }) .Where(x => x != Guid.Empty) .FirstOrDefault(x => CoreContext.UserManager.UserExists(x)); return true; }
private string SmsLoginUrl(AccountLinkControl accountLinkControl) { if (!StudioSmsNotificationSettings.IsVisibleSettings || !StudioSmsNotificationSettings.Enable) return string.Empty; UserInfo user; if (string.IsNullOrEmpty(HashId)) { user = CoreContext.UserManager.GetUsers(TenantProvider.CurrentTenantID, Login, Hasher.Base64Hash(Password, HashAlg.SHA256)); } else { Guid userId; TryByHashId(accountLinkControl, HashId, out userId); user = CoreContext.UserManager.GetUsers(userId); } if (user == null) return string.Empty; var confirmType = string.IsNullOrEmpty(user.MobilePhone) || user.MobilePhoneActivationStatus == MobilePhoneActivationStatus.NotActivated ? ConfirmType.PhoneActivation : ConfirmType.PhoneAuth; return StudioNotifyService.GenerateConfirmUrl(user.Email, confirmType); }
private string SmsLoginUrl(AccountLinkControl accountLinkControl) { if (!StudioSmsNotificationSettings.IsVisibleSettings || !StudioSmsNotificationSettings.Enable) return string.Empty; UserInfo user; if (string.IsNullOrEmpty(HashId)) { user = CoreContext.UserManager.GetUsers(TenantProvider.CurrentTenantID, Login, Hasher.Base64Hash(Password, HashAlg.SHA256)); } else { Guid userId; TryByHashId(accountLinkControl, HashId, out userId); user = CoreContext.UserManager.GetUsers(userId); } if (Constants.LostUser.Equals(user)) { throw new InvalidCredentialException(); } return Studio.Confirm.SmsConfirmUrl(user); }