Esempio n. 1
0
        public void Signout()
        {
            var response = new HRR.Core.Security.AuthenticationResponse();

            SecurityContextManager.Current.IsAuthenticated = false;
            response.IsAuthenticated = false;
            SecurityContextManager.Current.CurrentUser = null;
        }
Esempio n. 2
0
        public HRR.Core.Security.AuthenticationResponse AuthenticateUser(string userName, string password, string url)
        {
            var u        = new PersonRepository().GetByEmailPassword(userName, SecurityUtils.GetMd5Hash(password));
            var response = new HRR.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.";
                    SecurityContextManager.Current.LogEvent(u.ID, DateTime.Now, (int)ApplicationLogTypes.USER_LOGIN_UNSECCESSFUL, u.AccountID, "Account is inactive", "", "");
                }
                else
                {
                    SecurityContextManager.Current.CreateAuthenticationTicket(u.Email, u.Email + "_" + u.ID.ToString() + "_" + u.Password, DateTime.Now.AddDays(480), url);
                    u.Memberships.Count();
                    //u.AccountRef.ToString();
                    SecurityContextManager.Current.CurrentUser     = u;
                    SecurityContextManager.Current.CurrentProfile  = u;
                    SecurityContextManager.Current.CurrentAccount  = new AccountServices().GetByID(u.AccountID);
                    SecurityContextManager.Current.IsAuthenticated = true;
                    response.IsAuthenticated    = true;
                    response.CurrentAccessLevel = AccessLevels.FULLACCESS;
                    SecurityContextManager.Current.LogEvent(u.ID, DateTime.Now, (int)ApplicationLogTypes.USER_LOGIN_SUCCESSFUL, u.AccountID, "", "", "");
                }
            }
            else
            {
                SecurityContextManager.Current.IsAuthenticated = false;
                response.IsAuthenticated = false;
                SecurityContextManager.Current.CurrentUser = null;
                response.Message = "Invalid username or password.  Please try again.";
            }

            return(response);
        }