mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-19 17:23:33 +03:00
fix: caching for own profile picture
This commit is contained in:
@@ -38,7 +38,7 @@ func NewUserController(group *gin.RouterGroup, authMiddleware *middleware.AuthMi
|
|||||||
group.PUT("/users/:id/user-groups", authMiddleware.Add(), uc.updateUserGroups)
|
group.PUT("/users/:id/user-groups", authMiddleware.Add(), uc.updateUserGroups)
|
||||||
|
|
||||||
group.GET("/users/:id/profile-picture.png", uc.getUserProfilePictureHandler)
|
group.GET("/users/:id/profile-picture.png", uc.getUserProfilePictureHandler)
|
||||||
group.GET("/users/me/profile-picture.png", authMiddleware.WithAdminNotRequired().Add(), uc.getCurrentUserProfilePictureHandler)
|
|
||||||
group.PUT("/users/:id/profile-picture", authMiddleware.Add(), uc.updateUserProfilePictureHandler)
|
group.PUT("/users/:id/profile-picture", authMiddleware.Add(), uc.updateUserProfilePictureHandler)
|
||||||
group.PUT("/users/me/profile-picture", authMiddleware.WithAdminNotRequired().Add(), uc.updateCurrentUserProfilePictureHandler)
|
group.PUT("/users/me/profile-picture", authMiddleware.WithAdminNotRequired().Add(), uc.updateCurrentUserProfilePictureHandler)
|
||||||
|
|
||||||
@@ -249,24 +249,7 @@ func (uc *UserController) getUserProfilePictureHandler(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.DataFromReader(http.StatusOK, size, "image/png", picture, nil)
|
c.Header("Cache-Control", "public, max-age=300")
|
||||||
}
|
|
||||||
|
|
||||||
// getCurrentUserProfilePictureHandler godoc
|
|
||||||
// @Summary Get current user's profile picture
|
|
||||||
// @Description Retrieve the currently authenticated user's profile picture
|
|
||||||
// @Tags Users
|
|
||||||
// @Produce image/png
|
|
||||||
// @Success 200 {file} binary "PNG image"
|
|
||||||
// @Router /users/me/profile-picture.png [get]
|
|
||||||
func (uc *UserController) getCurrentUserProfilePictureHandler(c *gin.Context) {
|
|
||||||
userID := c.GetString("userID")
|
|
||||||
|
|
||||||
picture, size, err := uc.userService.GetProfilePicture(userID)
|
|
||||||
if err != nil {
|
|
||||||
c.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
c.DataFromReader(http.StatusOK, size, "image/png", picture, nil)
|
c.DataFromReader(http.StatusOK, size, "image/png", picture, nil)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@
|
|||||||
<Card.Root>
|
<Card.Root>
|
||||||
<Card.Content class="pt-6">
|
<Card.Content class="pt-6">
|
||||||
<ProfilePictureSettings
|
<ProfilePictureSettings
|
||||||
userId="me"
|
userId={account.id}
|
||||||
isLdapUser={!!account.ldapId}
|
isLdapUser={!!account.ldapId}
|
||||||
callback={updateProfilePicture}
|
callback={updateProfilePicture}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user