1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | class RestApi @Inject() ( val messagesApi: MessagesApi, val env:Environment[User,CookieAuthenticator]) extends Silhouette[User,CookieAuthenticator] { def profile = SecuredAction.async { implicit request => val json = Json.toJson(request.identity.profileFor(request.authenticator.loginInfo).get) val prunedJson = json.transform( (__ \ 'loginInfo).json.prune andThen (__ \ 'passordInfo).json.prune andThen (__ \ 'oauth1Info).json.prune) prunedJson.fold( _ => Future.successful(InternalServerError(Json.obj("error" -> Messages("error.profileError")))), js => Future.successful(Ok(js)) ) } override def onNotAuthenticated(request:RequestHeader) = { Some(Future.successful(Unauthorized(Json.obj("error" -> Messages("error.profileUnauth"))))) } } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |