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

Scala SocialProviderRegistry类代码示例

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

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



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

示例1: Application

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

import javax.inject.Inject

import scala.concurrent.Future
import com.mohiva.play.silhouette.api.Silhouette
import com.mohiva.play.silhouette.impl.providers.SocialProviderRegistry
import play.api.mvc._
import play.api.i18n.{I18nSupport, MessagesApi}
import utils.auth.CookieEnv

class Application @Inject() (
                              val messagesApi: MessagesApi,
                              silhouette: Silhouette[CookieEnv],
                              socialProviderRegistry: SocialProviderRegistry,
                              implicit val webJarAssets: WebJarAssets) extends Controller with I18nSupport {

  import silhouette._

  def index = UserAwareAction.async { implicit request =>
    Future.successful(Ok(views.html.index(request.identity, request.authenticator.map(_.loginInfo))))
  }

  def profile = SecuredAction { implicit request =>
    Ok(views.html.profile(request.identity, request.authenticator.loginInfo, socialProviderRegistry))
  }
} 
开发者ID:tm-sukehiro,项目名称:play-hands-on,代码行数:28,代码来源:Application.scala


示例2: messagesApi

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

import com.mohiva.play.silhouette.api.actions._
import com.mohiva.play.silhouette.api.repositories.AuthInfoRepository
import com.mohiva.play.silhouette.api.services.AvatarService
import com.mohiva.play.silhouette.api.util.{ Clock, PasswordHasher }
import com.mohiva.play.silhouette.impl.providers.{ CredentialsProvider, SocialProviderRegistry }
import com.softwaremill.macwire._
import models.daos.AuthTokenDAOImpl
import models.services.{ AuthTokenServiceImpl, UserService }
import play.api.Configuration
import play.api.i18n.MessagesApi
import utils.auth.{ CustomSecuredErrorHandler, CustomUnsecuredErrorHandler }

trait ControllerModule {
  lazy val authToken = new AuthTokenDAOImpl
  lazy val authTokenService = new AuthTokenServiceImpl(authToken, clock)
  lazy val securedErrorHandler: SecuredErrorHandler = wire[CustomSecuredErrorHandler]
  lazy val unSecuredErrorHandler: UnsecuredErrorHandler = wire[CustomUnsecuredErrorHandler]
  lazy val userAwareAction = new DefaultUserAwareAction(new DefaultUserAwareRequestHandler)
  lazy val securedAction: SecuredAction = new DefaultSecuredAction(new DefaultSecuredRequestHandler(securedErrorHandler))
  lazy val unsecuredAction: UnsecuredAction = new DefaultUnsecuredAction(new DefaultUnsecuredRequestHandler(unSecuredErrorHandler))

  def messagesApi: MessagesApi

  def socialProviderRegistry: SocialProviderRegistry

  def userService: UserService

  def authInfoRepository: AuthInfoRepository

  def credentialsProvider: CredentialsProvider

  def configuration: Configuration

  def clock: Clock

  def avatarService: AvatarService

  def passwordHasher: PasswordHasher

} 
开发者ID:Vinay-bhagwat,项目名称:Silhouette-4.0.0-MacWire,代码行数:43,代码来源:ControllerModule.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: ProductController

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

import scala.concurrent.Future
import javax.inject._

import com.mohiva.play.silhouette.api.Silhouette
import com.mohiva.play.silhouette.api.repositories.AuthInfoRepository
import com.mohiva.play.silhouette.api.util.Clock
import com.mohiva.play.silhouette.impl.providers.{CredentialsProvider, SocialProviderRegistry}
import forms.ProductForm
import models.Product
import models.daos.ProductDAO
import models.services.UserService
import play.api.Configuration
import play.api.i18n.I18nSupport
import play.api.i18n.MessagesApi
import play.api.libs.concurrent.Execution.Implicits._
import play.api.mvc.Controller
import utils.auth.DefaultEnv

@Singleton
class ProductController @Inject()(val messagesApi: MessagesApi,
                                  silhouette: Silhouette[DefaultEnv],
                                  userService: UserService,
                                  authInfoRepository: AuthInfoRepository,
                                  credentialsProvider: CredentialsProvider,
                                  socialProviderRegistry: SocialProviderRegistry,
                                  configuration: Configuration,
                                  clock: Clock,
                                  productDAO: ProductDAO,
                                  implicit val webJarAssets: WebJarAssets)
  extends Controller with I18nSupport {

  private val logger = org.slf4j.LoggerFactory.getLogger(this.getClass)


  def list = silhouette.SecuredAction.async { implicit request =>
    productDAO.all().map { products =>
      logger.info(s"Calling index: products = ${products}")
      Ok(views.html.products.list(request.identity, ProductForm.form, products))
    }
  }

  def add = silhouette.SecuredAction.async { implicit request =>
    ProductForm.form.bindFromRequest.fold(
      form => Future.successful(BadRequest(views.html.products.details(request.identity,ProductForm.form))),
      data => {
        val product = Product(
          ean = data.ean,
          name = data.name,
          description = data.description
        )
        productDAO.insert(product).map(_ => Redirect(routes.ProductController.list))
      }
    )
  }

} 
开发者ID:vahana-team,项目名称:play-slick-silhouette-postgres,代码行数:59,代码来源:ProductController.scala


示例5: InvitationController

//设置package包名称以及导入依赖的类
package com.clemble.loveit.user.controller

import javax.inject.{Inject, Singleton}

import com.clemble.loveit.common.util.AuthEnv
import com.clemble.loveit.user.model.Invitation
import com.clemble.loveit.user.service.InvitationService
import com.mohiva.play.silhouette.api.repositories.AuthInfoRepository
import com.mohiva.play.silhouette.api.{Logger, Silhouette}
import com.mohiva.play.silhouette.impl.providers.SocialProviderRegistry
import play.api.libs.json._
import play.api.mvc.Controller

import scala.concurrent.{ExecutionContext, Future}

@Singleton
case class InvitationController @Inject()(
                                           invitationService: InvitationService,
                                           silhouette: Silhouette[AuthEnv],
                                           authInfoRepository: AuthInfoRepository,
                                           socialProviderRegistry: SocialProviderRegistry,
                                           implicit val ec: ExecutionContext
                                         ) extends Controller with Logger {

  def invite() = silhouette.SecuredAction.async(parse.json[JsObject].map(_ \ "linkOrEmail"))(implicit req => {
    req.body match {
      case JsDefined(JsString(linkOrEmail)) =>
        val inv = Invitation(linkOrEmail, req.identity.id)
        invitationService.
          save(inv).
          map(res => Ok(Json.toJson(res)))
      case _ =>
        Future.successful(BadRequest("linkOrEmail field is missing"))
    }
  })

} 
开发者ID:thankyo,项目名称:thank,代码行数:38,代码来源:InvitationController.scala


示例6: SignInView

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

import com.mohiva.play.silhouette.impl.providers.SocialProviderRegistry
import controllers.routes
import play.api.i18n.{Lang, Messages}
import play.api.mvc.RequestHeader
import play.twirl.api.Html
import views.styles.SignInStyleSheet

import scala.concurrent.{ExecutionContext, Future}
import scalacss.DevDefaults._
import scalacss.ScalatagsCss._
import scalatags.Text
import scalatags.Text.all._

object SignInView {

  def apply(socialProviderRegistry: SocialProviderRegistry)
           (implicit request: RequestHeader, messages: Messages, lang: Lang): Html = {

    val headers = Seq(
      SignInStyleSheet.render[scalatags.Text.TypedTag[String]]
    )

    val errorSpot: Frag = request.flash.get("error") match {
      case Some(errorMessage) => div(`class` := "alert alert-danger center-block", maxWidth := 480)(
        errorMessage
      )
      case None => UnitFrag(Unit)
    }

    val body: Frag = div(`class` := "container", paddingTop := 100)(
      div(`class` := "panel panel-default center-block", maxWidth := 480)(
        div(`class` := "panel-heading")(messages("sign-in")),
        div(`class` := "panel-body")(
          a(href := routes.AuthController.authenticate("google").url)(
            img(src := "/assets/images/google_sign_in.png", `class` := "img-responsive center-block")
          ),
          div(`class` := "text-center")(messages("or")),
          a(href := routes.AuthController.authenticate("facebook").url)(
            img(src := "/assets/images/facebook_sign_in.png", `class` := "img-responsive center-block")
          )
        )
      ),
      errorSpot
    )

    MainTemplate(messages("sign-in"), "sign-in", headers, body, None)
  }
} 
开发者ID:rusins,项目名称:pusdieno,代码行数:51,代码来源:SignInView.scala


示例7: CookieCredentialsTestController

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

import javax.inject.Inject

import com.mohiva.play.silhouette.api.{ Environment, LogoutEvent, Silhouette }
import com.mohiva.play.silhouette.impl.authenticators.{JWTAuthenticator, CookieAuthenticator}
import com.mohiva.play.silhouette.impl.providers.SocialProviderRegistry
import models.tenant.AuthCrewUser
import play.api.i18n.{Messages, MessagesApi}
import play.api.libs.json.Json
import play.api.mvc.{Action, AnyContent}

import scala.concurrent.Future

class CookieCredentialsTestController @Inject()(
                                                 val messagesApi: MessagesApi,
                                                 val env: Environment[AuthCrewUser, CookieAuthenticator],
                                                 socialProviderRegistry: SocialProviderRegistry
                                         )
  extends Silhouette[AuthCrewUser, CookieAuthenticator]
{
  def index: Action[AnyContent] = SecuredAction.async { implicit request =>
    Future.successful(Ok(Json.obj("message" -> Messages("authentication.successful"))))
  }
} 
开发者ID:ShaneRich5,项目名称:hello-jenkins,代码行数:26,代码来源:CookieCredentialsTestController.scala


示例8: JWTCredentialsTestController

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

import javax.inject.Inject

import com.mohiva.play.silhouette.api.{ Environment, LogoutEvent, Silhouette }
import com.mohiva.play.silhouette.impl.authenticators.JWTAuthenticator
import com.mohiva.play.silhouette.impl.providers.SocialProviderRegistry
import models.tenant.AuthCrewUser
import play.api.i18n.{Messages, MessagesApi}
import play.api.libs.json.Json
import play.api.mvc.{Action, AnyContent}

import scala.concurrent.Future

class JWTCredentialsTestController @Inject()(
                                              val messagesApi: MessagesApi,
                                              val env: Environment[AuthCrewUser, JWTAuthenticator],
                                              socialProviderRegistry: SocialProviderRegistry
                                               )
  extends Silhouette[AuthCrewUser, JWTAuthenticator]
{
  def index: Action[AnyContent] = SecuredAction.async { implicit request =>
    Future.successful(Ok(Json.obj("message" -> Messages("authentication.successful"))))
  }
} 
开发者ID:ShaneRich5,项目名称:hello-jenkins,代码行数:26,代码来源:JWTCredentialsTestController.scala


示例9: ChildController

//设置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, CookieAuthenticator}
import com.mohiva.play.silhouette.impl.providers.SocialProviderRegistry
import dao.RepoFor
import models.tenant.{AuthCrewUser, Child}
import models.tenant.persistable.PersistableChild
import play.api._
import play.api.db.slick.DatabaseConfigProvider
import play.api.i18n.MessagesApi
import play.api.libs.json._

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

  override val repo: RepoFor[PersistableChild, Id] = dao.tenant.ChildRepo

  override def convertToDisplayable: PersistableChild => Child = _.convert
  override def convertToPersistable: Child => PersistableChild = PersistableChild.build

  override implicit val reads: Reads[Model] = models.tenant.json.ChildJson.childReads
  override implicit val writes: Writes[Model] = models.tenant.json.ChildJson.childWrites

} 
开发者ID:ShaneRich5,项目名称:hello-jenkins,代码行数:36,代码来源:ChildController.scala


示例10: GenericSecureApiController

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

import com.mohiva.play.silhouette.api.{Silhouette, Environment}
import com.mohiva.play.silhouette.impl.authenticators.JWTAuthenticator
import com.mohiva.play.silhouette.impl.providers.SocialProviderRegistry
import models.tenant.AuthCrewUser
import org.postgresql.util.PSQLException
import play.api.db.slick.DatabaseConfigProvider
import play.api.i18n.MessagesApi
import play.api.libs.json.Json
import play.api.mvc.{AnyContent, Action}

import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.{Failure, Success}

abstract class GenericSecureApiController(dbConfigProvider: DatabaseConfigProvider,
                                          messagesApi: MessagesApi,
                                          env: Environment[AuthCrewUser, JWTAuthenticator],
                                          socialProviderRegistry: SocialProviderRegistry)
  extends GenericApiController(dbConfigProvider, messagesApi, env, socialProviderRegistry)
  with Silhouette[AuthCrewUser, JWTAuthenticator]
{
  import dbConfig.driver.api._

  override def update: Action[Model] = SecuredAction.async(parse.json(reads)) {
    entity =>
      db.run(convertToPersistable(entity.body).update).map(updated => Ok(Json.toJson(convertToDisplayable(updated))))
  }

  override def delete(id: Id): Action[AnyContent] = SecuredAction.async {
    db.run(repo.filterById(id).delete).map {
      i =>
        if (i == 0) NotFound else Ok
    }
  }

  override def getById(id: Id): Action[AnyContent] = SecuredAction.async {
    db.run(repo.findById(id)).map(entity => Ok(Json.toJson(convertToDisplayable(entity))))
  }

  override def getAll: Action[AnyContent] = SecuredAction.async {
    val all = db.run(repo.tableQuery.result)

    all.map(all => Ok(Json.toJson(all.map(convertToDisplayable))))
  }

  override def create: Action[Model] = SecuredAction.async(parse.json(reads)) {
    parsed =>
      db.run(convertToPersistable(parsed.body).save.asTry).map {
        case Success(created) => Ok(Json.toJson(convertToDisplayable(created)))
        case Failure(e: PSQLException) if e.getSQLState == "23505" => InternalServerError("Unique key violation: unique key already exists in the database.")
        case Failure(t: PSQLException) => InternalServerError("PSQL error.")
      }

  }
} 
开发者ID:ShaneRich5,项目名称:hello-jenkins,代码行数:57,代码来源:GenericSecureApiController.scala


示例11: 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


示例12: TenantController

//设置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, CookieAuthenticator}
import com.mohiva.play.silhouette.impl.providers.SocialProviderRegistry
import dao.RepoFor
import models.admin.Tenant
import models.tenant.AuthCrewUser
import play.api.db.slick.DatabaseConfigProvider
import play.api.i18n.MessagesApi
import play.api.libs.json._

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

  override def convertToPersistable = identity

  override def convertToDisplayable = identity

  override val repo: RepoFor[Tenant, Id] = dao.admin.TenantRepo

  override implicit val reads: Reads[Model] = models.admin.json.TenantJson.tenantReads
  override implicit val writes: Writes[Model] = models.admin.json.TenantJson.tenantWrites
} 
开发者ID:ShaneRich5,项目名称:hello-jenkins,代码行数:35,代码来源:TenantController.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Scala ScalaJSPlugin类代码示例发布时间:2022-05-23
下一篇:
Scala Ints类代码示例发布时间: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