pressbooks / pressbooks-book

McLuhan is the default book theme for Pressbooks.
https://pressbooks.org
GNU General Public License v3.0
20 stars 16 forks source link

Customize access denied message based on user's login state #1154

Closed SteelWagstaff closed 1 year ago

SteelWagstaff commented 1 year ago

If a regular user signs in from a private book that they don't have any user permissions within, they’re returned to the default Access Denied page while logged into the network:

Screenshot 2023-02-22 at 7 50 53 AM

In this situation, the "sign in here" linked text redirects them to the same (Access Denied) page.

This is potentially confusing for users who do have an account on a network and who expect to have access to a private book but aren't a user on it yet. The generic Access Denied page seems to imply that they either aren't a registered user on the network or aren't logged in yet, but they are a logged in user in the network, they just don't have permissions in this book.

A specific Access Denied private book page for a user who is signed into the network but isn't a user on a given book would solve this. Perhaps it could contain linked text linking to the user dashboard?

Originally posted by @tw77 in https://github.com/pressbooks/pressbooks/issues/3195#issuecomment-1440406098

SteelWagstaff commented 1 year ago

I'd like to fix this by updating the message more generically for all cases. Perhaps something like: 'This book is private, and accessible only to registered users. To access the content, either sign in to your account or request access from a book or network administrator.

You can also create your own Pressbooks book at Pressbooks.pub.'

I believe the text that needs to be revised exists at https://github.com/pressbooks/pressbooks/blob/917fe37eedfa5415db57f58f00c46388f91d396b/inc/class-activation.php#L259

tw77 commented 1 year ago

'This book is private, and accessible only to registered users. To access the content, either sign in to your account or request access to this book.

You can also create your own Pressbooks book at Pressbooks.pub.'

tw77 commented 1 year ago

Tested and this is working as expected on dev.pressbooks.network.

Screenshot 2023-02-22 at 11 28 32 AM