Add current group user endpoint to allow to frontend to acknowledge the default user.
This commit is contained in:
parent
d0d35fa832
commit
8e50d520bf
|
@ -37,8 +37,8 @@ dependencies {
|
||||||
implementation("io.jsonwebtoken:jjwt-jackson:0.11.2")
|
implementation("io.jsonwebtoken:jjwt-jackson:0.11.2")
|
||||||
implementation("org.apache.poi:poi-ooxml:4.1.0")
|
implementation("org.apache.poi:poi-ooxml:4.1.0")
|
||||||
implementation("org.apache.pdfbox:pdfbox:2.0.4")
|
implementation("org.apache.pdfbox:pdfbox:2.0.4")
|
||||||
implementation("org.apache.logging.log4j:log4j-api:2.15.0")
|
implementation("org.apache.logging.log4j:log4j-api:2.16.0")
|
||||||
implementation("org.apache.logging.log4j:log4j-to-slf4j:2.15.0")
|
implementation("org.apache.logging.log4j:log4j-to-slf4j:2.16.0")
|
||||||
implementation("dev.fyloz.colorrecipesexplorer:database-manager:5.2.1")
|
implementation("dev.fyloz.colorrecipesexplorer:database-manager:5.2.1")
|
||||||
|
|
||||||
implementation("org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}")
|
implementation("org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}")
|
||||||
|
|
|
@ -9,7 +9,6 @@ import org.springframework.context.annotation.Profile
|
||||||
import org.springframework.http.MediaType
|
import org.springframework.http.MediaType
|
||||||
import org.springframework.security.access.prepost.PreAuthorize
|
import org.springframework.security.access.prepost.PreAuthorize
|
||||||
import org.springframework.web.bind.annotation.*
|
import org.springframework.web.bind.annotation.*
|
||||||
import java.security.Principal
|
|
||||||
import javax.servlet.http.HttpServletRequest
|
import javax.servlet.http.HttpServletRequest
|
||||||
import javax.servlet.http.HttpServletResponse
|
import javax.servlet.http.HttpServletResponse
|
||||||
import javax.validation.Valid
|
import javax.validation.Valid
|
||||||
|
@ -31,22 +30,6 @@ class UserController(private val userService: UserService) {
|
||||||
fun getById(@PathVariable id: Long) =
|
fun getById(@PathVariable id: Long) =
|
||||||
ok(userService.getByIdForOutput(id))
|
ok(userService.getByIdForOutput(id))
|
||||||
|
|
||||||
@GetMapping("current")
|
|
||||||
@PreAuthorize("isFullyAuthenticated()")
|
|
||||||
fun getCurrent(loggedInUser: Principal?) =
|
|
||||||
if (loggedInUser != null)
|
|
||||||
ok(
|
|
||||||
with(userService) {
|
|
||||||
getById(
|
|
||||||
loggedInUser.name.toLong(),
|
|
||||||
ignoreDefaultGroupUsers = false,
|
|
||||||
ignoreSystemUsers = false
|
|
||||||
).toOutput()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
else
|
|
||||||
forbidden()
|
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@PreAuthorizeEditUsers
|
@PreAuthorizeEditUsers
|
||||||
fun save(@Valid @RequestBody user: UserSaveDto) =
|
fun save(@Valid @RequestBody user: UserSaveDto) =
|
||||||
|
@ -133,6 +116,12 @@ class GroupsController(
|
||||||
getRequestDefaultGroup(request).toOutput()
|
getRequestDefaultGroup(request).toOutput()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@GetMapping("currentuser")
|
||||||
|
fun getCurrentGroupUser(request: HttpServletRequest) =
|
||||||
|
ok(with(groupService.getRequestDefaultGroup(request)) {
|
||||||
|
userService.getDefaultGroupUser(this).toOutputDto()
|
||||||
|
})
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@PreAuthorizeEditUsers
|
@PreAuthorizeEditUsers
|
||||||
fun save(@Valid @RequestBody group: GroupSaveDto) =
|
fun save(@Valid @RequestBody group: GroupSaveDto) =
|
||||||
|
|
Loading…
Reference in New Issue