public void LoginIntegrationTest_validParameters_Ok() { IUserDataAccess da = new UserDataAccess(); ILoginBusinessLogic login = new LoginBusinessLogic(da); Guid guid = user.Token; da.Add(user); login.Login(user.Username, user.Password); Guid tokenObtained = da.Get(user.Username).Token; Assert.AreNotEqual(guid, tokenObtained); }
public IHttpActionResult Put([FromBody] UserModel user) { try { Guid token = LoginBusinessLogic.Login(user.Username, user.Password); User obtainedUser = UserBusinessLogic.GetUser(user.Username); UserModel responseUser = UserModel.ToModel(obtainedUser); return(Ok(responseUser)); } catch (Exception e) { return(BadRequest(e.Message)); } }
private void button1_Click(object sender, EventArgs e) { string username = this.textBox1.Text; string password = this.textBox2.Text; try { Guid token = LoginBusinessLogic.Login(username, password); if (AuthBusinessLogic.IsAdmin(token)) { this.Hide(); var principal = new Principal(); principal.Show(); } else { MessageBox.Show("Usuario no es admin"); } } catch { MessageBox.Show("Username o password son incorrectos"); } }