Results 1 to 10 of 10

Thread: Suggestions on Login Prompt

  1. #1
    Join Date
    Jul 2006
    Location
    Atlanta, GA
    Posts
    86
    Thanks
    26
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question 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:

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include <QDesktopWidget>
    3. #include <QSqlError>
    4. #include <QMessageBox>
    5. #include <QSqlDatabase>
    6.  
    7. #include "entryform.h"
    8. #include "mainwindow.h"
    9. #include "logindialog.h"
    10.  
    11. int main(int argc, char *argv[])
    12. {
    13. QString strRejected = "";
    14. QApplication a(argc, argv);
    15. LoginDialog dlg;
    16. dlg.setWindowTitle("Login");
    17. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    18. if( dlg.exec() == QDialog::Accepted ){
    19. db.setHostName(dlg.loginDlgUi.serverLE->text());
    20. db.setDatabaseName(dlg.loginDlgUi.databaseLE->text());
    21. db.setUserName(dlg.loginDlgUi.usernameLE->text());
    22. db.setPassword(dlg.loginDlgUi.passwordLE->text());
    23. if ( db.open() ) {
    24. MainWindow w;
    25. QRect r = w.geometry();
    26. r.moveTopLeft(QApplication::desktop()->availableGeometry().topLeft());
    27. w.setGeometry(r);
    28.  
    29. w.resize(800, 650);
    30. w.show();
    31. return a.exec();
    32. }
    33. } else {
    34. QMessageBox::information(0,"Login Canceled!","Login Canceled!");
    35. return 1;
    36. }
    37. strRejected = QString("The Login was rejected because: %1").arg(db.lastError().text()).toLatin1();
    38. QMessageBox::information(0,"Login Rejected!",strRejected);
    39. return 2;
    40. };
    To copy to clipboard, switch view to plain text mode 

    Thanks in advance

    fnmblot
    fnmblot
    --------------------------------------
    Gee Ricky, I'm sorry your mom blew up.

  2. #2
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Suggestions on Login Prompt

    This looks like login for a database administrator?

    Did you try phpMyAdmin?

  3. #3
    Join Date
    Jul 2006
    Location
    Atlanta, GA
    Posts
    86
    Thanks
    26
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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.
    fnmblot
    --------------------------------------
    Gee Ricky, I'm sorry your mom blew up.

  4. #4
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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...

  5. #5
    Join Date
    Jul 2006
    Location
    Atlanta, GA
    Posts
    86
    Thanks
    26
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Suggestions on Login Prompt

    That is what I am thinking, but can you point me to an example on how to do this?
    fnmblot
    --------------------------------------
    Gee Ricky, I'm sorry your mom blew up.

  6. #6
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Suggestions on Login Prompt

    Quote Originally Posted by fnmblot View Post
    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

  7. #7
    Join Date
    May 2008
    Location
    Melbourne, Australia
    Posts
    136
    Thanks
    9
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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

  8. The following user says thank you to rbp for this useful post:

    fnmblot (21st May 2009)

  9. #8
    Join Date
    Jul 2006
    Location
    Atlanta, GA
    Posts
    86
    Thanks
    26
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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?
    fnmblot
    --------------------------------------
    Gee Ricky, I'm sorry your mom blew up.

  10. #9
    Join Date
    May 2008
    Location
    Melbourne, Australia
    Posts
    136
    Thanks
    9
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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!

  11. #10
    Join Date
    May 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Suggestions on Login Prompt

    Maybe this can help to you
    Attached Files Attached Files

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.