mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-06 14:20:55 +03:00
WebClient: refactor preserving share password
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -89,6 +89,11 @@ func (s *Share) GetAllowedFromAsString() string {
|
|||||||
return strings.Join(s.AllowFrom, ",")
|
return strings.Join(s.AllowFrom, ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsPasswordHashed returns true if the password is hashed
|
||||||
|
func (s *Share) IsPasswordHashed() bool {
|
||||||
|
return util.IsStringPrefixInSlice(s.Password, hashPwdPrefixes)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Share) getACopy() Share {
|
func (s *Share) getACopy() Share {
|
||||||
allowFrom := make([]string, len(s.AllowFrom))
|
allowFrom := make([]string, len(s.AllowFrom))
|
||||||
copy(allowFrom, s.AllowFrom)
|
copy(allowFrom, s.AllowFrom)
|
||||||
|
|||||||
@@ -706,6 +706,9 @@ func (s *httpdServer) renderAddUpdateSharePage(w http.ResponseWriter, r *http.Re
|
|||||||
currentURL = fmt.Sprintf("%v/%v", webClientSharePath, url.PathEscape(share.ShareID))
|
currentURL = fmt.Sprintf("%v/%v", webClientSharePath, url.PathEscape(share.ShareID))
|
||||||
title = util.I18nShareUpdateTitle
|
title = util.I18nShareUpdateTitle
|
||||||
}
|
}
|
||||||
|
if share.IsPasswordHashed() {
|
||||||
|
share.Password = redactedSecret
|
||||||
|
}
|
||||||
data := clientSharePage{
|
data := clientSharePage{
|
||||||
baseClientPage: s.getBaseClientPageData(title, currentURL, w, r),
|
baseClientPage: s.getBaseClientPageData(title, currentURL, w, r),
|
||||||
Share: share,
|
Share: share,
|
||||||
@@ -1437,7 +1440,6 @@ func (s *httpdServer) handleClientUpdateShareGet(w http.ResponseWriter, r *http.
|
|||||||
shareID := getURLParam(r, "id")
|
shareID := getURLParam(r, "id")
|
||||||
share, err := dataprovider.ShareExists(shareID, claims.Username)
|
share, err := dataprovider.ShareExists(shareID, claims.Username)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
share.HideConfidentialData()
|
|
||||||
s.renderAddUpdateSharePage(w, r, &share, nil, false)
|
s.renderAddUpdateSharePage(w, r, &share, nil, false)
|
||||||
} else if errors.Is(err, util.ErrNotFound) {
|
} else if errors.Is(err, util.ErrNotFound) {
|
||||||
s.renderClientNotFoundPage(w, r, err)
|
s.renderClientNotFoundPage(w, r, err)
|
||||||
|
|||||||
Reference in New Issue
Block a user