LoginSignup
1
1

More than 5 years have passed since last update.

PlayでOpenIDのサンプルが間違っていた件

Posted at

def loginPost = Action { implicit request =>
  Form(single(
    "openid" -> nonEmptyText
  )).bindFromRequest.fold(
    error => {
      Logger.info("bad request " + error.toString)
      BadRequest(error.toString)
    },
    {
      case (openid) => AsyncResult(OpenID.redirectURL(openid, routes.Application.openIDCallback.absoluteURL())
          .extend( _.value match {
              case Redeemed(url) => Redirect(url)
              case Thrown(t) => Redirect(routes.Application.login)
          }))
    }
  )
}

def openIDCallback = Action { implicit request =>
  AsyncResult(
    OpenID.verifiedId.extend( _.value match {
      case Redeemed(info) => Ok(info.id + "\n" + info.attributes)
      case Thrown(t) => {
        // Here you should look at the error, and give feedback to the user
        Redirect(routes.Application.login)
      }
    })
  )
}

の中にOpenID.redirectURL(openid, routes.Application.openIDCallback.absoluteURL())
.extend
みたいな所あるけど、2.1のFutureにextendなんてないので適宜書き換えましょう。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1