Skip to content

Commit 2799f34

Browse files
authored
Feature/sup 88 update ruby rails app with new style (#27)
* upgrades to ruby 2.7 and also adds most style changes with most session management in place * removes .DS_Store files * removes pry * adds full styling to app as well as additional devise methods * removes connection ID in controller * removes pry from file * removes .ds_store file
1 parent ce7f00d commit 2799f34

File tree

9 files changed

+194
-102
lines changed

9 files changed

+194
-102
lines changed

ruby-rails-sso-example/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ gem 'webpacker', '~> 4.0'
1717
gem 'turbolinks', '~> 5'
1818
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
1919
gem 'jbuilder', '~> 2.7'
20-
20+
gem 'pry'
2121
gem "sprockets-rails"
2222
gem "net-http"
2323
# Use Redis adapter to run Action Cable in production

ruby-rails-sso-example/Gemfile.lock

Lines changed: 61 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,67 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
actioncable (7.0.2.3)
5-
actionpack (= 7.0.2.3)
6-
activesupport (= 7.0.2.3)
4+
actioncable (7.0.2.4)
5+
actionpack (= 7.0.2.4)
6+
activesupport (= 7.0.2.4)
77
nio4r (~> 2.0)
88
websocket-driver (>= 0.6.1)
9-
actionmailbox (7.0.2.3)
10-
actionpack (= 7.0.2.3)
11-
activejob (= 7.0.2.3)
12-
activerecord (= 7.0.2.3)
13-
activestorage (= 7.0.2.3)
14-
activesupport (= 7.0.2.3)
9+
actionmailbox (7.0.2.4)
10+
actionpack (= 7.0.2.4)
11+
activejob (= 7.0.2.4)
12+
activerecord (= 7.0.2.4)
13+
activestorage (= 7.0.2.4)
14+
activesupport (= 7.0.2.4)
1515
mail (>= 2.7.1)
1616
net-imap
1717
net-pop
1818
net-smtp
19-
actionmailer (7.0.2.3)
20-
actionpack (= 7.0.2.3)
21-
actionview (= 7.0.2.3)
22-
activejob (= 7.0.2.3)
23-
activesupport (= 7.0.2.3)
19+
actionmailer (7.0.2.4)
20+
actionpack (= 7.0.2.4)
21+
actionview (= 7.0.2.4)
22+
activejob (= 7.0.2.4)
23+
activesupport (= 7.0.2.4)
2424
mail (~> 2.5, >= 2.5.4)
2525
net-imap
2626
net-pop
2727
net-smtp
2828
rails-dom-testing (~> 2.0)
29-
actionpack (7.0.2.3)
30-
actionview (= 7.0.2.3)
31-
activesupport (= 7.0.2.3)
29+
actionpack (7.0.2.4)
30+
actionview (= 7.0.2.4)
31+
activesupport (= 7.0.2.4)
3232
rack (~> 2.0, >= 2.2.0)
3333
rack-test (>= 0.6.3)
3434
rails-dom-testing (~> 2.0)
3535
rails-html-sanitizer (~> 1.0, >= 1.2.0)
36-
actiontext (7.0.2.3)
37-
actionpack (= 7.0.2.3)
38-
activerecord (= 7.0.2.3)
39-
activestorage (= 7.0.2.3)
40-
activesupport (= 7.0.2.3)
36+
actiontext (7.0.2.4)
37+
actionpack (= 7.0.2.4)
38+
activerecord (= 7.0.2.4)
39+
activestorage (= 7.0.2.4)
40+
activesupport (= 7.0.2.4)
4141
globalid (>= 0.6.0)
4242
nokogiri (>= 1.8.5)
43-
actionview (7.0.2.3)
44-
activesupport (= 7.0.2.3)
43+
actionview (7.0.2.4)
44+
activesupport (= 7.0.2.4)
4545
builder (~> 3.1)
4646
erubi (~> 1.4)
4747
rails-dom-testing (~> 2.0)
4848
rails-html-sanitizer (~> 1.1, >= 1.2.0)
49-
activejob (7.0.2.3)
50-
activesupport (= 7.0.2.3)
49+
activejob (7.0.2.4)
50+
activesupport (= 7.0.2.4)
5151
globalid (>= 0.3.6)
52-
activemodel (7.0.2.3)
53-
activesupport (= 7.0.2.3)
54-
activerecord (7.0.2.3)
55-
activemodel (= 7.0.2.3)
56-
activesupport (= 7.0.2.3)
57-
activestorage (7.0.2.3)
58-
actionpack (= 7.0.2.3)
59-
activejob (= 7.0.2.3)
60-
activerecord (= 7.0.2.3)
61-
activesupport (= 7.0.2.3)
52+
activemodel (7.0.2.4)
53+
activesupport (= 7.0.2.4)
54+
activerecord (7.0.2.4)
55+
activemodel (= 7.0.2.4)
56+
activesupport (= 7.0.2.4)
57+
activestorage (7.0.2.4)
58+
actionpack (= 7.0.2.4)
59+
activejob (= 7.0.2.4)
60+
activerecord (= 7.0.2.4)
61+
activesupport (= 7.0.2.4)
6262
marcel (~> 1.0)
6363
mini_mime (>= 1.1.0)
64-
activesupport (7.0.2.3)
64+
activesupport (7.0.2.4)
6565
concurrent-ruby (~> 1.0, >= 1.0.2)
6666
i18n (>= 1.6, < 2)
6767
minitest (>= 5.1)
@@ -100,15 +100,14 @@ GEM
100100
activesupport (>= 5.0)
101101
i18n (1.10.0)
102102
concurrent-ruby (~> 1.0)
103-
io-wait (0.2.1)
104103
jbuilder (2.11.5)
105104
actionview (>= 5.0.0)
106105
activesupport (>= 5.0.0)
107106
json (2.6.1)
108107
listen (3.7.1)
109108
rb-fsevent (~> 0.10, >= 0.10.3)
110109
rb-inotify (~> 0.9, >= 0.9.10)
111-
loofah (2.15.0)
110+
loofah (2.17.0)
112111
crass (~> 1.0.2)
113112
nokogiri (>= 1.5.9)
114113
mail (2.7.1)
@@ -119,7 +118,7 @@ GEM
119118
mini_mime (1.1.2)
120119
mini_portile2 (2.8.0)
121120
minitest (5.15.0)
122-
msgpack (1.4.5)
121+
msgpack (1.5.1)
123122
net-http (0.2.0)
124123
net-protocol
125124
uri
@@ -131,8 +130,7 @@ GEM
131130
digest
132131
net-protocol
133132
timeout
134-
net-protocol (0.1.2)
135-
io-wait
133+
net-protocol (0.1.3)
136134
timeout
137135
net-smtp (0.3.1)
138136
digest
@@ -146,7 +144,7 @@ GEM
146144
pry (0.14.1)
147145
coderay (~> 1.1)
148146
method_source (~> 1.0)
149-
public_suffix (4.0.6)
147+
public_suffix (4.0.7)
150148
puma (4.3.12)
151149
nio4r (~> 2.0)
152150
racc (1.6.0)
@@ -155,28 +153,28 @@ GEM
155153
rack
156154
rack-test (1.1.0)
157155
rack (>= 1.0, < 3)
158-
rails (7.0.2.3)
159-
actioncable (= 7.0.2.3)
160-
actionmailbox (= 7.0.2.3)
161-
actionmailer (= 7.0.2.3)
162-
actionpack (= 7.0.2.3)
163-
actiontext (= 7.0.2.3)
164-
actionview (= 7.0.2.3)
165-
activejob (= 7.0.2.3)
166-
activemodel (= 7.0.2.3)
167-
activerecord (= 7.0.2.3)
168-
activestorage (= 7.0.2.3)
169-
activesupport (= 7.0.2.3)
156+
rails (7.0.2.4)
157+
actioncable (= 7.0.2.4)
158+
actionmailbox (= 7.0.2.4)
159+
actionmailer (= 7.0.2.4)
160+
actionpack (= 7.0.2.4)
161+
actiontext (= 7.0.2.4)
162+
actionview (= 7.0.2.4)
163+
activejob (= 7.0.2.4)
164+
activemodel (= 7.0.2.4)
165+
activerecord (= 7.0.2.4)
166+
activestorage (= 7.0.2.4)
167+
activesupport (= 7.0.2.4)
170168
bundler (>= 1.15.0)
171-
railties (= 7.0.2.3)
169+
railties (= 7.0.2.4)
172170
rails-dom-testing (2.0.3)
173171
activesupport (>= 4.2.0)
174172
nokogiri (>= 1.6)
175173
rails-html-sanitizer (1.4.2)
176174
loofah (~> 2.3)
177-
railties (7.0.2.3)
178-
actionpack (= 7.0.2.3)
179-
activesupport (= 7.0.2.3)
175+
railties (7.0.2.4)
176+
actionpack (= 7.0.2.4)
177+
activesupport (= 7.0.2.4)
180178
method_source
181179
rake (>= 12.2)
182180
thor (~> 1.0)
@@ -185,7 +183,7 @@ GEM
185183
rb-fsevent (0.11.1)
186184
rb-inotify (0.10.1)
187185
ffi (~> 1.0)
188-
regexp_parser (2.2.1)
186+
regexp_parser (2.3.1)
189187
responders (3.0.1)
190188
actionpack (>= 5.0)
191189
railties (>= 5.0)
@@ -205,7 +203,7 @@ GEM
205203
childprocess (>= 0.5, < 5.0)
206204
rexml (~> 3.2, >= 3.2.5)
207205
rubyzip (>= 1.2.2)
208-
sorbet-runtime (0.5.9782)
206+
sorbet-runtime (0.5.9964)
209207
spring (2.1.1)
210208
spring-watcher-listen (2.0.1)
211209
listen (>= 2.7, < 4.0)
@@ -253,6 +251,7 @@ GEM
253251
zeitwerk (2.5.4)
254252

255253
PLATFORMS
254+
-darwin-21
256255
ruby
257256

258257
DEPENDENCIES
@@ -284,4 +283,4 @@ RUBY VERSION
284283
ruby 2.7.1p83
285284

286285
BUNDLED WITH
287-
1.17.2
286+
2.3.0

ruby-rails-sso-example/app/controllers/users/sessions_controller.rb

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Users::SessionsController < Devise::SessionsController
66
CLIENT_ID = ENV['WORKOS_CLIENT_ID']
77

88
# Set the Connection ID that you want to test
9-
CONNECTION_ID = 'conn_01FHQ0G8Q6WTP0YT1E3CVNQD6V'
9+
CONNECTION_ID = 'YOUR CONNECTION ID'
1010

1111
# GET /sso/new path to authenticate via WorkOS
1212
# You can also use connection or provider parameters
@@ -28,9 +28,8 @@ def callback
2828
code: params['code'],
2929
client_id: CLIENT_ID,
3030
)
31-
3231
@user = User.from_sso(profile_and_token.profile)
33-
32+
@user.save
3433
sign_in_and_redirect @user
3534
end
3635

@@ -40,11 +39,6 @@ def after_sign_in_path_for(_resource)
4039
end
4140

4241
def destroy
43-
if current_user
44-
puts current_user.id
45-
session.delete(current_user.id)
46-
flash[:success] = 'Goodbye!'
47-
end
48-
redirect_to root_path
42+
sign_out_and_redirect(current_user)
4943
end
5044
end

ruby-rails-sso-example/app/views/application/home.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22
<%= stylesheet_link_tag "application", media: "all" %>
33

44
</head>
5-
<% if current_user %>
6-
75
<div class="logged_in_nav">
86
<div class="flex">
9-
<p>You're logged in , welcome!</p>
107
</div>
118
<div>
129
<%= image_tag("workos_logo_new.png", :alt => "WorkOS Logo") %>
@@ -27,6 +24,9 @@
2724
</div>
2825
</div>
2926
<div class="logged_in_div_right">
27+
<% if current_user %>
28+
<p>You're logged in , welcome!</p>
29+
3030
<div class="flex_column">
3131
<h2>Raw Profile Response Details</h2>
3232
<div class="text_box">

ruby-rails-sso-example/app/views/layouts/application.html.erb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<title>Rails SSO Example App</title>
55
<%= csrf_meta_tags %>
66
<%= csp_meta_tag %>
7-
<%= javascript_include_tag :defaults %>
87
<%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
98
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
109
</head>
Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,58 @@
1-
<h2 class="text-center m-5">Sign up</h2>
2-
<section class="col-8 offset-2 col-sm-6 offset-sm-3">
3-
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
4-
<%= render "devise/shared/error_messages", resource: resource %>
1+
<head>
2+
<%= stylesheet_link_tag "application", media: "all" %>
53

6-
<div class="field">
7-
<%= f.label :email %><br />
8-
<%= f.email_field :email, autofocus: true, autocomplete: "email", class: 'form-control m-2' %>
4+
</head>
5+
<div class="logged_in_nav">
6+
<div class="flex">
97
</div>
10-
11-
<div class="field">
12-
<%= f.label :password %>
13-
<% if @minimum_password_length %>
14-
<em>(<%= @minimum_password_length %> characters minimum)</em>
15-
<% end %><br />
16-
<%= f.password_field :password, autocomplete: "new-password", class: 'form-control m-2' %>
8+
<div>
9+
<%= image_tag("workos_logo_new.png", :alt => "WorkOS Logo") %>
1710
</div>
18-
19-
<div class="field">
20-
<%= f.label :password_confirmation %><br />
21-
<%= f.password_field :password_confirmation, autocomplete: "new-password", class: 'form-control m-2' %>
11+
</div>
12+
<div class='flex'>
13+
<div class="logged_in_div_left">
14+
<div>
15+
<h1>Your app,</h1>
16+
<h2>Enterprise Ready</h2>
17+
</div>
18+
<div>
19+
<a href="https://workos.com/" target="_blank"><button class='button'>WorkOS</button></a>
20+
<a href="https://workos.com/docs" target="_blank"><button class='button'>Documentation</button></a>
21+
<a href="https://workos.com/docs/reference" target="_blank"><button class='button'>API Reference</button></a>
22+
<a href="https://workos.com/blog" target="_blank"><button class='button'>Blog</button></a>
23+
24+
</div>
2225
</div>
26+
<div class="logged_in_div_right">
2327

24-
<div class="actions">
25-
<%= f.submit "Sign up", class: 'btn btn-primary m-2' %>
26-
</div>
27-
<% end %>
28-
<hr>
29-
<%= render "users/shared/links" %>
30-
</section>
28+
<h2 class="text-center m-5">Sign up</h2>
29+
<section class="col-8 offset-2 col-sm-6 offset-sm-3">
30+
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
31+
<%= render "devise/shared/error_messages", resource: resource %>
32+
33+
<div class="field">
34+
<%= f.label :email %><br />
35+
<%= f.email_field :email, autofocus: true, autocomplete: "email", class: 'form-control m-2' %>
36+
</div>
37+
38+
<div class="field">
39+
<%= f.label :password %>
40+
<% if @minimum_password_length %>
41+
<em>(<%= @minimum_password_length %> characters minimum)</em>
42+
<% end %><br />
43+
<%= f.password_field :password, autocomplete: "new-password", class: 'form-control m-2' %>
44+
</div>
45+
46+
<div class="field">
47+
<%= f.label :password_confirmation %><br />
48+
<%= f.password_field :password_confirmation, autocomplete: "new-password", class: 'form-control m-2' %>
49+
</div>
50+
51+
<div class="actions">
52+
<%= f.submit "Sign up", class: 'btn btn-primary m-2' %>
53+
</div>
54+
<% end %>
55+
<hr>
56+
<%= render "users/shared/links" %>
57+
</section>
58+
</div>

0 commit comments

Comments
 (0)