Query password

i am using DQL and create an entity set up with the schema set for the property as the password type. Password can’t be queried directly, I want how to check if my password I entered is the same or not with the ones i put before

This question is really not clear to me. Can you clarify? Are you using GraphQL or DQL? Is the Auth feature that you are using? Can you share some code and samples?

2 Likes

Sorry, my bad! my English skill is not good.
In this case, i using DQL and put an entity set up with the schema set for the property as the password type. Password can’t be queried directly, I want how to check if my password I entered is the same or not with the ones i put before.

Okay, I got it.

Well, about your English Skills, that’s not important. As long you pass through your story with as much details as possible we’re good. It doesn’t matter if you had typo or something. We are here to help, not judge your grammar :stuck_out_tongue:

About the Password Type. The pass type is a special type. It creates hashes of the string automatically in a safe way. So you don’t have to come up with a custom procedure like Bcrypt or something. Dgraph does not write the password to the database. This is extremely unsafe. We only record the password hash. And when the password is re-entered in a new query, Dgraph compares the supplied password with the Hash recorded in the database.

You may have thought that the Password Type would create some kind of verification and login out of the box. That’s not True. It just create hashes, nothing more. The whole login implementation have to come from you. In the case of DQL. In GraphQL we have an Auth system for free if you are willing to use GraphQL. In the other hand, with DQL you have to do several thing by the hand.

When you query like

{
  check(func: uid(0x123)) {
    name
    checkpwd(pass, "ThePassword")
  }
}

It will check if the given string is the valid password. Returning "checkpwd(pass)": true or False.

See more at https://dgraph.io/docs/query-language/schema/#password-type

3 Likes