public Boolean ModifyUser(string token, User userNuevo) { Encripter encripter = new Encripter(); var valor = encripter.Desencripta(token); var objeto = JsonConvert.DeserializeObject <Token>(valor); var user = this.dataService.GetUserByName(objeto.Name); if (user != null) { if (!this.dataService.GetAllUsers().Any(u => u.Name.Equals(userNuevo.Name))) { user.Name = userNuevo.Name; user.Password = userNuevo.Password; return(this.dataService.UpdateUser(user)); } else { return(false); } } else { return(false); } }
public User Authenticate(string token) { if (!String.IsNullOrEmpty(token)) { Encripter encripter = new Encripter(); var valor = encripter.Desencripta(token); var objeto = JsonConvert.DeserializeObject <Token>(valor); if (objeto.Time > DateTime.Now) { if (UserExists(objeto.Name, objeto.Password)) { return(this.dataService.GetUserByName(objeto.Name)); } else { return(null); } } else { return(null); } } else { return(null); } }