public User AuthenticateUser(string username, string password) { InternalUserData userData = Users.FirstOrDefault(u => u.Username.Equals(username) && u.HashedPassword.Equals(CalculateHash(password, u.Username))); if (userData == null) { throw new UnauthorizedAccessException("Access denied. Please provide some valid credentials(证书)."); } return(new User(userData.Id, userData.Username, "TestUser", userData.Email, userData.Roles)); }
public User AuthenticateUser(string username, string clearTextPassword) { InternalUserData userData = _users.FirstOrDefault(u => u.Username.Equals(username) && u.HashedPassword.Equals(clearTextPassword)); if (userData == null) { throw new UnauthorizedAccessException("Złe hasło lub login"); } return(new User(userData.Username, userData.Email, userData.Roles)); }
public override void Remove(Employee item) { InternalUserData i = context.Set <InternalUserData>().FirstOrDefault(x => x.Username == item.Username); context.Entry(i).State = EntityState.Deleted; context.Set <InternalUserData>().Remove(i); //context.Entry(item.Service).State = EntityState.Unchanged; base.Remove(item); context.SaveChanges(); }
public User AuthenticateUser(string username, string clearTextPassword) { InternalUserData userData = _users.FirstOrDefault(u => u.Username.Equals(username) && u.HashedPassword.Equals(CryptorEngine.Encrypt(clearTextPassword, true))); if (userData == null) { throw new UnauthorizedAccessException("Login failed, please check your user id and password."); } InternalRoleData RoleData = _roles.FirstOrDefault(u => userData.Roles.Contains(u.role)); return(new User(userData.Username, userData.Email, userData.Roles, userData.AutoLogoutTime, RoleData.pages)); }
}; // dw19Q8xM4ZOpOuTTdrBYh7VJImakLW6xvThLHWVRfFM= public User AuthenticateUser(string username, string clearTextPassword) { var res = CalculateHash(clearTextPassword, username); InternalUserData userData = _users.FirstOrDefault(u => u.Username.Equals(username) && u.HashedPassword.Equals("hMaLizwzOQ5LeOnMuj+C6W75Zl5CXXYbwDSHWW9ZOXc = ")); if (userData == null) { throw new UnauthorizedAccessException("Access denied. Please provide some valid credentials."); } return(new User(userData.Username, userData.Email, userData.Roles)); }
public override void Create(Employee item) { //context.Entry(item.Service).State = EntityState.Unchanged; base.Create(item); InternalUserData internalUserData = new InternalUserData(item.Username, item.Email, item.Phone, item.Role) { Employee = item }; context.Set <InternalUserData>().Add(internalUserData); context.Entry(internalUserData).State = EntityState.Added; context.SaveChanges(); }
public Employee AuthenticateUser(string username, string clearTextPassword) { InternalUserData userData = _users.FirstOrDefault(u => u.Username.Equals(username) && u.HashedPassword.Equals(CalculateHash(clearTextPassword, u.Username))); if (userData == null) { return(null); } Employee e; using (HotelContext context = new HotelContext()) { List <Employee> employees = context.Employees.ToList(); e = employees.Find(x => x.Username == userData.Username); } return(e); }
public UserApprovalViewModel(InternalUserData userData) { UserData = userData; }