public new bool VerifyUserUnicity(int id, string userName, string email) { //string normalizedUserName = userName.ToLowerInvariant(); //if (_contentManager.Query<UserPart, UserPartRecord>() // .Where(user => // user.NormalizedUserName == normalizedUserName || // user.Email == email) // .List().Any(user => user.Id != id)) { // return false; //} //return true; if (CheckUsernameUnicity(userName, id)) { if (_userProviderService.Get(id).Count() > 0) { // account OAuth return(true); } else { // account locale return(CheckEmailUnicityInLocalAccounts(email, id)); } } else { return(false); } }
protected override DriverResult Editor(UserProviderDisplayPart part, dynamic shapeHelper) { if (!_authorizationService.TryCheckAccess(StandardPermissions.SiteOwner, _authenticationService.GetAuthenticatedUser(), part)) { return(null); } return(ContentShape("UserProviderDisplay", () => { var model = new UserProviderDisplayViewModel(); if (part.ContentItem.ContentType == "User") { var providers = _userProviderServices.Get(part.ContentItem.Id).Select(x => x.ProviderName); if (providers != null && providers.Count() > 0) { model.Providers = providers; } else { model.Providers = new List <string> { "Local" }; } } else { model.Providers = new List <string> { "N/A" }; } return shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix); })); }
public void CreateOrUpdateAccount(string providerName, string providerUserId, IUser user, IDictionary <string, string> providerUserData = null) { if (user == null) { throw new MembershipCreateUserException(MembershipCreateStatus.ProviderError); } var record = _userProviderServices.Get(providerName, providerUserId); var providerData = providerUserData == null ? null : providerUserData.ToJson(); var eventContext = new CreatedOpenAuthUserContext(user, providerName, providerUserId, providerUserData); if (record == null) { _userProviderServices.Create(providerName, providerUserId, user, providerData); _openAuthUserEventHandler.ProviderRecordCreated(eventContext); } else { _userProviderServices.Update(providerName, providerUserId, user, providerData); } _openAuthUserEventHandler.ProviderRecordUpdated(eventContext); }
private void AddProviderInfo(List <ContentIndexVM> items) { IUserProviderServices userProviderService = null; UserProviderRecord provider = null; if (_orchardServices.WorkContext.TryResolve <IUserProviderServices>(out userProviderService)) { foreach (var item in items) { if (item.UserId != 0) { provider = userProviderService.Get(item.UserId).FirstOrDefault(); if (provider == null) { item.Provider = "Local"; } else { item.Provider = provider.ProviderName; } } else { item.Provider = "Contact"; } } } }
public string GetUserNameFromOpenAuth(string provider, string providerUserId) { var record = _userProviderServices.Get(provider, providerUserId); if (record == null) { return(null); } var contentItem = _contentManager.Get(record.UserId); if (contentItem == null || !contentItem.Is <IUser>()) { return(null); // May want to throw an exception here } return(contentItem.As <IUser>().UserName); }
public void CreateOrUpdateAccount(string providerName, string providerUserId, IUser user) { if (user == null) { throw new MembershipCreateUserException(MembershipCreateStatus.ProviderError); } var record = _userProviderServices.Get(providerName, providerUserId); if (record == null) { _userProviderServices.Create(providerName, providerUserId, user); } else { _userProviderServices.Update(providerName, providerUserId, user); } }