Iteration I3: Permitting Access
We want people without an administrative login to be able to purchase our products. This, too, can be accomplished with very little code.
We could go back and change things so that we mark only those methods that specifically need authorization. Such an approach, called denylisting, is prone to errors of omission. A much better approach is to allowlist—list methods or controllers for which authorization is not required. We do this by inserting an allow_unauthenticated_access call within the StoreController:
| | class StoreController < ApplicationController |
| » | allow_unauthenticated_access |
And we do it again for the SessionsController class.
We’re not done yet; ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access