-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7cbc359
commit dcecab1
Showing
10 changed files
with
81 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/scala/org/broadinstitute/dsde/workbench/sam/model/api/AdminUpdateUserRequest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.broadinstitute.dsde.workbench.sam.model.api | ||
|
||
import akka.http.scaladsl.model.StatusCodes | ||
import monocle.macros.Lenses | ||
import org.broadinstitute.dsde.workbench.model.WorkbenchIdentityJsonSupport._ | ||
import org.broadinstitute.dsde.workbench.model.{AzureB2CId, ErrorReport, GoogleSubjectId, WorkbenchEmail} | ||
import spray.json.DefaultJsonProtocol._ | ||
import spray.json.RootJsonFormat | ||
|
||
object AdminUpdateUserRequest { | ||
implicit val UserUpdateRequestFormat: RootJsonFormat[AdminUpdateUserRequest] = | ||
jsonFormat(AdminUpdateUserRequest.apply, "azureB2CId", "googleSubjectId", "email", "enabled") | ||
|
||
def apply( | ||
azureB2CId: Option[AzureB2CId], | ||
googleSubjectId: Option[GoogleSubjectId], | ||
email: Option[WorkbenchEmail], | ||
enabled: Option[Boolean] | ||
): AdminUpdateUserRequest = | ||
AdminUpdateUserRequest(azureB2CId, googleSubjectId, email, enabled) | ||
} | ||
@Lenses final case class AdminUpdateUserRequest( | ||
azureB2CId: Option[AzureB2CId], | ||
googleSubjectId: Option[GoogleSubjectId], | ||
email: Option[WorkbenchEmail], | ||
enabled: Option[Boolean] | ||
) { | ||
def isValid(user: SamUser): Seq[ErrorReport] = { | ||
import org.broadinstitute.dsde.workbench.google.errorReportSource | ||
|
||
var errorReports = Seq[ErrorReport]() | ||
if (azureB2CId.contains(AzureB2CId("null")) && user.googleSubjectId.isEmpty) | ||
errorReports = errorReports ++ Seq(ErrorReport(StatusCodes.BadRequest, "Unable to null azureB2CId when the user's googleSubjectId is already null")) | ||
else if (googleSubjectId.contains(GoogleSubjectId("null")) && user.azureB2CId.isEmpty) | ||
errorReports = errorReports ++ Seq(ErrorReport(StatusCodes.BadRequest, "Unable to null googleSubjectId when the user's azureB2CId is already null")) | ||
errorReports | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters