-
Notifications
You must be signed in to change notification settings - Fork 142
Implement the new Play 2.4 messages API #335
Conversation
@akkie is it possible to do that without spray the maybe one solution could be convert WDYT? |
The
In my opinion, as the default behavior, it is better to define the lang in the entry point(Controller) and then pass it around to the other components. If a user needs another |
My concern is that now need to every There are 4 place where have The only one that use I agree that the best point to set Lang is the |
The One big problem with Secure Social was, that it wasn't possible to internationalize your application. This was one of the main reasons I've forked the library and created Silhouette. I see your concern, but I think omitting the
I'm not sure if it easily possible to replace the |
@rfranco What do you think about something like this? |
@akkie it's looks ok but i don't know if that is realy necessary create a wrapper for trait Environment[I <: Identity, T <: Authenticator] {
def identityService: IdentityService[I]
def authenticatorService: AuthenticatorService[T]
def requestProviders: Seq[RequestProvider]
def eventBus: EventBus
def messagesApi: MessageApi
}
trait Silhouette[I <: Identity, A <: Authenticator] extends Controller with Logger with play.api.i18n.I18nSupport {
lazy val messagesApi: MessagesApi = env.messagesApi
} WDYT? |
Let me put it this way: Silhouette depends on the Play messages support. So why not! I'll change it and update the pull request. Thanks, for the suggestion! |
@rfranco Please could you review it again? |
* @return True if the user is authorized, false otherwise. | ||
*/ | ||
def isAuthorized(identity: I)(implicit request: RequestHeader, lang: Lang): Boolean | ||
def isAuthorized(identity: I)(implicit request: RequestHeader, messages: Messages): Boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary Messages
as param?
because it's possible to do that
class I18nAuthorization (implicit messagesApi: MessagesApi) extends Authorization[User] with I18nSupport {
def isAuthorized(identity: User)(implicit request: RequestHeader): Unit = {
val messages: Messages = request2Messages
...
}
}
I thought we agreed that it's the best to define the Messages in the controller so that the user must not override the logic in different places in case of different lang sources. Inside a Silhouette controller the |
@akkie Ok, i agreed, looks good to go! |
Implement the new Play 2.4 messages API
See: https://www.playframework.com/documentation/2.4.x/ScalaI18N