• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala Environment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中com.mohiva.play.silhouette.api.Environment的典型用法代码示例。如果您正苦于以下问题:Scala Environment类的具体用法?Scala Environment怎么用?Scala Environment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Environment类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: CoinController

//设置package包名称以及导入依赖的类
package controllers

import javax.inject.Inject

import com.mohiva.play.silhouette.api.{Environment, Silhouette}
import com.mohiva.play.silhouette.impl.authenticators.CookieAuthenticator
import forms.CoinAddForm
import models.User
import models.coin.{Person, WorkEntry}
import models.common.Pagination
import play.api.i18n.MessagesApi
import play.api.mvc.{Action, AnyContent}

import scala.concurrent.Future


class CoinController @Inject()(
                                val messagesApi: MessagesApi,
                                val env: Environment[User, CookieAuthenticator]
                              ) extends Silhouette[User, CookieAuthenticator] {

  val itemsPerPage = 9

  
  def remove(id: Long): Action[AnyContent] = SecuredAction.async { implicit request =>
    WorkEntry.remove(id)
    Future.successful(Redirect(routes.CoinController.landing()))
  }
} 
开发者ID:wirvomgut,项目名称:curo,代码行数:30,代码来源:CoinController.scala


示例2: JSONCtrl

//设置package包名称以及导入依赖的类
package controllers.io

import javax.inject.Inject

import com.mohiva.play.silhouette.api.Environment
import com.mohiva.play.silhouette.impl.authenticators.CookieAuthenticator
import controllers.{ResultFormat, ViewContext}
import models.{PCMAPIUtils, User}
import org.opencompare.api.java.impl.io.KMFJSONExporter
import org.opencompare.formalizer.extractor.CellContentInterpreter
import play.api.data.Form
import play.api.data.Forms._
import play.api.i18n.MessagesApi
import play.api.libs.json.Json
import play.api.mvc.{AnyContent, Request, Result}



class JSONCtrl @Inject() (
                           val messagesApi: MessagesApi,
                           val env: Environment[User, CookieAuthenticator],
                           val pcmAPIUtils : PCMAPIUtils) extends IOCtrl("json") {

  val jsonExporter = new KMFJSONExporter()
  val formalizer = new CellContentInterpreter

  val outputParametersForm = Form(
    mapping(
      "file" -> text
    )(JSONExportParameters.apply)(JSONExportParameters.unapply)
  )

  override def importPCMs(format: ResultFormat)(implicit request: Request[AnyContent], viewContext: ViewContext): Result = {
    NotFound("JSON import is not implemented yet")
  }

  override def exportPCM(implicit request: Request[AnyContent]): Result = {
    val parameters = outputParametersForm.bindFromRequest.get
    val pcmJSON = Json.parse(parameters.pcm)

    val container = pcmAPIUtils.parsePCMContainers(pcmJSON).head
    formalizer.interpretCells(container.getPcm)
    val json = jsonExporter.export(container)

    Ok(json)
  }

  case class JSONExportParameters(pcm : String)
} 
开发者ID:Bastcloa,项目名称:testJenkins,代码行数:50,代码来源:JSONCtrl.scala


示例3: messagesApi

//设置package包名称以及导入依赖的类
package com.github.jacobono.modules

import com.mohiva.play.silhouette.api.Environment
import com.mohiva.play.silhouette.api.repositories.AuthInfoRepository
import com.mohiva.play.silhouette.api.services.AvatarService
import com.mohiva.play.silhouette.api.util.Clock
import com.mohiva.play.silhouette.api.util.PasswordHasher
import com.mohiva.play.silhouette.impl.authenticators.CookieAuthenticator
import com.mohiva.play.silhouette.impl.providers.{ CredentialsProvider, SocialProviderRegistry }

import com.softwaremill.macwire._

import play.api.Configuration
import play.api.i18n.MessagesApi

import com.github.jacobono.controllers._
import com.github.jacobono.models.User
import com.github.jacobono.models.services.UserService
import com.github.jacobono.utils.CSRFHelper

trait ControllerModule {
  def messagesApi: MessagesApi
  def silhouetteEnvironment: Environment[User, CookieAuthenticator]
  def socialProviderRegistry: SocialProviderRegistry
  def csrfHelper: CSRFHelper
  def userService: UserService
  def authInfoRepository: AuthInfoRepository
  def credentialsProvider: CredentialsProvider
  def configuration: Configuration
  def clock: Clock
  def avatarService: AvatarService
  def passwordHasher: PasswordHasher

  lazy val applicationController: Application = wire[Application]
  lazy val credentialsAuthController: CredentialsAuthController = wire[CredentialsAuthController]
  lazy val signUpController: SignUpController = wire[SignUpController]
  lazy val socialAuthController: SocialAuthController = wire[SocialAuthController]
} 
开发者ID:jacobono,项目名称:silhouette-macwire,代码行数:39,代码来源:ControllerModule.scala


示例4: SilhouetteModule

//设置package包名称以及导入依赖的类
package auth.http.module

import auth.core.DefaultEnv
import auth.core.module.SilhouetteContext
import auth.core.service.BasicUserService
import auth.core.service.authorization.PermissionsAuthorizer
import auth.http.service.impl.BasicUserServiceViaHttpImpl
import auth.http.service.impl.authorization.impl.PermissionsViaHttpAuthorizer
import com.google.inject.{AbstractModule, Provides}
import com.mohiva.play.silhouette.api.{Environment, EventBus}
import com.mohiva.play.silhouette.api.services.AuthenticatorService
import net.codingwell.scalaguice.ScalaModule
import play.api.Configuration
import play.api.libs.ws.WSClient

import scala.concurrent.ExecutionContext

sealed class SilhouetteModule extends AbstractModule with ScalaModule {
  override def configure(): Unit = {}

  @Provides
  def providePermissionsAuthorizer(configuration: Configuration, ws: WSClient)(
      implicit ec: ExecutionContext): PermissionsAuthorizer =
    new PermissionsViaHttpAuthorizer(configuration, ws)(ec)

  @Provides
  def provideUserService(configuration: Configuration,
                         wsClient: WSClient,
                         @SilhouetteContext ec: ExecutionContext): BasicUserService =
    new BasicUserServiceViaHttpImpl(configuration, wsClient)(ec)

  @Provides
  def provideEnvironment(userService: BasicUserService,
                         eventBus: EventBus,
                         authenticatorService: AuthenticatorService[DefaultEnv#A],
                         @SilhouetteContext ec: ExecutionContext): Environment[DefaultEnv] =
    Environment[DefaultEnv](userService, authenticatorService, Seq(), eventBus)(ec)
} 
开发者ID:KadekM,项目名称:play-slick-silhouette-auth-api,代码行数:39,代码来源:SilhouetteModule.scala


示例5: Statistics

//设置package包名称以及导入依赖的类
package controllers

import javax.inject.Inject

import com.mohiva.play.silhouette.api.{Environment, Silhouette}
import com.mohiva.play.silhouette.impl.authenticators.SessionAuthenticator
import models._
import models.daos._
import play.api.i18n.{Messages, MessagesApi}
import play.api.libs.json.Json
import play.api.mvc.{Action, AnyContent}

import scala.collection.immutable.ListMap
import scala.concurrent.ExecutionContext.Implicits._

class Statistics @Inject()(statisticsDAO: StatisticsDAO,
                           organisationDAO: OrganisationDAO,
                           val messagesApi: MessagesApi,
                           val env: Environment[User, SessionAuthenticator])
  extends Silhouette[User, SessionAuthenticator] {

  def statistics: Action[AnyContent] = SecuredAction.async { implicit request =>
    for {
      friday <- statisticsDAO.friday
      saturday <- statisticsDAO.saturday
      sorting <- statisticsDAO.sorting
      selling <- statisticsDAO.selling
      organisations <- organisationDAO.all
    } yield {
      val statistics = ListMap(
        Messages("friday") -> fill(organisations, friday),
        Messages("saturday") -> fill(organisations, saturday),
        Messages("sorting") -> fill(organisations, sorting),
        Messages("selling") -> fill(organisations, selling)
      )
      Ok(views.html.statistics(statistics, request.identity))
    }
  }

  private def fill(organisations: Seq[Organisation], statistic: Map[String, Int]): Map[String, Int] =
    organisations.map(organisation => (organisation.name, statistic.getOrElse(organisation.name, 0))).toMap

  def friday: Action[AnyContent] = SecuredAction.async { implicit request =>
    statisticsDAO.friday.map(statistics => Ok(Json.toJson(statistics)))
  }

  def saturday: Action[AnyContent] = SecuredAction.async { implicit request =>
    statisticsDAO.saturday.map(statistics => Ok(Json.toJson(statistics)))
  }

  def sorting: Action[AnyContent] = SecuredAction.async { implicit request =>
    statisticsDAO.sorting.map(statistics => Ok(Json.toJson(statistics)))
  }

  def selling: Action[AnyContent] = SecuredAction.async { implicit request =>
    statisticsDAO.selling.map(statistics => Ok(Json.toJson(statistics)))
  }
} 
开发者ID:wjglerum,项目名称:bamboesmanager,代码行数:59,代码来源:Statistics.scala


示例6: Application

//设置package包名称以及导入依赖的类
package controllers

import javax.inject.Inject

import com.mohiva.play.silhouette.api.{Environment, LogoutEvent, Silhouette}
import com.mohiva.play.silhouette.impl.authenticators.SessionAuthenticator
import forms._
import models.User
import play.api.i18n.MessagesApi

import scala.concurrent.Future

class Application @Inject()(val messagesApi: MessagesApi, val env: Environment[User, SessionAuthenticator])
  extends Silhouette[User, SessionAuthenticator] {

  def index = UserAwareAction { implicit request =>
    Ok(views.html.index(request.identity))
  }

  def dashboard = SecuredAction { implicit request =>
    Ok(views.html.dashboard(request.identity))
  }

  def signIn = UserAwareAction.async { implicit request =>
    request.identity match {
      case Some(_) => Future.successful(Redirect(routes.Application.index()))
      case None => Future.successful(Ok(views.html.signIn(SignInForm.form)))
    }
  }

  def signUp = SecuredAction { implicit request =>
    Ok(views.html.signUp(SignUpForm.form))
  }

  def signOut = SecuredAction.async { implicit request =>
    val result = Redirect(routes.Application.index())
    env.eventBus.publish(LogoutEvent(request.identity, request, request2Messages))
    env.authenticatorService.discard(request.authenticator, result)
  }
} 
开发者ID:wjglerum,项目名称:bamboesmanager,代码行数:41,代码来源:Application.scala


示例7: Persons

//设置package包名称以及导入依赖的类
package controllers

import java.util.UUID
import javax.inject.Inject

import com.mohiva.play.silhouette.api.{Environment, Silhouette}
import com.mohiva.play.silhouette.impl.authenticators.SessionAuthenticator
import models.User
import models.daos._
import play.api.i18n.{Messages, MessagesApi}
import play.api.libs.json._

import scala.concurrent.ExecutionContext.Implicits._
import scala.concurrent.Future

class Persons @Inject()(personDAO: PersonDAO,
                        val messagesApi: MessagesApi,
                        val env: Environment[User, SessionAuthenticator])
  extends Silhouette[User, SessionAuthenticator] {

  def all = SecuredAction.async {
    personDAO.all.map(persons => Ok(Json.toJson(persons)))
  }

  def get(id: String) = SecuredAction.async {
    try {
      personDAO.get(UUID.fromString(id)).map {
        case Some(person) => Ok(Json.toJson(person))
        case None => NotFound(Json.toJson(Messages("person.not_found")))
      }
    } catch {
      case _: IllegalArgumentException => Future.successful(BadRequest(Json.toJson(Messages("uuid.invalid"))))
    }
  }
} 
开发者ID:wjglerum,项目名称:bamboesmanager,代码行数:36,代码来源:Persons.scala


示例8: CrewController

//设置package包名称以及导入依赖的类
package controllers.api

import java.util.UUID

import com.google.inject.Inject
import com.mohiva.play.silhouette.api.Environment
import com.mohiva.play.silhouette.impl.authenticators.JWTAuthenticator
import com.mohiva.play.silhouette.impl.providers.SocialProviderRegistry
import dao.RepoFor
import models.tenant.persistable.PersistableCrew
import models.tenant.{Crew, AuthCrewUser}
import play.api._
import play.api.db.slick.DatabaseConfigProvider
import play.api.i18n.MessagesApi
import play.api.libs.json.{Writes, Reads}
import play.api.mvc._

class CrewController @Inject()(dbConfigProvider: DatabaseConfigProvider,
                               messagesApi: MessagesApi,
                               env: Environment[AuthCrewUser, JWTAuthenticator],
                               socialProviderRegistry: SocialProviderRegistry)
  extends GenericSecureApiController(dbConfigProvider, messagesApi, env, socialProviderRegistry)
{
  override type Id = UUID
  override type Model = Crew
  override type PersistedModel = PersistableCrew

  override def convertToPersistable = PersistableCrew.build
  override def convertToDisplayable = _.convert

  override val repo: RepoFor[PersistedModel, Id] = dao.tenant.CrewRepo

  override implicit val reads: Reads[Model] = models.tenant.json.CrewJson.crewReads
  override implicit val writes: Writes[Model] = models.tenant.json.CrewJson.crewWrites
} 
开发者ID:ShaneRich5,项目名称:hello-jenkins,代码行数:36,代码来源:CrewController.scala



注:本文中的com.mohiva.play.silhouette.api.Environment类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala ConcurrentHashMultiset类代码示例发布时间:2022-05-23
下一篇:
Scala ClassFinder类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap