Exemplo n.º 1
0
 private void CreateAdmin()
 {
     using (var session = DomainAccess.Instance.CurrentSession.OpenSession())
     {
         Security.PasswordManager pwdmng = new Security.PasswordManager();
         using (ITransaction transaction = session.BeginTransaction())
         {
             Domain.User adminusr = new Domain.User();
             adminusr.UserID   = 0;
             adminusr.Username = "******";
             adminusr.FullName = "Miguel Jimenez";
             adminusr.Password = pwdmng.HashPassword(adminusr.Username, "123456789");
             session.Save(adminusr);
             transaction.Commit();
         }
     }
 }
Exemplo n.º 2
0
 private bool ValidateUser(string username, string password)
 {
     Sirloin.Domain.User      result;
     Security.PasswordManager pmanager = new Security.PasswordManager();
     using (var session = DomainAccess.Instance.CurrentSession.OpenSession())
     {
         result = session.Query <Domain.User>().FirstOrDefault <Domain.User>(x => x.Username.ToLower() == username.ToLower());
     }
     if (result != null)
     {
         //user was found
         return(pmanager.IsValidPassword(username, password, result.Password));
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 3
0
        private void CreateAdmin()
        {
            using (var session = DomainAccess.Instance.CurrentSession.OpenSession())
            {
                Security.PasswordManager pwdmng = new Security.PasswordManager();
                using (ITransaction transaction = session.BeginTransaction())
                {
                    Domain.User adminusr = new Domain.User();
                    adminusr.UserID = 0;
                    adminusr.Username = "******";
                    adminusr.FullName = "Miguel Jimenez";
                    adminusr.Password = pwdmng.HashPassword(adminusr.Username, "123456789");
                    session.Save(adminusr);
                    transaction.Commit();
                }

            }
        }
Exemplo n.º 4
0
 private bool ValidateUser(string username, string password)
 {
     Sirloin.Domain.User result;
     Security.PasswordManager pmanager = new Security.PasswordManager();
     using (var session = DomainAccess.Instance.CurrentSession.OpenSession())
     {
         result = session.Query<Domain.User>().FirstOrDefault<Domain.User>(x => x.Username.ToLower() == username.ToLower());
     }
     if (result != null)
     {
         //user was found
         return pmanager.IsValidPassword(username, password, result.Password);
     }
     else
     {
         return false;
     }
 }