public IHttpActionResult ValidateUserRegister([FromBody] Usuario user) { if (!PersonaExists(user.Matricula)) { log.Ok = false; log.ErrorMessage = "Esta persona no esta registrada"; return(Ok(log)); } if (UserExists(user.Matricula)) { log.Ok = false; log.ErrorMessage = "Este usuario ya esta registrado"; return(Ok(log)); } try { user.Pass = CryptoPass.Hash(user.Pass); // INSERT INTO tblPersona (idPersona, Password) // VALUES (@Matricula, @Pass) db.AddUser(user.Matricula, user.Pass); db.SaveChanges(); Good(log); } catch (Exception) { log.Ok = false; log.ErrorMessage = "Hubo un problema al agregar el usuario"; } return(Ok(log)); }
public void TestUserLogin() { //Arrange var result = false; var userModel = new UserLoginModel { email = "*****@*****.**", password = "******" }; if (userModel.email != null && userModel.password != null) { //Act User userExist = MainClass.Instance.getUsers().Find(v => v.email == userModel.email); if (userExist != null) { if (userExist.isEmailVerified) { if (string.Compare(CryptoPass.Hash(userModel.password), userExist.password) == 0) { result = true; } } } } //Assert Assert.IsTrue(result); }
public IHttpActionResult ValidateUserLogin([FromBody] Usuario user) { Good(log); if (!UserExists(user.Matricula)) { log.Ok = false; log.ErrorMessage = "ID/Matricula no registrada"; return(Ok(log)); } // SELECT Pass FROM tblUsuario WHERE idPersona = @idPersona var validPassword = db.GetPassword(user.Matricula).FirstOrDefault(); if (CryptoPass.Hash(user.Pass) != validPassword) { log.Ok = false; log.ErrorMessage = "Usuario/contraseƱa no valida"; return(Ok(log)); } return(Ok(log)); }