alunosnet

UserLogin

Jan 21st, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. public class UserLogin
  2. {
  3. BaseDados bd;
  4.  
  5. public UserLogin()
  6. {
  7. this.bd = new BaseDados();
  8. }
  9.  
  10. public DataTable verificaLogin(string email, string password)
  11. {
  12. string sql = $@"SELECT * FROM Utilizadores WHERE
  13. email=@email AND password=HASHBYTES('SHA2_512',@password)
  14. AND estado=1";
  15. List<SqlParameter> parametros = new List<SqlParameter>()
  16. {
  17. new SqlParameter()
  18. {
  19. ParameterName="@email",
  20. SqlDbType=SqlDbType.VarChar,
  21. Value=email
  22. },
  23. new SqlParameter()
  24. {
  25. ParameterName="@password",
  26. SqlDbType=SqlDbType.VarChar,
  27. Value=password
  28. }
  29. };
  30. DataTable utilizador = bd.devolveSQL(sql, parametros);
  31. if (utilizador == null || utilizador.Rows.Count == 0)
  32. return null;
  33.  
  34. return utilizador;
  35. }
  36. }
Add Comment
Please, Sign In to add comment