0

function that receives an author object in the request

  def login = Action.async (parse.json) {
    request => 
      request.body.validate[Author].map {
        author => 
          val query = Json.obj("username" -> "222")
          val obj = collection.find(query).one[Author]
          obj.map {
           author => 
            Ok("Welcome").withSession (
              "username" -> "ok")
          }
      }.getOrElse(Future.successful(BadRequest("invalid json")))
  }

always results in a bad request, even with hard coded username. What's wrong here?

Johny T Koshy
  • 3,857
  • 2
  • 23
  • 40
user1538814
  • 201
  • 1
  • 3
  • 13

1 Answers1

0

Changed login to a post. Seems to be working now.

POST    /author/login               @controllers.Authors.login
user1538814
  • 201
  • 1
  • 3
  • 13