public void EnsureDefaultUser() { string username = "******"; AccountDataProvider accountDal = new AccountDataProvider(); if (!accountDal.UserExists(username)) { accountDal.InsertUser(username, "*****@*****.**" , Utils.BCrypt.HashPassword("gandon", Utils.BCrypt.GenerateSalt())); } }
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; }
public User GetUser(string username) { AccountDataProvider dal = new AccountDataProvider(); return new User(dal.GetUserByLogin(username)); }