Skip to content

Commit

Permalink
Merge pull request #222 from writeas/fix-template-typo
Browse files Browse the repository at this point in the history
Fix password-protected page template
  • Loading branch information
thebaer committed Dec 18, 2019
2 parents 6a5d49e + 6afafa4 commit ed40e9d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
10 changes: 10 additions & 0 deletions collections.go
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,16 @@ func processCollectionPermissions(app *App, cr *collectionReq, u *User, w http.R
uname = u.Username
}

// TODO: move this to all permission checks?
suspended, err := app.db.IsUserSuspended(c.OwnerID)
if err != nil {
log.Error("process protected collection permissions: %v", err)
return nil, err
}
if suspended {
return nil, ErrCollectionNotFound
}

// See if we've authorized this collection
authd := isAuthorizedForCollection(app, c.Alias, r)

Expand Down
8 changes: 6 additions & 2 deletions posts.go
Original file line number Diff line number Diff line change
Expand Up @@ -1342,8 +1342,12 @@ func viewCollectionPost(app *App, w http.ResponseWriter, r *http.Request) error
if c.IsPrivate() && (u == nil || u.ID != c.OwnerID) {
return ErrPostNotFound
}
if c.IsProtected() && ((u == nil || u.ID != c.OwnerID) && !isAuthorizedForCollection(app, c.Alias, r)) {
return impart.HTTPError{http.StatusFound, c.CanonicalURL() + "/?g=" + slug}
if c.IsProtected() && (u == nil || u.ID != c.OwnerID) {
if suspended {
return ErrPostNotFound
} else if !isAuthorizedForCollection(app, c.Alias, r) {
return impart.HTTPError{http.StatusFound, c.CanonicalURL() + "/?g=" + slug}
}
}

cr.isCollOwner = u != nil && c.OwnerID == u.ID
Expand Down
2 changes: 1 addition & 1 deletion templates/edit-meta.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
<script>
function updateMeta() {
if ({{.Suspended}}) {
alert('Your account is currently supsended, editing posts is disabled.');
alert("Your account is silenced, so you can't edit posts.");
return
}
document.getElementById('create-error').style.display = 'none';
Expand Down
3 changes: 0 additions & 3 deletions templates/password-collection.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@

</head>
<body id="collection" itemscope itemtype="http://schema.org/WebPage">
{{if .Suspended}}
{{template "user-supsended"}}
{{end}}
<header>
<h1 dir="{{.Direction}}" id="blog-title"><a href="/{{.Alias}}/" class="h-card p-author u-url" rel="me author">{{.DisplayTitle}}</a></h1>
</header>
Expand Down

0 comments on commit ed40e9d

Please sign in to comment.