Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Verifying User Login
Forum Updated to NodeBB v4.3 + New Features

Verifying User Login

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 2 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    That's something you need to do at the backend level.

    But why would you need your user to tell you which department(s) they belong to as part of their login data ? It's typically something that is stored as part of the user profile/data and not something that one needs to provide.

    On a side note, I hope this is just testing code because otherwise you are either using plain text password in your database or doing some password encoding on the client side which neither is a good idea.

    By the way, please post your code as text not images. There are coding tags that you can use (the </> button in the editor toolbar).

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    C 1 Reply Last reply
    2
    • SGaistS SGaist

      Hi,

      That's something you need to do at the backend level.

      But why would you need your user to tell you which department(s) they belong to as part of their login data ? It's typically something that is stored as part of the user profile/data and not something that one needs to provide.

      On a side note, I hope this is just testing code because otherwise you are either using plain text password in your database or doing some password encoding on the client side which neither is a good idea.

      By the way, please post your code as text not images. There are coding tags that you can use (the </> button in the editor toolbar).

      C Offline
      C Offline
      CEO.
      wrote on last edited by
      #3

      @SGaist thanks for your contribution. If you read the post again, you will see where I stated that I want only a particular department to be able to access this particular platform (Window) called "Special Project".

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        I read and understood your question.

        My own questions are still valid.

        My remarques about doing the check on the backend side is still valid as well.

        Your code does a check using the department name but the code is wrong as you are breaking the string the way you try to do it.

        In any case, since you are on Python, I would recommend taking a look at SQLAlchemy's ORM. This will help you write simpler and cleaner code rather than building all your queries by hand.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        C 1 Reply Last reply
        2
        • SGaistS SGaist

          I read and understood your question.

          My own questions are still valid.

          My remarques about doing the check on the backend side is still valid as well.

          Your code does a check using the department name but the code is wrong as you are breaking the string the way you try to do it.

          In any case, since you are on Python, I would recommend taking a look at SQLAlchemy's ORM. This will help you write simpler and cleaner code rather than building all your queries by hand.

          C Offline
          C Offline
          CEO.
          wrote on last edited by
          #5

          @SGaist thanks once agan for your time. I know I'm wrong. I was only trying that code to see what could work. I need the right code to achieve my aim.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #6

            Sorry if I sound brutal but you should rather get a better understanding of how managing users works than ready made code.

            From the looks of it, you are accessing your school's main database, correct ?

            If so there's likely already some documented way to access these information.

            If not, then I would highly recommande to first take a look at how this can be implemented with frameworks like Django.

            If accessing a readymade database, then again, take a look at SQLAlchemy's ORM to handle the database communication/query part.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            C 2 Replies Last reply
            2
            • SGaistS SGaist

              Sorry if I sound brutal but you should rather get a better understanding of how managing users works than ready made code.

              From the looks of it, you are accessing your school's main database, correct ?

              If so there's likely already some documented way to access these information.

              If not, then I would highly recommande to first take a look at how this can be implemented with frameworks like Django.

              If accessing a readymade database, then again, take a look at SQLAlchemy's ORM to handle the database communication/query part.

              C Offline
              C Offline
              CEO.
              wrote on last edited by
              #7

              @SGaist never mind. It's obvious you have no clue. Anything that can be imagined can be made possible. Don't worry, I will come up with something and fix it before the week runs out if I'm less busy.

              I love programming, if one can think logically, one can manipulate things. I've programmed some projects lime this before using conditions. I hope to do so with this just that I've been too busy with lot of tasks.

              Once again, thanks for your time.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #8

                @CEO said in Verifying User Login:

                @SGaist never mind. It's obvious you have no clue

                I sure have no clue about the database you are using to store your user information as you did not give any information about it nor did you say the exact error you are hitting.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                C 1 Reply Last reply
                1
                • SGaistS SGaist

                  Sorry if I sound brutal but you should rather get a better understanding of how managing users works than ready made code.

                  From the looks of it, you are accessing your school's main database, correct ?

                  If so there's likely already some documented way to access these information.

                  If not, then I would highly recommande to first take a look at how this can be implemented with frameworks like Django.

                  If accessing a readymade database, then again, take a look at SQLAlchemy's ORM to handle the database communication/query part.

                  C Offline
                  C Offline
                  CEO.
                  wrote on last edited by
                  #9

                  @SGaist I am the one writing the application and commanding the systems in what to do at any instance. It's all about IF and ELSE.

                  1 Reply Last reply
                  0
                  • SGaistS SGaist

                    @CEO said in Verifying User Login:

                    @SGaist never mind. It's obvious you have no clue

                    I sure have no clue about the database you are using to store your user information as you did not give any information about it nor did you say the exact error you are hitting.

                    C Offline
                    C Offline
                    CEO.
                    wrote on last edited by
                    #10

                    @SGaist Eureka!!!
                    I just got it right!!

                    Now see how I resolved it.

                    result = conn.execute("SELECT * FROM tableName WHERE usernameID = ? AND pw = ? AND department = 'Computer Science' ", (username, password) )

                    Eureka!

                    If you can imagine it, then it can happen.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      That is what my answer contained.

                      @SGaist said in Verifying User Login:

                      Your code does a check using the department name but the code is wrong as you are breaking the string the way you try to do it.

                      Since you are commanding that stuff, I stand by my suggestions about database handling. You really should use a framework that allows modeling of your data and also please do not store password in plaintext.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      C 2 Replies Last reply
                      2
                      • SGaistS SGaist

                        That is what my answer contained.

                        @SGaist said in Verifying User Login:

                        Your code does a check using the department name but the code is wrong as you are breaking the string the way you try to do it.

                        Since you are commanding that stuff, I stand by my suggestions about database handling. You really should use a framework that allows modeling of your data and also please do not store password in plaintext.

                        C Offline
                        C Offline
                        CEO.
                        wrote on last edited by
                        #12

                        @SGaist I made it clear that the code in the attached photo was wrong, thus I came here seeking for ideas on what to do. If the line of code was correct, why would I come seeking for help please?

                        1 Reply Last reply
                        0
                        • SGaistS SGaist

                          That is what my answer contained.

                          @SGaist said in Verifying User Login:

                          Your code does a check using the department name but the code is wrong as you are breaking the string the way you try to do it.

                          Since you are commanding that stuff, I stand by my suggestions about database handling. You really should use a framework that allows modeling of your data and also please do not store password in plaintext.

                          C Offline
                          C Offline
                          CEO.
                          wrote on last edited by CEO.
                          #13

                          @SGaist again if you look at my line of code for the SQL statement, you would have seen the statement was actually correct, the error I made was enclosing the name of the department in double quotes like this ... "Computer Science". Microsoft SQL doesn't accept double quotes for string values (varchar) as in my case.
                          I should have enclosed it in a single quote like this ... department = 'Computer Science'

                          The data type for the field department in my table is varchar(30)

                          The library I'm using is pyodbc.

                          PyQt5 gui framework.

                          I should have given more details in my opening post. I thought I did actually.

                          MySql uses double quotes for string values, Microsoft SQL uses single quotes

                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #14

                            And again as well, the image of the code you posted shows that your Python code is invalid. As I already explained, your use of double quotes breaks the line of code itself. The fact that your DB server does not handle double quotes is an entirely different issue that cannot be deduced neither by the information nor the code you provided.

                            Since you did not tell which type of database you were using, nor the exact error(s) you were getting, the only obvious one was the fact that that line was invalid code.

                            On a side note, the double quote handling of MySQL is in fact non standard so you were currently lucky with that one.

                            Since you are using Qt, you might want to take a look at the Qt SQL module.

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            2

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved