-
Notifications
You must be signed in to change notification settings - Fork 111
feat: add affiliation attribute to user #4113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jaeyun0503
wants to merge
20
commits into
apache:main
Choose a base branch
from
jaeyun0503:jaeyun-add-affiliation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
ee5a536
initial commit
jaeyun0503 c219f13
initial commit
jaeyun0503 babf196
Edited texera ddl file
jaeyun0503 04648cd
html change
jaeyun0503 01ad9d4
user.ts and backend changes
jaeyun0503 45229f9
changed 16.sql
jaeyun0503 a3186c9
Added UserResource.scala
jaeyun0503 b3d6897
Change jwtauth
jaeyun0503 ec69a6b
Changed related User related files
jaeyun0503 9eadcef
changed ts files
jaeyun0503 000d082
added cancel cases
jaeyun0503 59c6699
Changes to files
jaeyun0503 d3b118b
Changes to auth claims and sql files
jaeyun0503 408e5df
Merge branch 'main' into jaeyun-add-affiliation
jaeyun0503 9a2b162
Merge branch 'main' into jaeyun-add-affiliation
jaeyun0503 d372ef2
Changed 16.sql
jaeyun0503 d94163d
Changed texera_ddl.sql
jaeyun0503 ea581d5
Merge branch 'main' into jaeyun-add-affiliation
jaeyun0503 6cdf9f9
Lint fix
jaeyun0503 e34a8bb
Scala format check
jaeyun0503 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
74 changes: 74 additions & 0 deletions
74
amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/UserResource.scala
This file contains hidden or 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,74 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.texera.web.resource.dashboard.user | ||
|
|
||
| import org.apache.texera.dao.SqlServer | ||
| import org.apache.texera.dao.jooq.generated.tables.daos.UserDao | ||
| import org.apache.texera.dao.jooq.generated.tables.User.USER | ||
| import javax.ws.rs._ | ||
| import javax.ws.rs.core.{MediaType, Response} | ||
|
|
||
| case class AffiliationUpdateRequest(uid: Int, affiliation: String) | ||
|
|
||
| object UserResource { | ||
jaeyun0503 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private lazy val context = SqlServer.getInstance().createDSLContext() | ||
| private lazy val userDao = new UserDao(context.configuration) | ||
| } | ||
|
|
||
| @Path("/user") | ||
| class UserResource { | ||
|
|
||
| /** | ||
| * Update the affiliation of a user. | ||
| * Used by a first-time user to set their own affiliation. | ||
| */ | ||
| @PUT | ||
| @Path("/affiliation") | ||
| @Consumes(Array(MediaType.APPLICATION_JSON)) | ||
| def updateAffiliation(request: AffiliationUpdateRequest): Unit = { | ||
| val rowsUpdated = UserResource.context | ||
| .update(USER) | ||
| .set(USER.AFFILIATION, request.affiliation) | ||
| .where(USER.UID.eq(request.uid)) | ||
| .execute() | ||
|
|
||
| if (rowsUpdated == 0) { | ||
| throw new WebApplicationException("User not found", Response.Status.NOT_FOUND) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Gets affiliation with uid. Returns "", null or affiliation. | ||
| * "": Prompted and no response | ||
| * null: never prompted | ||
| * @param uid | ||
| * @return | ||
| */ | ||
| @GET | ||
| @Path("/affiliation") | ||
| @Produces(Array(MediaType.APPLICATION_JSON)) | ||
| def needsAffiliation(@QueryParam("uid") uid: Int): java.lang.Boolean = { | ||
| val user = UserResource.userDao.fetchOneByUid(uid) | ||
| if (user == null) { | ||
| throw new WebApplicationException("User not found", Response.Status.NOT_FOUND) | ||
| } | ||
| java.lang.Boolean.valueOf(user.getAffiliation == null) | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.