🐛 Fix new own share not being accessible
This commit is contained in:
parent
eced1e67f8
commit
e5a996452d
|
@ -62,6 +62,6 @@
|
|||
<a href="share-add-user?share={{ $share.UUID }}" class="share-add-user">Add User</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
<a href="create-share" class="create-share">Create Share</a>
|
||||
<a href="create-share?owned=true" class="create-share">Create Share</a>
|
||||
</div>
|
||||
{{ end }}
|
23
webadmin.go
23
webadmin.go
|
@ -477,11 +477,24 @@ Are you sure you want to continue?`, loginName)
|
|||
ar.Route("/create-share", func(r chi.Router) {
|
||||
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
sessionContext := h.buildSessionContext(w, r)
|
||||
|
||||
owned := r.FormValue("owned") == "true"
|
||||
if !owned && sessionContext.user.Role != GlobalRoleAdmin {
|
||||
sessionContext.Unauthorized()
|
||||
return
|
||||
}
|
||||
|
||||
sessionContext.RenderPage(h.tplCreateShare, nil)
|
||||
})
|
||||
r.Post("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
sessionContext := h.buildSessionContext(w, r)
|
||||
|
||||
owned := r.FormValue("owned") == "true"
|
||||
if !owned && sessionContext.user.Role != GlobalRoleAdmin {
|
||||
sessionContext.Unauthorized()
|
||||
return
|
||||
}
|
||||
|
||||
share, err := app.shareStore.CreateShare()
|
||||
if err != nil {
|
||||
sessionContext.RenderError(template.HTML("Cannot create share: "+err.Error()), "")
|
||||
|
@ -496,7 +509,15 @@ Are you sure you want to continue?`, loginName)
|
|||
return
|
||||
}
|
||||
|
||||
sessionContext.Redirect("shares#share-" + share.UUID.String())
|
||||
if owned {
|
||||
if err := app.shareStore.AddUserToShare(share, sessionContext.user.Username, ShareRoleAdmin); err != nil {
|
||||
sessionContext.RenderError(template.HTML("Cannot add self to share: "+err.Error()), "")
|
||||
return
|
||||
}
|
||||
sessionContext.Redirect("my-shares#share-" + share.UUID.String())
|
||||
} else {
|
||||
sessionContext.Redirect("shares#share-" + share.UUID.String())
|
||||
}
|
||||
})
|
||||
})
|
||||
ar.Post("/delete-share", func(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
Loading…
Reference in New Issue