mjackson / mjackson/sinatra-session
Custom fail method
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 37
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
Hey. First of all I dig the gem, loving how simple it is. Not sure if it was intended for my type of use though. I'm building an API which requires authentication for certain requests, but a simple redirect to '/whatever_route' isn't quite what one would expect when developing against an API and authentication fails.
Maybe I'm just lacking the necessary Sinatra skills (yes I am new at this), but something like
def authentication_required
status 403
{"error" => "Authentication required."}.to_json
end
set :session_fail, lambda { authentication_required }
would be awesome. Of course the "authentication_required" method fails here as it doesn't have the status method. Any way to accomplish this? Would love to send a PR with documentation if you can help me figure this out. Cheers! :)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the existing session-failure handling behind set :session_fail and how that callback is invoked. Confirm whether the callback can access Sinatra response helpers; done means an unauthenticated request can return status 403 and the requested JSON body, with documentation if supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- authentication
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100