Esempio n. 1
0
        // 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);
        }
Esempio n. 2
0
        // 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);
        }