public User Login(User user) { var cypherPassword = StringSecurity.Hash(user.Password); var foundUser = INoteContext.Users.SingleOrDefault(u => u.Username.Equals(user.Username)); if (foundUser != null && StringSecurity.Verify(user.Password, foundUser.Password)) { return(foundUser); } return(null); }
public User Register(User user) { var registeredUser = user; IEnumerable <User> enumerable = Find(u => u.Username.Equals(user.Username)); if (enumerable.Any()) { return(null); } registeredUser.Password = StringSecurity.Hash(user.Password); return(INoteContext.Users.Add(registeredUser)); }