🐛 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>
|
<a href="share-add-user?share={{ $share.UUID }}" class="share-add-user">Add User</a>
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<a href="create-share" class="create-share">Create Share</a>
|
<a href="create-share?owned=true" class="create-share">Create Share</a>
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ 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) {
|
ar.Route("/create-share", func(r chi.Router) {
|
||||||
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
|
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
sessionContext := h.buildSessionContext(w, r)
|
sessionContext := h.buildSessionContext(w, r)
|
||||||
|
|
||||||
|
owned := r.FormValue("owned") == "true"
|
||||||
|
if !owned && sessionContext.user.Role != GlobalRoleAdmin {
|
||||||
|
sessionContext.Unauthorized()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
sessionContext.RenderPage(h.tplCreateShare, nil)
|
sessionContext.RenderPage(h.tplCreateShare, nil)
|
||||||
})
|
})
|
||||||
r.Post("/", func(w http.ResponseWriter, r *http.Request) {
|
r.Post("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
sessionContext := h.buildSessionContext(w, r)
|
sessionContext := h.buildSessionContext(w, r)
|
||||||
|
|
||||||
|
owned := r.FormValue("owned") == "true"
|
||||||
|
if !owned && sessionContext.user.Role != GlobalRoleAdmin {
|
||||||
|
sessionContext.Unauthorized()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
share, err := app.shareStore.CreateShare()
|
share, err := app.shareStore.CreateShare()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sessionContext.RenderError(template.HTML("Cannot create share: "+err.Error()), "")
|
sessionContext.RenderError(template.HTML("Cannot create share: "+err.Error()), "")
|
||||||
|
@ -496,7 +509,15 @@ Are you sure you want to continue?`, loginName)
|
||||||
return
|
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) {
|
ar.Post("/delete-share", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
Loading…
Reference in New Issue