// Admin Users public bool AuthenticateAdminUser(string email, string password, ref string errorMessage) { bool result = false; try { UserAccount u = AdminUsers.FindByEmail(email); if (u == null) { errorMessage = "Please check your email address and password and try again."; return(false); } if (!u.DoesPasswordMatch(password)) { errorMessage = "Please check your email address and password and try again."; return(false); } if (u.Status == UserAccountStatus.Disabled) { errorMessage = "Your account is not currently active. Please contact an administrator for details."; return(false); } return(true); } catch (Exception ex) { result = false; EventLog.LogEvent(ex); errorMessage = "Unknown login error. Contact administrator for assistance."; } return(result); }
public bool AdminUserResetRequest(string email, Accounts.Store store) { UserAccount u = AdminUsers.FindByEmail(email); if (u == null) { return(false); } u.ResetKey = System.Guid.NewGuid().ToString(); AdminUsers.Update(u); Utilities.MailServices.SendAdminUserResetLink(u, store); return(true); }
// Admin Users public bool LoginAdminUser(string email, string password, ref string errorMessage, System.Web.HttpContextBase httpContext, MerchantTribeApplication app) { bool result = false; try { UserAccount u = AdminUsers.FindByEmail(email); if (u == null) { errorMessage = "Please check your email address and password and try again."; return(false); } if (!u.DoesPasswordMatch(password)) { errorMessage = "Please check your email address and password and try again."; return(false); } if (u.Status == UserAccountStatus.Disabled) { errorMessage = "Your account is not currently active. Please contact an administrator for details."; return(false); } AuthToken token = new AuthToken(); token.UserId = u.Id; token.Expires = DateTime.UtcNow.AddDays(WebAppSettings.AuthenticationTokenValidForDays()); if (AuthTokens.Create(token)) { Cookies.SetCookieGuid(WebAppSettings.CookieNameAuthenticationTokenAdmin(app.CurrentStore.Id), token.TokenId, httpContext, false, new EventLog()); result = true; } else { errorMessage = "There was a problem with your authentication token. Please contact an administrator for assistance."; return(false); } } catch (Exception ex) { result = false; EventLog.LogEvent(ex); errorMessage = "Unknown login error. Contact administrator for assistance."; } return(result); }
public bool AddUserToStoreByEmail(long storeId, string email, StoreAccessMode mode) { UserAccount u = AdminUsers.FindByEmail(email); if (u == null) { u = new UserAccount(); u.Email = email; string password = Utilities.PasswordGenerator.GeneratePassword(); u.HashedPassword = password; AdminUsers.Create(u); } if (AddUserToStore(storeId, u.Id, mode)) { Store s = Stores.FindById(storeId); Utilities.MailServices.SendAccountInformation(u, s); return(true); } return(false); }
private Store CreateIndividualStore() { Store s = null; string storeName = "www"; s = new Store(); s.StoreName = Text.ForceAlphaNumericOnly(storeName).ToLower(); s.Status = StoreStatus.Active; s.DateCreated = DateTime.UtcNow; s.PlanId = 99; s.CustomUrl = string.Empty; if (!Stores.Create(s)) { throw new CreateStoreException("Unable to create store. Unknown error. Please contact an administrator for assistance."); } s = Stores.FindByStoreName(s.StoreName); if (s != null) { UserAccount mainAccount = new UserAccount(); mainAccount.Email = "*****@*****.**"; mainAccount.HashedPassword = "******"; mainAccount.Status = UserAccountStatus.Active; AdminUsers.Create(mainAccount); mainAccount = AdminUsers.FindByEmail(mainAccount.Email); AddUserToStore(s.Id, mainAccount.Id, StoreAccessMode.Owner); s.Settings.FriendlyName = "My MerchantTribe Store"; s.Settings.MailServer.FromEmail = "*****@*****.**"; s.Settings.LastOrderNumber = 0; s.Settings.LogoImage = "[[default]]"; s.Settings.LogoRevision = 0; s.Settings.UseLogoImage = false; s.Settings.LogoText = s.StoreName; s.Settings.MinumumOrderAmount = 0; s.Settings.MailServer.EmailForGeneral = mainAccount.Email; s.Settings.MailServer.EmailForNewOrder = mainAccount.Email; s.Settings.MailServer.UseCustomMailServer = false; s.Settings.ProductReviewCount = 3; s.Settings.ProductReviewModerate = true; s.Settings.ProductReviewShowRating = true; s.Settings.PayPal.FastSignupEmail = mainAccount.Email; s.Settings.PayPal.Currency = "USD"; s.Settings.MaxItemsPerOrder = 999; s.CurrentPlanRate = 0; s.CurrentPlanDayOfMonth = DateTime.Now.Day; s.CurrentPlanPercent = 0; // Save data to store Stores.Update(s); // No longer need to redirect because home controller handles this //System.Web.HttpContext.Current.Response.Redirect("~/adminaccount/login?wizard=1"); // Force this store into the request context so // non-repository datalayer will read in the correct // store id //RequestContext demoContext = new RequestContext(); //demoContext.CurrentStore = s; //RequestContext.ForceCurrentRequestContext(demoContext); //// Add Sample Data //AddSampleProductsToStore(demoContext); //// Set a default theme //Content.ThemeManager m = new Content.ThemeManager(demoContext); //m.InstallTheme("cf09d318-3792-47b8-a207-a9502f96f0f9"); } return(s); }