Exemple #1
0
 public TransitLogin(DBlog.Data.Login o)
     : base(o.Id)
 {
     Email    = o.Email;
     Name     = o.Name;
     Password = o.Password;
     Username = o.Username;
     Website  = o.Website;
     Role     = (TransitLoginRole)Enum.Parse(typeof(TransitLoginRole), o.Role);
 }
Exemple #2
0
        public static bool IsAdministrator(ISession session, string ticket)
        {
            if (string.IsNullOrEmpty(ticket))
            {
                return(false);
            }
            int id = GetLoginId(ticket);

            DBlog.Data.Login login = (DBlog.Data.Login)session.Load(typeof(DBlog.Data.Login), id);
            return((TransitLoginRole)Enum.Parse(typeof(TransitLoginRole), login.Role) == TransitLoginRole.Administrator);
        }
Exemple #3
0
        public LoginTest()
        {
            mLogin = new Login();

            mLogin.Email = Guid.NewGuid().ToString().Substring(0, 31);
            mLogin.Name = Guid.NewGuid().ToString();
            mLogin.Password = Guid.NewGuid().ToString().Substring(0, 31);
            mLogin.Role = Guid.NewGuid().ToString();
            mLogin.Username = Guid.NewGuid().ToString();
            mLogin.Website = Guid.NewGuid().ToString();
        }
Exemple #4
0
        public static TransitLogin LoginMd5(ISession session, string username, string passwordhash)
        {
            // find a verified e-mail associated with an Login with the same password
            DBlog.Data.Login l = (DBlog.Data.Login)session.CreateCriteria(typeof(DBlog.Data.Login))
                                 .Add(Expression.Eq("Username", username))
                                 .UniqueResult();

            if (l == null || l.Password != passwordhash)
            {
                throw new AccessDeniedException();
            }

            return(new TransitLogin(l));
        }