Skip to content

Commit

Permalink
fix: unable to modify team's avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
ElaBosak233 committed Jun 2, 2024
1 parent 9b44b2b commit 81a0be2
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions internal/controller/team.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ func (c *TeamController) Leave(ctx *gin.Context) {
func (c *TeamController) SaveAvatar(ctx *gin.Context) {
id := convertor.ToUintD(ctx.Param("id"), 0)
fileHeader, err := ctx.FormFile("file")
fmt.Println("coming!!!!!!!!!!!!!!!!!!!!!")
if err != nil {
ctx.JSON(http.StatusBadRequest, gin.H{
"code": http.StatusBadRequest,
Expand Down
2 changes: 2 additions & 0 deletions internal/extension/casbin/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ func initDefaultPolicy() {
{"user", "/api/teams/{id}", "PUT"},
{"user", "/api/teams/{id}", "GET"},
{"user", "/api/teams/{id}", "DELETE"},
{"user", "/api/teams/{id}/avatar", "POST"},
{"user", "/api/teams/{id}/avatar", "DELETE"},
{"user", "/api/teams/{id}/invite", "PUT"},
{"user", "/api/teams/{id}/invite", "GET"},
{"user", "/api/teams/{id}/users/{user_id}", "DELETE"},
Expand Down
5 changes: 0 additions & 5 deletions internal/model/team.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ type Team struct {
Users []*User `gorm:"many2many:user_teams;" json:"users,omitempty"` // The team's users.
}

func (t *Team) Simplify() {
t.InviteToken = ""
t.Description = ""
}

func (t *Team) AfterFind(db *gorm.DB) (err error) {
p := path.Join(utils.MediaPath, "teams", fmt.Sprintf("%d", t.ID))
var name string
Expand Down
2 changes: 1 addition & 1 deletion internal/service/team.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (t *TeamService) Delete(id uint) error {
func (t *TeamService) Find(req request.TeamFindRequest) (teams []model.Team, total int64, err error) {
teams, total, err = t.teamRepository.Find(req)
for index, team := range teams {
team.Simplify()
team.InviteToken = ""
teams[index] = team
}
return teams, total, err
Expand Down
4 changes: 3 additions & 1 deletion web/src/components/modals/TeamEditModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,9 @@ export default function TeamEditModal(props: TeamEditModalProps) {
<Flex mt={20} justify={"end"} gap={10}>
<Button
leftSection={
<MDIcon>swap_horiz</MDIcon>
<MDIcon color="red">
swap_horiz
</MDIcon>
}
onClick={openDeleteTeamModal}
color="red"
Expand Down
5 changes: 4 additions & 1 deletion web/src/pages/register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ export default function Page() {
});

function register() {
if (configStore?.captchaCfg?.enabled && !form.getValues().token) {
if (
configStore?.pltCfg?.user?.register?.captcha?.enabled &&
!form.getValues().token
) {
showErrNotification({
title: "注册失败",
message: "请完成验证码验证",
Expand Down

0 comments on commit 81a0be2

Please sign in to comment.