CheckUserPassword can't use username

Dgraph version: 20.07.1

my schema:

type User @secret(field: "password") {
  id: ID!
  user_name: String! @id
  age: int
}

I want to use user_name and password to auth,but when I use:

query {
    checkUserPassword(user_name: "peter", password: "123456") {
           id,
           user_name,
    }
}

I got an error:Unknown argument "name" on field "checkUserPassword" of type "Query"

So I check the generatedSchema, I got:

checkUserPassword(id: ID, password: String!): User

It seems that I can only use id to checkUserPassword, but I want to use user_name…
How can I keep id and use user_name to checkUserPassword?

Currently, check<Type>Password query is used to verify if the credentials are correct for ID and the secret field (password in this case).
In case there are multiple IDs as in this case, preference is given to the field which is of type ID.

You should be able to use user_name and password for auth with the following schema,

type User @secret(field: "password") {
  user_name: String! @id
  age: int
}

What is your use case that you require both ID field and user_name field with @id directive ?

We can accept this as a feature request to have multiple ID fields in check<Type>Password query if it is a popular use case.

Thanks to reply. I found that I can totaly use user_name to replace id, so the problem is solved.

2 Likes