-
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 f19d707
Showing
14 changed files
with
124 additions
and
251 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
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
34 changes: 34 additions & 0 deletions
34
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,34 @@ | ||
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} | ||
import spray.json.DefaultJsonProtocol._ | ||
import spray.json.RootJsonFormat | ||
|
||
object AdminUpdateUserRequest { | ||
implicit val UserUpdateRequestFormat: RootJsonFormat[AdminUpdateUserRequest] = | ||
jsonFormat(AdminUpdateUserRequest.apply, "azureB2CId", "googleSubjectId") | ||
|
||
def apply( | ||
azureB2CId: Option[AzureB2CId], | ||
googleSubjectId: Option[GoogleSubjectId] | ||
): AdminUpdateUserRequest = | ||
AdminUpdateUserRequest(azureB2CId, googleSubjectId) | ||
} | ||
@Lenses final case class AdminUpdateUserRequest( | ||
azureB2CId: Option[AzureB2CId], | ||
googleSubjectId: Option[GoogleSubjectId] | ||
) { | ||
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
Oops, something went wrong.