Example #1
0
        public IdeaSeedCMS.Core.Security.AuthenticationResponse AuthenticateUser(string userName, string password, string url, ISecurityContext securityContext)
        {
            var u        = new UserRepository().GetByEmailPassword(userName, SecurityUtils.GetMd5Hash(password));
            var response = new IdeaSeedCMS.Core.Security.AuthenticationResponse();

            if (u != null)
            {
                if (!u.IsActive)
                {
                    response.IsAuthenticated    = false;
                    response.CurrentAccessLevel = AccessLevels.NOACCESS;
                    response.Message            = "Your account has been marked as inactive.";
                }
                else
                {
                    CreateAuthenticationTicket(u.UserName, u.ID.ToString(), DateTime.Now.AddMinutes(60), url);
                    u.LastLoginDate = DateTime.Now;
                    SecurityContextManager.Current.CurrentUser = u;
                    securityContext.CurrentUser            = u;
                    SessionManager.Current["Current_User"] = u;
                    securityContext.IsAuthenticated        = true;
                    response.IsAuthenticated    = true;
                    response.CurrentAccessLevel = AccessLevels.FULLACCESS;
                }
            }
            else
            {
                securityContext.IsAuthenticated = false;
                response.IsAuthenticated        = false;
                securityContext.CurrentUser     = null;
                response.Message = "Invalid username or password.  Please try again.";
            }

            return(response);
        }
Example #2
0
        public void Signout()
        {
            var response = new IdeaSeedCMS.Core.Security.AuthenticationResponse();

            SecurityContextManager.Current.IsAuthenticated = false;
            response.IsAuthenticated = false;
            SecurityContextManager.Current.CurrentUser = null;
        }