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

Scala Identity类代码示例

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

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



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

示例1: User

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

import java.util.UUID

import com.mohiva.play.silhouette.api.{ Identity, LoginInfo }

import utils.misc.Glicko

case class User(
  userID: UUID,
  loginInfo: LoginInfo,
  handle: Option[String],
  regpass: Option[String],
  firstName: Option[String],
  lastName: Option[String],
  fullName: Option[String],
  email: Option[String],
  avatarURL: Option[String],
  activated: Boolean,
  admin: Boolean = false,
  rating: Double = Glicko.rating0,
  rd: Double = Glicko.rd0,
  lastrated: Double = 0.0
) extends Identity {

  def name = fullName.orElse {
    firstName -> lastName match {
      case (Some(f), Some(l)) => Some(f + " " + l)
      case (Some(f), None) => Some(f)
      case (None, Some(l)) => Some(l)
      case _ => None
    }
  }

  def setActivated(a: Boolean) = this.copy(activated = a)
} 
开发者ID:serversideapps,项目名称:silhmojs,代码行数:37,代码来源:User.scala


示例2: User

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

import java.util.UUID

import com.mohiva.play.silhouette.api.{ Identity, LoginInfo }
import org.joda.time.LocalDateTime

case class User(
    id: UUID,
    username: Option[String],
    profiles: Seq[LoginInfo],
    roles: Set[Role] = Set(Role.User),
    created: LocalDateTime
) extends Identity {
  def isGuest = profiles.isEmpty
  def isAdmin = roles.contains(models.user.Role.Admin)
} 
开发者ID:laurinka,项目名称:golfmit,代码行数:18,代码来源:User.scala


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


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


示例5: id

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

import com.mohiva.play.silhouette.api.Identity
import com.mohiva.play.silhouette.impl.providers.SocialProfile
import reactivemongo.bson.{ BSONDocument, BSONDocumentReader, BSONDocumentWriter, BSONNumberLike }


trait ServiceProfile extends Identity with SocialProfile {
  type Self <: ServiceProfile
  import models.ServiceProfile._
  def id: ServiceUserId
  def service: String
  def visible: Boolean
  def displayName: String
  def avatarUrl: String
  def profileState: ProfileState
  def isInGame: Boolean
  def currentlyPlaying: Game
  def isRegistered: Boolean
  def register: Self

  override def equals(obj: scala.Any): Boolean = obj match {
    case s: ServiceProfile => s.id == id && s.service == service
    case _ => false
  }
}

object ServiceProfile {
  implicit def ordering: Ordering[ServiceProfile] = Ordering.by { p: ServiceProfile => { (p.visible, p.currentlyPlaying, p.profileState, p.displayName) } }
  implicit def ordering2: Ordering[ProfileState] = Ordering.by(s => s.priority)
  type ServiceUserId = String
  sealed trait ProfileState {
    def priority: Int
  }
  case object Online extends ProfileState { override def priority = 4 }
  case object Offline extends ProfileState { override def priority = 20 }
  case object Busy extends ProfileState { override def priority = 8 }
  case object Away extends ProfileState { override def priority = 6 }
  case object Snooze extends ProfileState { override def priority = 10 }
  case object LookingToTrade extends ProfileState { override def priority = 2 }
  case object LookingToPlay extends ProfileState { override def priority = 0 }

  implicit object ProfileStateWriter extends BSONDocumentWriter[ProfileState] {
    def write(state: ProfileState): BSONDocument = BSONDocument("code" -> stateCode(state))
  }
  implicit object ProfileStateReader extends BSONDocumentReader[ProfileState] {
    override def read(bson: BSONDocument): ProfileState = profileStateFactory(bson.getAs[BSONNumberLike]("code").get.toInt)
  }
  def stateCode(state: ProfileState): Int = state match {
    case Offline => 0
    case Online => 1
    case Busy => 2
    case Away => 3
    case Snooze => 4
    case LookingToTrade => 5
    case LookingToPlay => 6
  }
} 
开发者ID:hnrklssn,项目名称:game-check-match,代码行数:59,代码来源:ServiceProfile.scala


示例6: UserIdentity

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

import com.clemble.loveit.common.model.UserID
import com.mohiva.play.silhouette.api.Identity
import org.joda.time.DateTime
import play.api.libs.json.Json

case class UserIdentity(
                         id: UserID,
                         firstName: Option[String],
                         lastName: Option[String],
                         thumbnail: Option[String],
                         dateOfBirth: Option[DateTime]
                       ) extends UserProfile with Identity

object UserIdentity {

  implicit val jsonFormat = Json.format[UserIdentity]

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


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


示例8: User

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

import java.util.UUID

import auth.core.model.core.User.State.Created
import auth.core.model.core.User.UserState
import com.mohiva.play.silhouette.api.Identity

final case class User(
    uuid: UUID,
    email: String,
    firstName: String,
    lastName: String,
    state: UserState
)
    extends Identity

object User {
  def empty: User = User(UUID.randomUUID, "", "", "", state = Created)

  sealed trait UserState
  object State {

    
    case object Deactivated extends UserState

    def fromString(x: String): Option[UserState] =
      Array[UserState](Created, Activated, Deactivated).find(_.toString == x)
  }
} 
开发者ID:KadekM,项目名称:play-slick-silhouette-auth-api,代码行数:31,代码来源:User.scala


示例9: User

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

import java.util.UUID

import com.mohiva.play.silhouette.api.Identity
import com.mohiva.play.silhouette.password.BCryptPasswordHasher
import play.api.libs.json.Json

case class User(
    id: Option[UUID],
    email: String,
    emailConfirmed: Boolean,
    password: String,
    nick: String,
    firstName: String,
    lastName: String,
    services: List[String]
) extends Identity {
  def key = email
  def fullName: String = firstName + " " + lastName
}

object User {
  val services = Seq("serviceA", "serviceB", "serviceC")
  implicit val jsonFormat = Json.format[User]
  val users = List(
    User(Some(UUID.fromString("3f145a02-7e5d-11e6-ae22-56b6b6499611")), "[email protected]", true, (new BCryptPasswordHasher()).hash("123123").password, "Eddy", "Eddard", "Stark", List("master")),
    User(Some(UUID.fromString("3f145c82-7e5d-11e6-ae22-56b6b6499611")), "[email protected]", true, (new BCryptPasswordHasher()).hash("123123").password, "Maggy", "Margaery", "Tyrell", List("serviceA")),
    User(Some(UUID.fromString("3f145d86-7e5d-11e6-ae22-56b6b6499611")), "[email protected]", true, (new BCryptPasswordHasher()).hash("123123").password, "Petyr", "Petyr", "Baelish", List("serviceB")),
    User(Some(UUID.fromString("3f145e62-7e5d-11e6-ae22-56b6b6499611")), "[email protected]", true, (new BCryptPasswordHasher()).hash("123123").password, "Tyry", "Tyrion", "Lannister", List("serviceA", "serviceB"))
  )
} 
开发者ID:ashutosh-shirole,项目名称:play-scalajs-mongo,代码行数:33,代码来源:User.scala


示例10: AuthCrewUser

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

import java.time.LocalDate
import java.util.UUID

import com.mohiva.play.silhouette.api.{Identity, LoginInfo}
import models.Role
import models.helpers.BelongsToTenant


case class AuthCrewUser(
                         userID: UUID,
                         loginInfo: LoginInfo,
                         firstName: Option[String],
                         lastName: Option[String],
                         fullName: Option[String],
                         email: Option[String],
                         avatarURL: Option[String],
                         roles: Set[Role]
                       )
  extends Identity


case class Crew(
                 id: Option[UUID],
                 loginInfo: LoginInfo,
                 firstName: Option[String],
                 lastName: Option[String],
                 fullName: Option[String],
                 email: Option[String],
                 avatarURL: Option[String],
                 birthDate: Option[LocalDate],
                 address: Option[Address],
                 tenantId: UUID
               )
  extends Identity with BelongsToTenant 
开发者ID:ShaneRich5,项目名称:hello-jenkins,代码行数:37,代码来源:AuthCrewUser.scala


示例11: User

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

import java.util.UUID

import com.mohiva.play.silhouette.api.{Identity, LoginInfo}
import play.api.libs.json.Json


case class User(uuid: UUID = UUID.randomUUID(),
                loginInfo: LoginInfo,
                firstName: Option[String],
                lastName: Option[String],
                fullName: Option[String],
                email: Option[String],
                avatarURL: Option[String],
                activated: Boolean) extends Identity

object User {
  val COLLECTION_NAME = "users"
  implicit val lgFmt = Json.format[LoginInfo]
  implicit val fmt = Json.format[User]
} 
开发者ID:fsanaulla,项目名称:SilhuetteSocialProvider,代码行数:23,代码来源:User.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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