Giter VIP home page Giter VIP logo

Comments (2)

Jonarod avatar Jonarod commented on June 12, 2024 1

Ok my bad, the correct mutation to create a new user should be SignupUser instead of CreateUser, like this:

mutation {
  signupUser(email: "[email protected]", password: "MySecretPassword") {
    token
  }
}

Then everything works fine.

Got it in the official forum here:
http://www.prisma.io/forum/t/template-auth-email-password-is-not-working/1805/3

from graphcool-templates.

Jonarod avatar Jonarod commented on June 12, 2024

Reproduced the same problem using Graphcool shared servers.
Here are the steps:

  1. Create a new project:
graphcool init
  1. Add email auth template:
graphcool-framework add-template auth/email-password
  1. Uncomment proper lines in types.graphql and graphcool.yml

here is my final types.graphql:

type User @model {
  id: ID! @isUnique # read-only (managed by Graphcool)

  createdAt: DateTime! # read-only (managed by Graphcool)
  updatedAt: DateTime! # read-only (managed by Graphcool)

  email: String! @isUnique
  password: String!
}

here is my final graphcool.yml

types: ./types.graphql

functions:
  signup:
    type: resolver
    schema: src/email-password/signup.graphql
    handler:
      code: src/email-password/signup.ts

  authenticate:
    type: resolver
    schema: src/email-password/authenticate.graphql
    handler:
      code: src/email-password/authenticate.ts

  loggedInUser:
    type: resolver
    schema: src/email-password/loggedInUser.graphql
    handler:
      code: src/email-password/loggedInUser.ts

  hello:
    handler:
      code: src/hello.js
    type: resolver
    schema: src/hello.graphql

permissions:
  - operation: "*"

  1. Deploy project to shared servers:
graphcool deploy

I deployed to eu-west1

  1. Go to the graphiQL console provided by the deploy command

  2. Create a new user:

mutation {
  createUser (email: "[email protected]", password: "MySecretPassword") {
    id
  }
}
  1. Check the user is created:
query {
  allUsers {
    id
    email
    password
  }
}

returns

{
  "data": {
    "allUsers": [
      {
        "id": "cjlr396u51c0l0138gllo608y",
        "email": "[email protected]",
        "password": "MySecretPassword"
      }
    ]
  }
}

This is already wrong: the value in the password field should be hashed and not displayed in clear. It should be a gibberish like: dufeiugug78TugDHSLIKgdsjgkguk or something like that.

  1. Authenticate user:
mutation {
  authenticateUser (email: "[email protected]", password: "MySecretPassword") {
    token
  }
}

returns error:

{
  "data": {
    "authenticateUser": null
  },
  "errors": [
    {
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "functionError": "Invalid credentials!",
      "path": [
        "authenticateUser"
      ],
      "code": 5001,
      "message": "function execution error: Invalid credentials!",
      "requestId": "eu-west-1:simple:cjlr3apz512gc01392k8afi0n"
    }
  ]
}

Did I miss something ?!

from graphcool-templates.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.