I am developing an App that has a server side using Play Framework Scala, and a client side AngularJS.
I want to manage authentication only on the server side because I will have to secure both the API and the application itself and I want to keep the sessions "centralized" on my server.
But since I am not using Play Framework view templating (to keep my client side and my server side independant), I cannot pass the user profile information to the client side as it is done in the examples.
I tried to list my Cache and my Cookie keys on my Angular template but I can't seem to find anything there.
Is there any way I can grab the session information using Angular? having the session requested and managed by Play Framework ? (I cannot find it anywhere on the docs)
Here is how I render my Angular client side front page (Play framework only does the API routing and this front page routing)
def frontPage() = AuthenticatedAction {
request =>
val idToken = request.session.get("idToken").get
val profile = cache.get[JsValue](idToken + "profile").get
Ok.sendFile(content = new File("./public/layout.html"), inline = true).as("text/html")
}
Here is how it is done on the docs example :
def index = AuthenticatedAction { request =>
val idToken = request.session.get("idToken").get
val profile = Cache.getAs[JsValue](idToken + "profile").get
Ok(views.html.user(profile))
}
I would need to get that "profile" across to my template, but I don't want to have scala html templates : I want to keep using pure Angular templates to keep my client / server sides independants (only communicating through an API)
EDIT 21/06/2016: I did not find a way to grab my session information directly from Angular, but I was able to return it by extending my API and I like that solution better ! see https://stackoverflow.com/a/37942787/4884034