Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Add note on login path helper
  • Loading branch information
grega authored Jan 4, 2023
1 parent 89d0752 commit bcd43fd
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,29 @@ To login via Hydra your app needs to send the user to `/auth/rpi` via a POST req

```ruby
<%= link_to 'Log in', '/auth/rpi', method: :post %>
# or:
<%= button_to 'Log in', '/auth/rpi' %>
```

A GET request will be blocked by the CSRF protection gem.

Alternatively, create a dummy route to allow its use in helpers, eg.

```ruby
# Dummy route. This route is never reached in the app, as RPiAuth / Omniauth gets it
# before it reaches Rails, however adding this route allows us to use
# login_path helpers etc.
post '/auth/rpi', as: 'login'
```

Followed by:

```ruby
<%= link_to 'Log in', login_path, method: :post %>
# or:
<%= button_to 'Log in', login_path %>
```

There is a helper for the logout route:

```ruby
Expand Down

0 comments on commit bcd43fd

Please sign in to comment.