Skip to content

Commit 85fd817

Browse files
committed
Merge branch 'main' of github.com:devcongress/hackathon
2 parents d8ac749 + f6fa396 commit 85fd817

File tree

15 files changed

+76
-84
lines changed

15 files changed

+76
-84
lines changed

.env.local.template

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@
88
GOOGLE_CLIENT_ID=GOOGLE_CLIENT_ID
99
GOOGLE_CLIENT_SECRET=GOOGLE_CLIENT_SECRET
1010
GITHUB_CLIENT_ID=GITHUB_CLIENT_ID
11-
GITHUB_CLIENT_SECRET=GITHUB_CLIENT_SECRET
11+
GITHUB_CLIENT_SECRET=GITHUB_CLIENT_SECRET
12+
13+
POSTMARK_API_TOKEN=POSTMARK_API_TOKEN

Gemfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,12 @@ gem "rotp", "~> 6.3"
9898

9999
gem "rqrcode", "~> 3.1"
100100

101-
gem "dockerfile-rails", ">= 1.7", :group => :development
101+
gem "dockerfile-rails", ">= 1.7", group: :development
102102

103103
gem "pg", "~> 1.6"
104104

105105
gem "litestream", "~> 0.14.0"
106106

107-
gem "aws-sdk-s3", "~> 1.199", :require => false
107+
gem "aws-sdk-s3", "~> 1.199", require: false
108+
109+
gem "postmark-rails", "~> 0.22.1"

Gemfile.lock

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ GEM
378378
phlexi-display
379379
phlexi-field (~> 0.2.0)
380380
zeitwerk
381-
plutonium (0.26.9)
381+
plutonium (0.26.10)
382382
action_policy (~> 0.7.0)
383383
listen (~> 3.8)
384384
pagy (~> 9.0)
@@ -398,6 +398,11 @@ GEM
398398
tailwind_merge
399399
tty-prompt (~> 0.23.1)
400400
zeitwerk
401+
postmark (1.25.1)
402+
json
403+
postmark-rails (0.22.1)
404+
actionmailer (>= 3.0.0)
405+
postmark (>= 1.21.3, < 2.0)
401406
pp (0.6.2)
402407
prettyprint
403408
prettyprint (0.2.0)
@@ -664,6 +669,7 @@ DEPENDENCIES
664669
omniauth-google-oauth2 (~> 1.2)
665670
pg (~> 1.6)
666671
plutonium
672+
postmark-rails (~> 0.22.1)
667673
propshaft
668674
puma (>= 5.0)
669675
rails (~> 8.0.1)

app/definitions/profile_definition.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,16 @@ class ProfileDefinition < ::ResourceDefinition
44

55
edit_page_title "Edit Your Profile"
66
index_page_title "Team Members"
7+
8+
class Form < Form
9+
private
10+
11+
def render_actions
12+
input name: "return_to", value: request.params[:return_to], type: :hidden, hidden: true
13+
14+
actions_wrapper {
15+
render submit_button
16+
}
17+
end
18+
end
719
end

app/rodauth/admin_rodauth_plugin.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,12 @@ class AdminRodauthPlugin < RodauthPlugin
150150
# Or only remember users that have ticked a "Remember Me" checkbox on login.
151151
# after_login { remember_login if param_or_nil("remember") }
152152

153-
# Extend user's remember period when remembered via a cookie
153+
# Extend user's remember period when remembered via a cookie
154154
extend_remember_deadline? true
155155

156+
# Use separate session key for admin authentication
157+
session_key "_admin_session"
158+
156159
# Store the user's remember cookie under a namespace
157160
remember_cookie_key "_admin_remember"
158161

app/rodauth/hacker_rodauth_plugin.rb

Lines changed: 14 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@ class HackerRodauthPlugin < RodauthPlugin
1717
:login,
1818
:remember,
1919
:logout,
20-
:create_account,
21-
:verify_account,
22-
:verify_account_grace_period,
23-
:reset_password,
24-
:reset_password_notify,
25-
:change_login,
26-
:verify_login_change,
27-
:change_password,
28-
:change_password_notify,
2920
:case_insensitive_login,
3021
:internal_request
3122
)
@@ -47,9 +38,6 @@ class HackerRodauthPlugin < RodauthPlugin
4738
# Change prefix of table and foreign key column names from default "account"
4839
accounts_table :hackers
4940
remember_table :hacker_remember_keys
50-
reset_password_table :hacker_password_reset_keys
51-
verify_account_table :hacker_verification_keys
52-
verify_login_change_table :hacker_login_change_keys
5341

5442
# The secret key used for hashing public-facing tokens for various features.
5543
# Defaults to Rails `secret_key_base`, but you can use your own secret key.
@@ -73,7 +61,6 @@ class HackerRodauthPlugin < RodauthPlugin
7361
# Change some default param keys.
7462
login_param "email"
7563
login_label "Email"
76-
# password_confirm_param "confirm_password"
7764

7865
# Redirect back to originally requested location after authentication.
7966
login_return_to_requested_location? true
@@ -92,39 +79,6 @@ class HackerRodauthPlugin < RodauthPlugin
9279
# Requires the JSON feature
9380
# only_json? false
9481

95-
# ==> Emails
96-
# Use a custom mailer for delivering authentication emails.
97-
98-
create_reset_password_email do
99-
Rodauth::HackerMailer.reset_password(self.class.configuration_name,
100-
account_id, reset_password_key_value)
101-
end
102-
103-
create_verify_account_email do
104-
Rodauth::HackerMailer.verify_account(self.class.configuration_name,
105-
account_id, verify_account_key_value)
106-
end
107-
108-
create_verify_login_change_email do |_login|
109-
Rodauth::HackerMailer.verify_login_change(
110-
self.class.configuration_name,
111-
account_id,
112-
verify_login_change_key_value
113-
)
114-
end
115-
116-
create_password_changed_email do
117-
Rodauth::HackerMailer.change_password_notify(
118-
self.class.configuration_name, account_id
119-
)
120-
end
121-
122-
create_reset_password_notify_email do
123-
Rodauth::HackerMailer.reset_password_notify(
124-
self.class.configuration_name, account_id
125-
)
126-
end
127-
12882
send_email do |email|
12983
# queue email delivery on the mailer after the transaction commits
13084
db.after_commit { email.deliver_later }
@@ -152,7 +106,7 @@ class HackerRodauthPlugin < RodauthPlugin
152106
# ==> Passwords
153107

154108
# Passwords shorter than 8 characters are considered weak according to OWASP.
155-
password_minimum_length 8
109+
# password_minimum_length 8
156110

157111
# Custom password complexity requirements (alternative to password_complexity feature).
158112
# password_meets_requirements? do |password|
@@ -182,6 +136,9 @@ class HackerRodauthPlugin < RodauthPlugin
182136
# Extend user's remember period when remembered via a cookie
183137
extend_remember_deadline? true
184138

139+
# Use separate session key for hacker authentication
140+
session_key "_hacker_session"
141+
185142
# Store the user's remember cookie under a namespace
186143
remember_cookie_key "_hacker_remember"
187144

@@ -211,24 +168,24 @@ class HackerRodauthPlugin < RodauthPlugin
211168
# Profile.find_by!(account_id: account_id).destroy
212169
# end
213170

214-
create_account_route "register"
215-
216171
# ==> Redirects
217172

218-
# Redirect to home after login.
219-
create_account_redirect "/hacker_dashboard"
173+
# Ensure auto-login after omniauth account creation
174+
omniauth_create_account? true
175+
176+
# Redirect to dashboard after omniauth login/create (user is auto-logged in)
177+
after_omniauth_create_account do
178+
# Explicitly login if not already logged in
179+
login_session(account_id) unless logged_in?
180+
redirect "/hacker_dashboard"
181+
end
220182

221183
# Redirect to home after login.
222184
login_redirect "/hacker_dashboard"
223185

224186
# Redirect to home page after logout.
225-
logout_redirect "/"
226-
227-
# Redirect to wherever login redirects to after account verification.
228-
verify_account_redirect { login_redirect }
187+
logout_redirect "/hacker_dashboard"
229188

230-
# Redirect to login page after password reset.
231-
reset_password_redirect { login_path }
232189
# ==> Deadlines
233190
# Change default deadlines for some actions.
234191
# verify_account_grace_period 3.days.to_i

app/views/rodauth/hacker/_login_form.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<h1
33
class="
44
text-md leading-tight tracking-tight text-gray-900 md:text-lg dark:text-white
5-
text-center
5+
text-center hidden
66
"
77
>
88
Sign in to your account
99
</h1>
10-
<%= form_with url: rodauth(:hacker).login_path, method: :post, data: { turbo: false }, class: "space-y-4" do |form| %>
10+
<%= form_with url: rodauth(:hacker).login_path, method: :post, data: { turbo: false }, class: "space-y-4 hidden" do |form| %>
1111
<div>
1212
<%= form.label "login",
1313
rodauth(:hacker).login_label,

app/views/rodauth/hacker/_omniauth_links.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<%= @google_text %>
2828
<% end %>
2929

30-
<div class="flex items-center my-4">
30+
<div class="flex items-center my-4 hidden">
3131
<div class="flex-grow border-t border-gray-300"></div>
3232
<span class="px-4 dark:text-white text-gray-700">or</span>
3333
<div class="flex-grow border-t border-gray-300"></div>

config/environments/production.rb

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,9 @@
6060
# Set host to be used by links generated in mailer templates.
6161
config.action_mailer.default_url_options = {host: "hack25.devcongress.io"}
6262

63-
# Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit.
64-
config.action_mailer.smtp_settings = {
65-
user_name: "apikey",
66-
password: ENV["SENDGRID_API_KEY"],
67-
address: "smtp.sendgrid.net",
68-
port: 587,
69-
authentication: :plain,
70-
enable_starttls_auto: true
63+
config.action_mailer.delivery_method = :postmark
64+
config.action_mailer.postmark_settings = {
65+
api_token: ENV["POSTMARK_API_TOKEN"]
7166
}
7267

7368
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to

config/initializers/001_ensure_required_env.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55

66
if Rails.env.production?
77
required_env_vars += %w[
8-
RAILS_MASTER_KEY
8+
RAILS_MASTER_KEY DATABASE_URL
9+
POSTMARK_API_TOKEN
10+
GOOGLE_CLIENT_ID GOOGLE_CLIENT_SECRET
911
]
12+
# GITHUB_CLIENT_ID GITHUB_CLIENT_SECRET
1013
end
1114

1215
# Add additional env vars here

0 commit comments

Comments
 (0)