Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix password-protected page template #222

Merged
merged 6 commits into from Dec 18, 2019
Merged

Conversation

thebaer
Copy link
Member

@thebaer thebaer commented Dec 7, 2019

A typo in the password-protected.tmpl template would previously cause the page to fail. This fixes that.

It also updates the "silenced" alert text in edit-meta.tmpl.

Resolves #221.

Fixed "user-supsended" to "user-suspended"
Use "silenced" phrasing instead of "suspended"
@thebaer thebaer added this to the 0.11.2 milestone Dec 7, 2019
Previously, any password-protected collection on a suspended account
would prompt visitors for a password, and *then* take them to the "not
found" page. This fixes that.
@thebaer
Copy link
Member Author

thebaer commented Dec 17, 2019

Also noticed an issue with password-protected blogs for suspended accounts not returning a 404 right away. Fixed that in 6f6204a.

This is ready for review now.

@thebaer thebaer requested a review from a user December 17, 2019 18:08
Logged-in users never see this particular page, so it's not needed here.
@ghost
Copy link

ghost commented Dec 17, 2019

everything is working as described except another issue:

If the user with the protected blog is silenced, and another user who has entered the password visits the page of a post, not the blog root, the post is still displayed but with the 'you are silenced' banner.

I tested out a small fix to check for suspended collection owners on protected collection posts:

diff --git a/posts.go b/posts.go
index 9440ad8..1167c71 100644
--- a/posts.go
+++ b/posts.go
@@ -1342,6 +1342,9 @@ 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) && suspended {
+               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}
        }

I can push that up if you like.

@thebaer
Copy link
Member Author

thebaer commented Dec 17, 2019

Good catch. Yeah, feel free to push that -- though maybe combine the logic? e.g.

if c.IsProtected() && (u == nil || u.ID != c.OwnerID) {
  if suspended {
    return ErrPostNotFound
  } else if !isAuthorizedForCollection(app, c.Alias, r) {
    ...

a user who had previously authenticated on a protected collection would
still see the post after the owner was silenced, with a banner meant for
the owner displayed.
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with fix for previous authorized users this is good now.

tested logged in user, owner and logged out users for both protected collection and protected collection post with and without the owner silenced

@thebaer
Copy link
Member Author

thebaer commented Dec 18, 2019

Great, confirmed this is working. Merging now, thanks!

@thebaer thebaer merged commit ed40e9d into hotfix-0.11.2 Dec 18, 2019
@thebaer thebaer deleted the fix-template-typo branch December 18, 2019 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant