Skip to content
This repository has been archived by the owner on Sep 12, 2021. It is now read-only.

Update actions.rst #263

Closed
wants to merge 1 commit into from
Closed

Update actions.rst #263

wants to merge 1 commit into from

Conversation

JamesSullivan
Copy link

You definitely want to look this over as I really do not know what I am doing with type parametric polymorphism in Scala. However, I absolutely could not get the WithProvider example to compile without those changes.

You definitely want to look this over as I really do not know what I am doing with type parametric polymorphism in Scala. However, I absolutely could not get the WithProvider example to compile without those changes.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.32% when pulling 7633125 on JamesSullivan:patch-1 into 54f8711 on mohiva:master.

@akkie
Copy link
Contributor

akkie commented Jan 22, 2015

This compiles fine to me:

import com.mohiva.play.silhouette.api.{Authorization, LoginInfo, Identity}
import play.api.i18n.Lang
import play.api.mvc.RequestHeader

case class User(loginInfo: LoginInfo) extends Identity

case class WithProvider(provider: String) extends Authorization[User] {
  def isAuthorized(user: User)(implicit request: RequestHeader, lang: Lang) = {
    user.loginInfo.providerID == provider
  }
}

This is also tested with Scala 2.10.4 and Scala 2.11.4:

https://github.com/mohiva/play-silhouette/blob/master/silhouette/test/com/mohiva/play/silhouette/api/SilhouetteSpec.scala#L1045
https://github.com/mohiva/play-silhouette/blob/master/silhouette/test/com/mohiva/play/silhouette/api/SilhouetteSpec.scala#L138
https://github.com/mohiva/play-silhouette/blob/master/silhouette/test/com/mohiva/play/silhouette/api/SilhouetteSpec.scala#L157

I've no idea what's going on in your code. Could you share a code snippet?

@JamesSullivan
Copy link
Author

Thanks for the quick reply Christian.

Looked into this a bit more and now understand that I need to import the
correct User.

import com.mohiva.play.silhouette.api.Authorization
import com.mohiva.play.silhouette.api.Identity
import play.api.i18n.Lang
import play.api.mvc.RequestHeader
// import com.mohiva.play.silhouette.impl.User -- using this import causes
need to add type info
import models.User // this works without adding type info

case class WithProvider(provider: String) extends Authorization[User] {
def isAuthorized(user: User)(implicit request: RequestHeader, lang: Lang)
= {
// changed line below from example to work with version 2.0-SNAPSHOT
// user.identityId.providerId == provider
user.loginInfo.providerID == provider
}
}

On Thu, Jan 22, 2015 at 9:23 PM, Christian Kaps notifications@github.com
wrote:

This compiles fine to me:

import com.mohiva.play.silhouette.api.{Authorization, LoginInfo, Identity}import play.api.i18n.Langimport play.api.mvc.RequestHeader
case class User(loginInfo: LoginInfo) extends Identity
case class WithProvider(provider: String) extends Authorization[User] {
def isAuthorized(user: User)(implicit request: RequestHeader, lang: Lang) = {
user.loginInfo.providerID == provider
}
}

This is also tested with Scala 2.10.4 and Scala 2.11.4:

https://github.com/mohiva/play-silhouette/blob/master/silhouette/test/com/mohiva/play/silhouette/api/SilhouetteSpec.scala#L1045

https://github.com/mohiva/play-silhouette/blob/master/silhouette/test/com/mohiva/play/silhouette/api/SilhouetteSpec.scala#L138

https://github.com/mohiva/play-silhouette/blob/master/silhouette/test/com/mohiva/play/silhouette/api/SilhouetteSpec.scala#L157

I've no idea what's going on in your code. Could you share a code snippet?


Reply to this email directly or view it on GitHub
#263 (comment)
.

@akkie
Copy link
Contributor

akkie commented Jan 23, 2015

Nice, that it works. Let me know if you have further questions.

@akkie akkie closed this Jan 23, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants