How to retrieved password in PasswordInfo

89 views
Skip to first unread message

Sanx El Santo

unread,
Jun 25, 2015, 5:00:31 PM6/25/15
to play-si...@googlegroups.com
Hi

I'm working on the implementation of the authentication module

my code is this:

  def find(loginInfo: LoginInfo) = {

    println("loginInfo.providerID :" + loginInfo.providerID + "\n")
    println("loginInfo.providerKey :" + loginInfo.providerKey + "\n")

    val passwordInfo: Future[Option[PasswordInfo]] = collection.find(Json.obj( "loginInfo" -> loginInfo )).one[PasswordInfo]

    passwordInfo.flatMap {
      case None =>
        println("None: ")
        Future.successful(Option.empty[PasswordInfo])
      case Some(fullDoc) =>
        println("fullDoc: " + fullDoc)
        Future( Some( fullDoc ) )
    }

    //Future.successful(data.get(loginInfo))

  }

My code compile fine, but at runtime, the console show me this:

[info] play - Starting application default Akka system.
[error] play - Cannot invoke the action, eventually got an error: java.lang.RuntimeException: JsError(List((/hasher,List(ValidationError(error.path.missing,WrappedArray()))), (/password,List(ValidationError(error.path.missing,WrappedArray())))))
[error] application -

! @6mi3e77hb - Internal server error, for (POST) [/signin] ->

play.api.Application$$anon$1: Execution exception[[RuntimeException: JsError(List((/hasher,List(ValidationError(error.path.missing,WrappedArray()))), (/password,List(ValidationError(error.path.missing,WrappedArray())))))]]
    at play.api.Application$class.handleError(Application.scala:296) ~[play_2.11-2.3.8.jar:2.3.8]
    at play.api.DefaultApplication.handleError(Application.scala:402) [play_2.11-2.3.8.jar:2.3.8]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [play_2.11-2.3.8.jar:2.3.8]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [play_2.11-2.3.8.jar:2.3.8]
    at scala.Option.map(Option.scala:146) [scala-library-2.11.6.jar:na]
Caused by: java.lang.RuntimeException: JsError(List((/hasher,List(ValidationError(error.path.missing,WrappedArray()))), (/password,List(ValidationError(error.path.missing,WrappedArray())))))
    at scala.sys.package$.error(package.scala:27) ~[scala-library-2.11.6.jar:na]
    at play.api.libs.iteratee.Iteratee$$anonfun$run$1.apply(Iteratee.scala:355) ~[play-iteratees_2.11-2.3.8.jar:2.3.8]
    at play.api.libs.iteratee.Iteratee$$anonfun$run$1.apply(Iteratee.scala:348) ~[play-iteratees_2.11-2.3.8.jar:2.3.8]
    at play.api.libs.iteratee.StepIteratee$$anonfun$fold$2.apply(Iteratee.scala:670) ~[play-iteratees_2.11-2.3.8.jar:2.3.8]
    at play.api.libs.iteratee.StepIteratee$$anonfun$fold$2.apply(Iteratee.scala:670) ~[play-iteratees_2.11-2.3.8.jar:2.3.8]


my mistake is associated with:

passwordInfo, here the code:

https://github.com/hectorgool/reactivemongo-silhouette-rest/blob/master/app/models/daos/PasswordInfoDAO.scala#L72

Can anyone tell me I'm doing wrong or what I'm missing?

I do not know how to get the value to return the find method


Thank you for your help



Christian Kaps

unread,
Jun 26, 2015, 2:17:29 AM6/26/15
to play-si...@googlegroups.com, hecto...@gmail.com
Hi,

You store the Json:
{
 
"loginInfo": {
     
"providerID": "",
     
"providerKey": ""
   
},
   
"authInfo": {
     
"hasher": "",
     
"password": "",
     
"salt": ""
   
}
}

But you try to query only the Json:
{
  "hasher": "",
 
"password": "",
 
"salt": ""
}

This doesn't work. You must query the same Json as you store or you use the MongoDB aggregate functions to query a sub document.

Best regards,
Christian



The Json object you store has the wrong format.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages