Authenticators are renamed.

This commit is contained in:
takezoe
2013-07-04 03:37:49 +09:00
parent a28bb7fd73
commit 9688afac02
6 changed files with 16 additions and 19 deletions

View File

@@ -1,7 +1,7 @@
package app package app
import util.Directory._ import util.Directory._
import util.UsersOnlyAuthenticator import util.UsersAuthenticator
import service._ import service._
import java.io.File import java.io.File
import org.eclipse.jgit.api.Git import org.eclipse.jgit.api.Git
@@ -10,13 +10,13 @@ import org.apache.commons.io._
import jp.sf.amateras.scalatra.forms._ import jp.sf.amateras.scalatra.forms._
class CreateRepositoryController extends CreateRepositoryControllerBase class CreateRepositoryController extends CreateRepositoryControllerBase
with RepositoryService with AccountService with WikiService with LabelsService with UsersOnlyAuthenticator with RepositoryService with AccountService with WikiService with LabelsService with UsersAuthenticator
/** /**
* Creates new repository. * Creates new repository.
*/ */
trait CreateRepositoryControllerBase extends ControllerBase { trait CreateRepositoryControllerBase extends ControllerBase {
self: RepositoryService with WikiService with LabelsService with UsersOnlyAuthenticator => self: RepositoryService with WikiService with LabelsService with UsersAuthenticator =>
case class RepositoryCreationForm(name: String, description: Option[String]) case class RepositoryCreationForm(name: String, description: Option[String])

View File

@@ -3,7 +3,7 @@ package app
import jp.sf.amateras.scalatra.forms._ import jp.sf.amateras.scalatra.forms._
import service._ import service._
import util.{CollaboratorsAuthenticator, ReferrerAuthenticator, UsersOnlyAuthenticator} import util.{CollaboratorsAuthenticator, ReferrerAuthenticator, UsersAuthenticator}
class MilestonesController extends MilestonesControllerBase class MilestonesController extends MilestonesControllerBase
with MilestonesService with RepositoryService with AccountService with MilestonesService with RepositoryService with AccountService

View File

@@ -2,15 +2,15 @@ package app
import service._ import service._
import util.Directory._ import util.Directory._
import util.{UsersOnlyAuthenticator, OwnerOnlyAuthenticator} import util.{UsersAuthenticator, OwnerAuthenticator}
import jp.sf.amateras.scalatra.forms._ import jp.sf.amateras.scalatra.forms._
import org.apache.commons.io.FileUtils import org.apache.commons.io.FileUtils
class SettingsController extends SettingsControllerBase class SettingsController extends SettingsControllerBase
with RepositoryService with AccountService with OwnerOnlyAuthenticator with UsersOnlyAuthenticator with RepositoryService with AccountService with OwnerAuthenticator with UsersAuthenticator
trait SettingsControllerBase extends ControllerBase { trait SettingsControllerBase extends ControllerBase {
self: RepositoryService with AccountService with OwnerOnlyAuthenticator with UsersOnlyAuthenticator => self: RepositoryService with AccountService with OwnerAuthenticator with UsersAuthenticator =>
case class OptionsForm(description: Option[String], defaultBranch: String, isPrivate: Boolean) case class OptionsForm(description: Option[String], defaultBranch: String, isPrivate: Boolean)

View File

@@ -2,14 +2,14 @@ package app
import service.{AccountService, SystemSettingsService} import service.{AccountService, SystemSettingsService}
import SystemSettingsService._ import SystemSettingsService._
import util.AdminOnlyAuthenticator import util.AdminAuthenticator
import jp.sf.amateras.scalatra.forms._ import jp.sf.amateras.scalatra.forms._
class SystemSettingsController extends SystemSettingsControllerBase class SystemSettingsController extends SystemSettingsControllerBase
with SystemSettingsService with AccountService with AdminOnlyAuthenticator with SystemSettingsService with AccountService with AdminAuthenticator
trait SystemSettingsControllerBase extends ControllerBase { trait SystemSettingsControllerBase extends ControllerBase {
self: SystemSettingsService with AccountService with AdminOnlyAuthenticator => self: SystemSettingsService with AccountService with AdminAuthenticator =>
private case class SystemSettingsForm(allowAccountRegistration: Boolean) private case class SystemSettingsForm(allowAccountRegistration: Boolean)

View File

@@ -1,13 +1,13 @@
package app package app
import service._ import service._
import util.AdminOnlyAuthenticator import util.AdminAuthenticator
import util.StringUtil._ import util.StringUtil._
import jp.sf.amateras.scalatra.forms._ import jp.sf.amateras.scalatra.forms._
class UserManagementController extends UserManagementControllerBase with AccountService with AdminOnlyAuthenticator class UserManagementController extends UserManagementControllerBase with AccountService with AdminAuthenticator
trait UserManagementControllerBase extends ControllerBase { self: AccountService with AdminOnlyAuthenticator => trait UserManagementControllerBase extends ControllerBase { self: AccountService with AdminAuthenticator =>
case class UserNewForm(userName: String, password: String, mailAddress: String, isAdmin: Boolean, url: Option[String]) case class UserNewForm(userName: String, password: String, mailAddress: String, isAdmin: Boolean, url: Option[String])
case class UserEditForm(userName: String, password: Option[String], mailAddress: String, isAdmin: Boolean, url: Option[String]) case class UserEditForm(userName: String, password: Option[String], mailAddress: String, isAdmin: Boolean, url: Option[String])

View File

@@ -26,8 +26,7 @@ trait OneselfAuthenticator { self: ControllerBase =>
/** /**
* Allows only the repository owner and administrators. * Allows only the repository owner and administrators.
*/ */
// TODO rename to OwnerAuthenticator trait OwnerAuthenticator { self: ControllerBase with RepositoryService =>
trait OwnerOnlyAuthenticator { self: ControllerBase with RepositoryService =>
protected def ownerOnly(action: (RepositoryInfo) => Any) = { authenticate(action) } protected def ownerOnly(action: (RepositoryInfo) => Any) = { authenticate(action) }
protected def ownerOnly[T](action: (T, RepositoryInfo) => Any) = (form: T) => { authenticate(action(form, _)) } protected def ownerOnly[T](action: (T, RepositoryInfo) => Any) = (form: T) => { authenticate(action(form, _)) }
@@ -48,8 +47,7 @@ trait OwnerOnlyAuthenticator { self: ControllerBase with RepositoryService =>
/** /**
* Allows only signed in users. * Allows only signed in users.
*/ */
// TODO rename to UsersAuthenticator trait UsersAuthenticator { self: ControllerBase =>
trait UsersOnlyAuthenticator { self: ControllerBase =>
protected def usersOnly(action: => Any) = { authenticate(action) } protected def usersOnly(action: => Any) = { authenticate(action) }
protected def usersOnly[T](action: T => Any) = (form: T) => { authenticate(action(form)) } protected def usersOnly[T](action: T => Any) = (form: T) => { authenticate(action(form)) }
@@ -66,8 +64,7 @@ trait UsersOnlyAuthenticator { self: ControllerBase =>
/** /**
* Allows only administrators. * Allows only administrators.
*/ */
// TODO rename to AdminAuthenticator trait AdminAuthenticator { self: ControllerBase =>
trait AdminOnlyAuthenticator { self: ControllerBase =>
protected def adminOnly(action: => Any) = { authenticate(action) } protected def adminOnly(action: => Any) = { authenticate(action) }
protected def adminOnly[T](action: T => Any) = (form: T) => { authenticate(action(form)) } protected def adminOnly[T](action: T => Any) = (form: T) => { authenticate(action(form)) }