-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from kitoranaoki/rename-trait
rename trait. Permission -> Role
- Loading branch information
Showing
12 changed files
with
44 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,11 +91,11 @@ For example: `Build.scala` | |
* 認可(権限チェック)を行う際に、アクション毎に設定するオブジェクトの型です。 | ||
* このサンプルでは例として以下のような trait を使用しています。 | ||
* | ||
* sealed trait Permission | ||
* case object Administrator extends Permission | ||
* case object NormalUser extends Permission | ||
* sealed trait Role | ||
* case object Administrator extends Role | ||
* case object NormalUser extends Role | ||
*/ | ||
type Authority = Permission | ||
type Authority = Role | ||
|
||
/** | ||
* CacheからユーザIDを取り出すための ClassTag です。 | ||
|
@@ -143,7 +143,7 @@ For example: `Build.scala` | |
* 任意の処理を記述してください。 | ||
*/ | ||
def authorize(user: User, authority: Authority)(implicit ctx: ExecutionContext): Future[Boolean] = Future.successful { | ||
(user.permission, authority) match { | ||
(user.role, authority) match { | ||
case (Administrator, _) => true | ||
case (NormalUser, NormalUser) => true | ||
case _ => false | ||
|
@@ -733,7 +733,7 @@ Play2 の現在の仕組みではできません。 | |
|
||
アカウントは以下の3アカウントが登録されています。 | ||
|
||
Email | Password | Permission | ||
Email | Password | Role | ||
[email protected] | secret | Administrator | ||
[email protected] | secret | NormalUser | ||
[email protected] | secret | NormalUser | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,11 +98,11 @@ Usage | |
* A type that is defined by every action for authorization. | ||
* This sample uses the following trait: | ||
* | ||
* sealed trait Permission | ||
* case object Administrator extends Permission | ||
* case object NormalUser extends Permission | ||
* sealed trait Role | ||
* case object Administrator extends Role | ||
* case object NormalUser extends Role | ||
*/ | ||
type Authority = Permission | ||
type Authority = Role | ||
|
||
/** | ||
* A `ClassTag` is used to retrieve an id from the Cache API. | ||
|
@@ -150,7 +150,7 @@ Usage | |
* You should alter this procedure to suit your application. | ||
*/ | ||
def authorize(user: User, authority: Authority)(implicit ctx: ExecutionContext): Future[Boolean] = Future.successful { | ||
(user.permission, authority) match { | ||
(user.role, authority) match { | ||
case (Administrator, _) => true | ||
case (NormalUser, NormalUser) => true | ||
case _ => false | ||
|
@@ -532,7 +532,7 @@ Running The Sample Application | |
|
||
defined accounts | ||
|
||
Email | Password | Permission | ||
Email | Password | Role | ||
[email protected] | secret | Administrator | ||
[email protected] | secret | NormalUser | ||
[email protected] | secret | NormalUser | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package jp.t2v.lab.play2.auth.sample | ||
|
||
sealed trait Role | ||
|
||
object Role { | ||
|
||
case object Administrator extends Role | ||
case object NormalUser extends Role | ||
|
||
def valueOf(value: String): Role = value match { | ||
case "Administrator" => Administrator | ||
case "NormalUser" => NormalUser | ||
case _ => throw new IllegalArgumentException() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters