Skip to content

Commit 2f7db03

Browse files
committed
Add login_options as a permitted param; add rpi_auth_signup_path
1 parent 03c1442 commit 2f7db03

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,13 @@ link_to 'Log in', rpi_auth_login_path, method: :post
9696
button_to 'Log in', rpi_auth_login_path
9797
```
9898

99-
There is also a helper for the logout route:
99+
There is a helper for the sign-up buttons, which pushes the user through the sign-up flow.
100+
101+
```ruby
102+
button_to 'Sign up', rpi_auth_signup_path
103+
```
104+
105+
And there is also a helper for the logout route:
100106

101107
```ruby
102108
link_to 'Log out', rpi_auth_logout_path

config/routes.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# frozen_string_literal: true
22

33
Rails.application.routes.draw do
4-
# Dummy route. This route is never reached in the app, as Omniauth intercepts
5-
# it via Rack middleware before it reaches Rails, however adding this route
6-
# allows us to use rpi_auth_login_path helpers etc.
4+
# Dummy routes. These routes are never reached in the app, as Omniauth
5+
# intercepts it via Rack middleware before it reaches Rails, however adding
6+
# them allows us to use rpi_auth_login_path helpers etc.
77
post '/auth/rpi', as: :rpi_auth_login
8+
post '/auth/rpi', as: :rpi_auth_signup, params: { login_options: 'force_signup,v1_signup' }
89

910
namespace 'rpi_auth' do
1011
get '/auth/callback', to: 'auth#callback', as: 'callback'

lib/rpi_auth/engine.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Engine < ::Rails::Engine
3636
jwks_uri: RpiAuth.configuration.jwks_uri
3737
},
3838
extra_authorize_params: { brand: RpiAuth.configuration.brand },
39+
allow_authorize_params: [ :login_options ],
3940
origin_param: 'returnTo'
4041
)
4142

spec/dummy/app/views/home/show.html.erb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
<% else %>
88
<%= button_to 'Log in', rpi_auth_login_path, method: :post %>
99
<br />
10-
<%= link_to 'Log in GET', rpi_auth_login_path %>
10+
<%= link_to 'Log in GET', rpi_auth_login_path %> (should 404)
11+
<br />
12+
<%= button_to 'Sign up', rpi_auth_signup_path, method: :post %>
1113
<% end %>
1214
</p>

0 commit comments

Comments
 (0)