Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Authorization::on_pushButton_login_clicked()
- {
- QString username = ui->lineEdit_username->text();
- QString password = ui->lineEdit_password->text();
- connectionIsOpened();
- QSqlQuery query;
- query.prepare("SELECT 1 FROM users WHERE username=:username AND password=:password");
- query.bindValue(":username", username);
- query.bindValue(":password", QString(QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Md5).toHex()));
- if ( query.exec() )
- {
- int cnt = 0;
- while ( query.next() ) {
- cnt++;
- }
- if (cnt == 1)
- {
- connectionIsClosed();
- this->hide();
- Analisys an;
- an.setModal(true);
- an.exec();
- }
- else if (cnt < 1)
- {
- QMessageBox::warning(this, "Error", "Login or password is not correct");
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement