Exemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of the UserPermitVM
        /// </summary>
        /// <param name="permit"></param>
        /// <param name="user"></param>
        public UserPermitVM(PermitDO permit, myCoalUser user)
        {
            Permit = permit;
            User = user;

            List<PermitRegistrationBO> registrations = PermitRegistrationBLL.GetPermitRegistrationsByRegistrationID(User.RegistrationId);
            Registration = registrations.Where(r => r.PermitRegistration.PermitKey == Permit.PermitKey).FirstOrDefault();
        }
Exemplo n.º 2
0
        public CurrentPermitsVM(IEnumerable<PermitDO> Permits, myCoalUser User)
        {
            CurrentUser = User;

            UserPermits = new List<UserPermitVM>();

            foreach (PermitDO permit in Permits)
            {
                UserPermitVM userPermit = new UserPermitVM(permit, User);
                UserPermits.Add(userPermit);
            }
        }
Exemplo n.º 3
0
 public myCoalPrincipal(myCoalUser coalUser, IIdentity identity)
 {
     _identity = identity;
     _coalUser = coalUser;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Attaches a custom identity
 /// </summary>
 /// <param name="user"></param>
 private void AttachMyCoalIdentity(myCoalUser user)
 {
     myCoalPrincipal newUser = new myCoalPrincipal(user, User.Identity);
     HttpContext.Current.User = newUser;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Redirect the request based on the user status
        /// </summary>
        /// <param name="user"></param>
        private void UserStatusRedirects(myCoalUser user)
        {
            try
            {

                // registered users that aren't active get to an information page specific to their status
                switch (user.Status)
                {
                    case myCoalUserStatus.Denied:
                        Response.Redirect("~/account/denied");
                        break;
                    case myCoalUserStatus.Inactive:
                        Response.Redirect("~/account/inactive");
                        break;
                    case myCoalUserStatus.Pending:
                        Response.Redirect("~/account/pending");
                        break;
                    case myCoalUserStatus.Unknown:
                        Response.Redirect("~/account/unknown");
                        break;
                }

                throw new UnauthorizedAccessException("Your status could not be determined");

            }
            catch (ThreadAbortException ex)
            {
                // when a redirect occurs it aborts the current thread, which is expected
            }
            catch (Exception ex)
            {
                logger.Error("An error occurred in UserStatusRedirects", ex);
                throw ex;
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// sends unregistered users immediately to the registration page
 /// </summary>
 private void RegistrationBasedRedirect(myCoalUser user)
 {
     try
     {
         if (!user.IsRegistered)
             Response.Redirect("~/account/register");
     }
     catch (ThreadAbortException ex)
     {
         // when a redirect occurs it aborts the current thread, which is expected
     }
     catch (Exception ex)
     {
         logger.Error("An error occurred while determining the user's registration status", ex);
         throw ex;
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Is the current user Active
 /// </summary>
 /// <param name="user"></param>
 private bool IsUserActive(myCoalUser user)
 {
     try
     {
         return (user.Status == myCoalUserStatus.Active);
     }
     catch (Exception ex)
     {
         logger.Error("An error occurred while determinning the user.Status", ex);
         throw ex;
     }
 }
Exemplo n.º 8
0
 public myCoalPrincipal(myCoalUser coalUser, IIdentity federatedIdentity)
 {
     _identity = federatedIdentity;
     _coalUser = coalUser;
 }