public bool LogoutAdminUser(System.Web.HttpContextBase httpContext, MerchantTribeApplication app)
        {
            bool result = true;

            Cookies.SetCookieGuid(WebAppSettings.CookieNameAuthenticationTokenAdmin(app.CurrentStore.Id),
                                  System.Guid.NewGuid(),
                                  httpContext, false, new EventLog());

            return(result);
        }
        // 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);
        }
Beispiel #3
0
        public bool IsCurrentUserAdmin(MerchantTribeApplication app, HttpContextBase httpContext)
        {
            Guid?tokenId = MerchantTribe.Web.Cookies.GetCookieGuid(
                WebAppSettings.CookieNameAuthenticationTokenAdmin(app.CurrentStore.Id),
                httpContext, new EventLog());

            // no token, return
            if (!tokenId.HasValue)
            {
                return(false);
            }

            if (app.AccountServices.IsTokenValidForStore(app.CurrentStore.Id, tokenId.Value))
            {
                return(true);
            }

            return(false);
        }
        public void ValidateAdminLogin()
        {
            bool validLogin = false;

            Guid?tokenId = MerchantTribe.Web.Cookies.GetCookieGuid(WebAppSettings.CookieNameAuthenticationTokenAdmin(MTApp.CurrentStore.Id),
                                                                   this.HttpContext,
                                                                   new EventLog());

            if (tokenId.HasValue)
            {
                if (this.MTApp.AccountServices.IsTokenValidForStore(this.MTApp.CurrentStore.Id, tokenId.Value))
                {
                    validLogin = true;
                }
            }

            if (validLogin == false)
            {
                Response.Redirect("~/adminaccount/login");
            }

            _AuthTokenGuid = tokenId;
        }