Advertisement
Guest User

Untitled

a guest
Dec 5th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. void Authorization::on_pushButton_login_clicked()
  2. {
  3.     QString username = ui->lineEdit_username->text();
  4.     QString password = ui->lineEdit_password->text();
  5.  
  6.     connectionIsOpened();
  7.     QSqlQuery query;
  8.     query.prepare("SELECT 1 FROM users WHERE username=:username AND password=:password");
  9.     query.bindValue(":username", username);
  10.     query.bindValue(":password", QString(QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Md5).toHex()));
  11.     if ( query.exec() )
  12.     {
  13.         int cnt = 0;
  14.  
  15.         while ( query.next() ) {
  16.             cnt++;
  17.         }
  18.  
  19.         if (cnt == 1)
  20.         {
  21.  
  22.             connectionIsClosed();
  23.             this->hide();
  24.             Analisys an;
  25.             an.setModal(true);
  26.             an.exec();
  27.         }
  28.  
  29.         else if (cnt < 1)
  30.         {
  31.             QMessageBox::warning(this, "Error", "Login or password is not correct");
  32.             return;
  33.         }
  34.     }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement