当前位置: 首页>>代码示例>>Scala>>正文


Scala OAuth1Info类代码示例

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


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

示例1: OAuth1InfoQueries

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

import com.mohiva.play.silhouette.api.LoginInfo
import com.mohiva.play.silhouette.impl.providers.OAuth1Info
import jdub.async.{ Row, Statement }
import jdub.async.queries.BaseQueries
import org.joda.time.LocalDateTime

object OAuth1InfoQueries extends BaseQueries[OAuth1Info] {
  override protected val tableName = "oauth1_info"
  override protected val columns = Seq("provider", "key", "token", "secret", "created")
  override protected val idColumns = Seq("provider", "key")
  override protected val searchColumns = Seq("key", "token")

  val getById = GetById
  val removeById = RemoveById

  case class CreateOAuth1Info(l: LoginInfo, o: OAuth1Info) extends Statement {
    override val sql = insertSql
    override val values = Seq(l.providerID, l.providerKey) ++ toDataSeq(o)
  }

  case class UpdateOAuth1Info(l: LoginInfo, o: OAuth1Info) extends Statement {
    override val sql = s"update $tableName set token = ?, secret = ?, created = ? where provider = ? and key = ?"
    override val values = toDataSeq(o) ++ Seq(l.providerID, l.providerKey)
  }

  override protected def fromRow(row: Row) = {
    val token = row.as[String]("token")
    val secret = row.as[String]("secret")
    OAuth1Info(token, secret)
  }

  override protected def toDataSeq(o: OAuth1Info) = Seq(o.token, o.secret, new LocalDateTime())
} 
开发者ID:laurinka,项目名称:golfmit,代码行数:36,代码来源:OAuth1InfoQueries.scala

示例2: OAuth1InfoService

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

import com.mohiva.play.silhouette.api.LoginInfo
import com.mohiva.play.silhouette.impl.daos.DelegableAuthInfoDAO
import com.mohiva.play.silhouette.impl.providers.OAuth1Info
import jdub.async.Database
import models.queries.OAuth1InfoQueries
import play.api.libs.concurrent.Execution.Implicits.defaultContext

import scala.concurrent.Future

object OAuth1InfoService extends DelegableAuthInfoDAO[OAuth1Info] {
  override def find(loginInfo: LoginInfo) = Database.query(OAuth1InfoQueries.getById(Seq(loginInfo.providerID, loginInfo.providerKey)))

  override def save(loginInfo: LoginInfo, authInfo: OAuth1Info) = {
    Database.transaction { conn =>
      Database.execute(OAuth1InfoQueries.UpdateOAuth1Info(loginInfo, authInfo), Some(conn)).flatMap { rowsAffected =>
        if (rowsAffected == 0) {
          Database.execute(OAuth1InfoQueries.CreateOAuth1Info(loginInfo, authInfo), Some(conn)).map(x => authInfo)
        } else {
          Future.successful(authInfo)
        }
      }
    }
  }

  override def add(loginInfo: LoginInfo, authInfo: OAuth1Info) = {
    Database.execute(OAuth1InfoQueries.CreateOAuth1Info(loginInfo, authInfo)).map(x => authInfo)
  }

  override def update(loginInfo: LoginInfo, authInfo: OAuth1Info) = {
    Database.execute(OAuth1InfoQueries.UpdateOAuth1Info(loginInfo, authInfo)).map(x => authInfo)
  }

  override def remove(loginInfo: LoginInfo) = {
    Database.execute(OAuth1InfoQueries.removeById(Seq(loginInfo.providerID, loginInfo.providerKey))).map(x => Unit)
  }
} 
开发者ID:laurinka,项目名称:golfmit,代码行数:39,代码来源:OAuth1InfoService.scala

示例3: OAuth1InfoDao

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

import javax.inject.Inject

import scala.concurrent.{Await, Future}
import com.mohiva.play.silhouette.api.LoginInfo
import com.mohiva.play.silhouette.impl.providers.OAuth1Info
import com.mohiva.play.silhouette.persistence.daos.DelegableAuthInfoDAO
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import play.api.libs.json._
import play.modules.reactivemongo.ReactiveMongoApi
import play.modules.reactivemongo.json._
import reactivemongo.play.json.collection.JSONCollection
import models.User
import User._

import scala.concurrent.duration.Duration

class OAuth1InfoDao @Inject() (
                                val reactiveMongoApi: ReactiveMongoApi
                              ) extends DelegableAuthInfoDAO[OAuth1Info] {
  val users = Await.result(reactiveMongoApi.database.map(_.collection[JSONCollection]("users")), Duration.Inf)

  def find(loginInfo:LoginInfo):Future[Option[OAuth1Info]] = for {
    user <- users.find(Json.obj(
      "profiles.loginInfo" -> loginInfo
    )).one[User]
  } yield user.flatMap(_.profiles.find(_.loginInfo == loginInfo)).flatMap(_.oauth1Info)

  def add(loginInfo:LoginInfo, authInfo:OAuth1Info):Future[OAuth1Info] =
    users.update(Json.obj(
      "profiles.loginInfo" -> loginInfo
    ), Json.obj(
      "$set" -> Json.obj("profiles.$.oauth1Info" -> authInfo)
    )).map(_ => authInfo)

  def update(loginInfo:LoginInfo, authInfo:OAuth1Info):Future[OAuth1Info] =
    add(loginInfo, authInfo)

  def save(loginInfo:LoginInfo, authInfo:OAuth1Info):Future[OAuth1Info] =
    add(loginInfo, authInfo)

  def remove(loginInfo:LoginInfo):Future[Unit] =
    users.update(Json.obj(
      "profiles.loginInfo" -> loginInfo
    ), Json.obj(
      "$pull" -> Json.obj(
        "profiles" -> Json.obj("loginInfo" -> loginInfo)
      )
    )).map(_ => ())
} 
开发者ID:tm-sukehiro,项目名称:play-hands-on,代码行数:52,代码来源:OAuth1InfoDao.scala

示例4: Profile

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

import java.util.UUID

import play.api.libs.json.Json
import com.mohiva.play.silhouette.api.{Identity, LoginInfo}
import com.mohiva.play.silhouette.api.util.PasswordInfo
import com.mohiva.play.silhouette.impl.providers.OAuth1Info

case class Profile(
                    loginInfo:LoginInfo,
                    confirmed: Boolean,
                    email:Option[String],
                    firstName: Option[String],
                    lastName: Option[String],
                    fullName: Option[String],
                    passwordInfo:Option[PasswordInfo],
                    oauth1Info: Option[OAuth1Info],
                    avatarUrl: Option[String]) {
}

case class User(id: UUID, profiles: List[Profile]) extends Identity {
  def profileFor(loginInfo:LoginInfo) = profiles.find(_.loginInfo == loginInfo)
  def fullName(loginInfo:LoginInfo) = profileFor(loginInfo).flatMap(_.fullName)
}

object User {
  implicit val passwordInfoJsonFormat = Json.format[PasswordInfo]
  implicit val oauth1InfoJsonFormat = Json.format[OAuth1Info]
  implicit val profileJsonFormat = Json.format[Profile]
  implicit val userJsonFormat = Json.format[User]
} 
开发者ID:tm-sukehiro,项目名称:play-hands-on,代码行数:33,代码来源:User.scala

示例5: OAuth1InfoDAO

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

import com.mohiva.play.silhouette.api.LoginInfo
import com.mohiva.play.silhouette.impl.daos.DelegableAuthInfoDAO
import com.mohiva.play.silhouette.impl.providers.OAuth1Info
import com.mongodb.casbah.Imports
import com.mongodb.casbah.Imports._
import models.Database


class OAuth1InfoDAO extends DelegableAuthInfoDAO[OAuth1Info] with AuthInfoDAO[OAuth1Info] {

  override def data: Imports.MongoCollection = Database.db("oAuth1Info")

  override def convertToDB(loginInfo: LoginInfo, authInfo: OAuth1Info) : DBObject = {
    MongoDBObject(
      "providerID" -> loginInfo.providerID,
      "providerKey" -> loginInfo.providerKey,
      "token" -> authInfo.token,
      "secret" -> authInfo.secret
    )
  }

  override def loadFromDB(dbAuthInfo : DBObject) : OAuth1Info = {
    OAuth1Info(
      Database.loadString(dbAuthInfo, "token"),
      Database.loadString(dbAuthInfo, "secret")
    )
  }
} 
开发者ID:Bastcloa,项目名称:testJenkins,代码行数:31,代码来源:OAuth1InfoDAO.scala

示例6: OAuth1InfoDao

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

import scala.concurrent.Future
import com.mohiva.play.silhouette.api.LoginInfo
import com.mohiva.play.silhouette.impl.providers.OAuth1Info
import com.mohiva.play.silhouette.impl.daos.DelegableAuthInfoDAO
import play.api.Play.current
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import play.api.libs.json._
import play.modules.reactivemongo.ReactiveMongoApi
import play.modules.reactivemongo.json._
import play.modules.reactivemongo.json.collection.JSONCollection
import models.User
import User._

class OAuth1InfoDao extends DelegableAuthInfoDAO[OAuth1Info] {
  lazy val reactiveMongoApi = current.injector.instanceOf[ReactiveMongoApi]
  val users = reactiveMongoApi.db.collection[JSONCollection]("users")

  def find(loginInfo:LoginInfo):Future[Option[OAuth1Info]] = for {
    user <- users.find(Json.obj(
      "profiles.loginInfo" -> loginInfo
    )).one[User]
  } yield user.flatMap(_.profiles.find(_.loginInfo == loginInfo)).flatMap(_.oauth1Info)

  def add(loginInfo:LoginInfo, authInfo:OAuth1Info):Future[OAuth1Info] = {
    implicit val OAuth1InfoFormat = Json.format[OAuth1Info]
    users.update(Json.obj(
      "profiles.loginInfo" -> loginInfo
    ), Json.obj(
      "$set" -> Json.obj("profiles.$.oauth1Info" -> authInfo)
    )).map(_ => authInfo)
  }

  def update(loginInfo:LoginInfo, authInfo:OAuth1Info):Future[OAuth1Info] = 
    add(loginInfo, authInfo)

  def save(loginInfo:LoginInfo, authInfo:OAuth1Info):Future[OAuth1Info] = 
    add(loginInfo, authInfo)

  def remove(loginInfo:LoginInfo):Future[Unit] = 
    users.update(Json.obj(
      "profiles.loginInfo" -> loginInfo
    ), Json.obj(
      "$pull" -> Json.obj(
        "profiles" -> Json.obj("loginInfo" -> loginInfo)
      )
    )).map(_ => ())
} 
开发者ID:k19862217,项目名称:book-shoes-api,代码行数:50,代码来源:OAuth1InfoDao.scala

示例7: Profile

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

import java.util.UUID

import com.mohiva.play.silhouette.api.{Identity, LoginInfo}
import com.mohiva.play.silhouette.api.util.PasswordInfo
import com.mohiva.play.silhouette.impl.providers.OAuth1Info
import play.api.libs.json.Json



case class Profile(
                    loginInfo:LoginInfo,
                    confirmed: Boolean,
                    email:Option[String],
                    firstName: Option[String],
                    lastName: Option[String],
                    fullName: Option[String],
                    passwordInfo:Option[PasswordInfo],
                    oauth1Info: Option[OAuth1Info],
                    avatarUrl: Option[String])

object Profile {
  implicit val passwordInfoJsonFormat = Json.format[PasswordInfo]
  implicit val oauth1InfoJsonFormat = Json.format[OAuth1Info]
  implicit val profileJsonFormat = Json.format[Profile]
}

case class User(id: UUID, profiles: List[Profile]) extends Identity {
  def profileFor(loginInfo:LoginInfo) = profiles.find(_.loginInfo == loginInfo)
  def fullName(loginInfo:LoginInfo) = profileFor(loginInfo).flatMap(_.fullName)
}

object User {
  implicit val userJsonFormat = Json.format[User]
} 
开发者ID:k19862217,项目名称:book-shoes-api,代码行数:37,代码来源:User.scala

示例8: OAuth1InfoDao

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

import scala.concurrent.Future

import com.mohiva.play.silhouette.api.LoginInfo
import com.mohiva.play.silhouette.impl.providers.OAuth1Info
import com.mohiva.play.silhouette.impl.daos.DelegableAuthInfoDAO

import play.api.Play.current
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import play.api.libs.json._

import play.modules.reactivemongo.ReactiveMongoApi
import play.modules.reactivemongo.json._
import play.modules.reactivemongo.json.collection.JSONCollection

import models.User, User._

class OAuth1InfoDao extends DelegableAuthInfoDAO[OAuth1Info] {
  lazy val reactiveMongoApi = current.injector.instanceOf[ReactiveMongoApi]
  val users = reactiveMongoApi.db.collection[JSONCollection]("users")

  def find(loginInfo:LoginInfo):Future[Option[OAuth1Info]] = for {
    user <- users.find(Json.obj(
      "profiles.loginInfo" -> loginInfo
    )).one[User]
  } yield user.flatMap(_.profiles.find(_.loginInfo == loginInfo)).flatMap(_.oauth1Info)

  def add(loginInfo:LoginInfo, authInfo:OAuth1Info):Future[OAuth1Info] = 
    users.update(Json.obj(
      "profiles.loginInfo" -> loginInfo
    ), Json.obj(
      "$set" -> Json.obj("profiles.$.oauth1Info" -> authInfo)
    )).map(_ => authInfo)

  def update(loginInfo:LoginInfo, authInfo:OAuth1Info):Future[OAuth1Info] = 
    add(loginInfo, authInfo)

  def save(loginInfo:LoginInfo, authInfo:OAuth1Info):Future[OAuth1Info] = 
    add(loginInfo, authInfo)

  def remove(loginInfo:LoginInfo):Future[Unit] = 
    users.update(Json.obj(
      "profiles.loginInfo" -> loginInfo
    ), Json.obj(
      "$pull" -> Json.obj(
        "profiles" -> Json.obj("loginInfo" -> loginInfo)
      )
    )).map(_ => ())
} 
开发者ID:Viva-con-Agua,项目名称:drops,代码行数:51,代码来源:OAuth1InfoDao.scala

示例9: User

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

import java.util.{Date, UUID}

import com.mohiva.play.silhouette.api.util.PasswordInfo
import com.mohiva.play.silhouette.api.{Identity, LoginInfo}
import com.mohiva.play.silhouette.impl.providers.OAuth1Info
import org.joda.time.DateTime
import play.api.libs.json.Json


case class User(
                id: UUID = UUID.randomUUID(),
                loginInfo: LoginInfo,
                confirmed: Boolean,
                email: Option[String],
                phone: Option[String],
                firstName: Option[String] = None,
                lastName: Option[String] = None,
                passwordInfo: Option[PasswordInfo],
                oauth1Info: Option[OAuth1Info],
                created: Date = new Date()) extends Identity {

  def fullName(loginInfo: LoginInfo): Option[String] = for {
    f <- firstName
    l <- lastName
  } yield f + " " + l

  def uuidStr: String = id.toString
}

object User {
  implicit val passwordInfoJsonFormat = Json.format[PasswordInfo]
  implicit val oauth1InfoJsonFormat = Json.format[OAuth1Info]
  implicit val userJsonFormat = Json.format[User]

  val COLLECTION_NAME = "users"
}

case class UserToken(id: UUID, userId: UUID, email: String, expirationTime: DateTime, isSignUp: Boolean) {
  def isExpired: Boolean = expirationTime.isBeforeNow
}

object UserToken {
  implicit val toJson = Json.format[UserToken]

  val COLLECTION_NAME = "tokens"

  def create(userId: UUID, email: String, isSignUp: Boolean) =
    UserToken(UUID.randomUUID(), userId, email, new DateTime().plusHours(12), isSignUp)
} 
开发者ID:fsanaulla,项目名称:Silh,代码行数:52,代码来源:User.scala

示例10: find

//设置package包名称以及导入依赖的类
package models.daos.slick

import com.mohiva.play.silhouette.api.LoginInfo
import com.mohiva.play.silhouette.impl.daos.DelegableAuthInfoDAO
import com.mohiva.play.silhouette.impl.providers.OAuth1Info
import scala.concurrent.Future
import models.daos.slick.DBTableDefinitions._
import play.api.db.slick.Config.driver.simple._
import play.api.db.slick._


  def find(loginInfo: LoginInfo): Future[Option[OAuth1Info]] = {
    Future.successful(
      DB withSession { implicit session =>
        slickLoginInfos.filter(info => info.providerID === loginInfo.providerID && info.providerKey === loginInfo.providerKey).firstOption match {
          case Some(info) =>
            val oAuth1Info = slickOAuth1Infos.filter(_.loginInfoId === info.id).first
            Some(OAuth1Info(oAuth1Info.token, oAuth1Info.secret))
          case None => None
        }
      }
    )
  }
} 
开发者ID:mahmoudabbasi,项目名称:slickseedproject,代码行数:25,代码来源:OAuth1InfoDAOSlick.scala


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