示例#1
0
 public void EnsureDefaultUser()
 {
     string username = "******";
     AccountDataProvider accountDal = new AccountDataProvider();
     if (!accountDal.UserExists(username))
     {
         accountDal.InsertUser(username, "*****@*****.**" , Utils.BCrypt.HashPassword("gandon", Utils.BCrypt.GenerateSalt()));
     }
 }
示例#2
0
 public User Login(string userOrMail, string pwd)
 {
     AccountDataProvider dal = new AccountDataProvider();
     BsonDocument doc = dal.GetUserByLogin(userOrMail);
     if (doc != null && doc.ElementCount > 0 && Utils.BCrypt.CheckPassword(pwd, doc["pwd_hash"].AsString))
     {
         if (doc["role"] == "Admin")
         {
             return new User(doc);
         }
     }
     return null;
 }
示例#3
0
 public User GetUser(string username)
 {
     AccountDataProvider dal = new AccountDataProvider();
     return new User(dal.GetUserByLogin(username));
 }