Example #1
0
        public PinzCustomPrincipal(IIdentity client)
        {
            this.Identity = client;

            PinzDbContext dbContext = new PinzDbContext("pinzDBConnectionString");

            roles = new List <string>();
            if (Identity.IsAuthenticated)
            {
                roles.Add(USER);
            }

            UserDO user = dbContext.Users.Single(u => u.EMail == Identity.Name);

            if (user.ProjectStaff.Any(ps => ps.IsProjectAdmin == true))
            {
                roles.Add(PROJECT_ADMIN);
            }
            if (user.IsCompanyAdmin)
            {
                roles.Add(PROJECT_ADMIN);
                roles.Add(COMPANY_ADMIN);
            }
            if (user.IsPinzSuperAdmin)
            {
                roles.Add(PROJECT_ADMIN);
                roles.Add(COMPANY_ADMIN);
                roles.Add(PINZ_SUPERADMIN);
            }
        }
Example #2
0
        public override void Validate(string userName, string password)
        {
            if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
            {
                throw new SecurityTokenException("Username and password required");
            }

            var dbContext = new PinzDbContext("pinzDBConnectionString");
            var user      = dbContext.Users.SingleOrDefault(u => (u.EMail == userName) && (u.Password == password));

            if (user == null)
            {
                throw new FaultException($"Wrong username ({userName}) or password");
            }

            var company      = dbContext.Companies.Single(c => c.CompanyId == user.CompanyId);
            var subscription =
                dbContext.Subscriptions.Single(s => s.SubscriptionReference == company.SubscriptionReference);

            if (subscription.Status == SubscriptionStatus.Inactive)
            {
                if (subscription.Test)
                {
                    throw new FaultException($"Trial for Company ({user.Company}) expired.");
                }
                else
                {
                    throw new FaultException($"Subscription for Company ({user.Company}) has been canceled.");
                }
            }
            if (subscription.Test && (subscription.End < DateTime.Today))
            {
                subscription.Status                 = SubscriptionStatus.Inactive;
                subscription.StatusReason           = SubscriptionStatusReason.Canceled;
                dbContext.Entry(subscription).State = EntityState.Modified;
                dbContext.SaveChanges();

                throw new FaultException($"Trial for Company ({user.Company}) expired.");
            }
        }
Example #3
0
 public UserDAO(PinzDbContext context) : base(context)
 {
 }
 public SubscriptionDAO(PinzDbContext context) : base(context)
 {
 }
 public ProjectStaffDAO(PinzDbContext context) : base(context)
 {
 }
Example #6
0
 public BasicDAO(PinzDbContext context)
 {
     this.context = context;
 }
Example #7
0
 public CompanyDAO(PinzDbContext context) : base(context)
 {
 }
 public CategoryDAO(PinzDbContext context) : base(context)
 {
 }
Example #9
0
 public TaskDAO(PinzDbContext context) : base(context)
 {
 }