Suggestions on Login Prompt
I was wondering if anyone could direct me to an example of a login prompt that has a check box to "Remember Login Info." I would like to just write to a hidden file in the user's home directory if that kind of helps.
Here is what my main.cpp looks like that calls the login prompt, or maybe I should do it in the logindialog.cpp:
Code:
#include <QtGui/QApplication>
#include <QDesktopWidget>
#include <QSqlError>
#include <QMessageBox>
#include <QSqlDatabase>
#include "entryform.h"
#include "mainwindow.h"
#include "logindialog.h"
int main(int argc, char *argv[])
{
LoginDialog dlg;
dlg.setWindowTitle("Login");
if( dlg.
exec() == QDialog::Accepted ){ db.setHostName(dlg.loginDlgUi.serverLE->text());
db.setDatabaseName(dlg.loginDlgUi.databaseLE->text());
db.setUserName(dlg.loginDlgUi.usernameLE->text());
db.setPassword(dlg.loginDlgUi.passwordLE->text());
if ( db.open() ) {
MainWindow w;
r.
moveTopLeft(QApplication::desktop()->availableGeometry
().
topLeft());
w.setGeometry(r);
w.resize(800, 650);
w.show();
return a.exec();
}
} else {
QMessageBox::information(0,
"Login Canceled!",
"Login Canceled!");
return 1;
}
strRejected
= QString("The Login was rejected because: %1").
arg(db.
lastError().
text()).
toLatin1();
QMessageBox::information(0,
"Login Rejected!",strRejected
);
return 2;
};
Thanks in advance
fnmblot
Re: Suggestions on Login Prompt
This looks like login for a database administrator?
Did you try phpMyAdmin?
Re: Suggestions on Login Prompt
yes, but I am designing a database entry/view/purchasing system for cataloging Music Scores for my publishing company. I do not want to use phpMyAdmin.
Re: Suggestions on Login Prompt
ok...
You can save the username/password in a binary format of your own choice so no one else knows the format, you also want the file to be protected so only the account owner has read permission...
On successful login, fire up your DB management window, otherwise, kick him out...
Re: Suggestions on Login Prompt
That is what I am thinking, but can you point me to an example on how to do this?
Re: Suggestions on Login Prompt
Quote:
Originally Posted by
fnmblot
That is what I am thinking, but can you point me to an example on how to do this?
There are a lot of examples that come with Qt source....
Check this website and see what its login screen look like: https://www.secform4.com/account/login
Re: Suggestions on Login Prompt
I remember my apps last login details with QSettings. On Linux this will store the data under the home directory and on Windows in the registry.
If you're concerned about security you could encrypt the login details before saving.
Richard
Re: Suggestions on Login Prompt
Thanks a million rbp. I used QSettings and it works wonderfully. I am just curious though, how could I encrypt the password using QSettings?
Re: Suggestions on Login Prompt
I don't believe Qt has such a library. The closest one is the cryptographic library for generating a hash of a string. Could you store your passwords as hashes?
If the user data is very sensitive you could investigate gnupg or cryptocpp, but they seem over the top for your case.
Perhaps something simple like the Caesar cipher will do!
2 Attachment(s)
Re: Suggestions on Login Prompt
Maybe this can help to you