com.mohiva.play.silhouette.api.Identity Scala Examples
The following examples show how to use com.mohiva.play.silhouette.api.Identity.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: User.scala From crm-seed with Apache License 2.0 | 5 votes |
package com.dataengi.crm.identities.models import com.dataengi.crm.identities.models.UserStates.UserState import com.mohiva.play.silhouette.api.{Identity, LoginInfo} import monocle.macros.GenLens import monocle.{Lens, PLens} case class User(loginInfo: LoginInfo, company: Company, role: Role, state: UserState = UserStates.Activated, id: Option[Long] = None) extends Identity object UserStates extends Enumeration { type UserState = Value val Activated = Value(0) val Deactivated = Value(1) } object Users { val role: Lens[User, Role] = GenLens[User](_.role) val roleName: Lens[Role, String] = GenLens[Role](_.name) val rolePermissions: Lens[Role, Seq[Permission]] = GenLens[Role](_.permissions) val userRoleName: PLens[User, User, String, String] = role composeLens roleName val userPermissions: PLens[User, User, Seq[Permission], Seq[Permission]] = role composeLens rolePermissions }
Example 2
Source File: User.scala From play-silhouette-reactivemongo-seed with Apache License 2.0 | 5 votes |
package models import java.util.UUID import play.api.libs.json._ import com.mohiva.play.silhouette.api.{ Identity, LoginInfo } 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 } } } object User { implicit val jsonFormat = Json.format[User] }
Example 3
Source File: HatUser.scala From HAT2.0 with GNU Affero General Public License v3.0 | 5 votes |
package org.hatdex.hat.authentication.models import java.util.UUID import com.mohiva.play.silhouette.api.{ Identity, LoginInfo } import org.hatdex.hat.api.models._ import org.hatdex.hat.resourceManagement.HatServer case class HatUser(userId: UUID, email: String, pass: Option[String], name: String, roles: Seq[UserRole], enabled: Boolean) extends Identity { def loginInfo(implicit hatServer: HatServer) = LoginInfo(hatServer.domain, email) def withRoles(roles: UserRole*): HatUser = { this.copy(roles = (this.roles.toSet ++ roles.toSet).toSeq) } def withoutRoles(roles: UserRole*): HatUser = { this.copy(roles = (this.roles.toSet -- roles.toSet).toSeq) } lazy val primaryRole: UserRole = { if (roles.contains(Owner())) { Owner() } else if (roles.contains(Platform())) { Platform() } else if (roles.contains(DataCredit(""))) { DataCredit("") } else if (roles.contains(DataDebitOwner(""))) { DataDebitOwner("") } else { Validate() } } }
Example 4
Source File: User.scala From play-silhouette-postgres-async-seed with Apache License 2.0 | 5 votes |
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) }