Skip to content

Commit 76b0390

Browse files
committed
Changed some things
1 parent 5867fd4 commit 76b0390

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+440
-96
lines changed

Gemfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
source "https://rubygems.org"
21

2+
source "https://rubygems.org"
33
ruby "3.3.0"
44

55
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
66
gem "rails", "~> 7.1.2"
77

88
# Propshaft!
9-
gem "propshaft"
9+
gem "propshaft",
10+
github: "calebowens/propshaft",
11+
ref: "fbae0e4f9b389b172fc3d1eec75598d7bd4af894"
1012

1113
# Use postgresql as the database for Active Record
1214
gem "pg", "~> 1.1"
@@ -15,7 +17,9 @@ gem "pg", "~> 1.1"
1517
gem "puma", ">= 5.0"
1618

1719
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
18-
gem "importmap-rails", "~> 1.0"
20+
gem "importmap-rails",
21+
github: "calebowens/importmap-rails",
22+
ref: "ebddf48364c46498df3109de4ab5a0b1e0cff660"
1923

2024
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
2125
gem "turbo-rails"

Gemfile.lock

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
GIT
2+
remote: https://github.com/calebowens/importmap-rails.git
3+
revision: ebddf48364c46498df3109de4ab5a0b1e0cff660
4+
ref: ebddf48364c46498df3109de4ab5a0b1e0cff660
5+
specs:
6+
importmap-rails (2.0.1)
7+
actionpack (>= 6.0.0)
8+
activesupport (>= 6.0.0)
9+
railties (>= 6.0.0)
10+
11+
GIT
12+
remote: https://github.com/calebowens/propshaft.git
13+
revision: fbae0e4f9b389b172fc3d1eec75598d7bd4af894
14+
ref: fbae0e4f9b389b172fc3d1eec75598d7bd4af894
15+
specs:
16+
propshaft (0.8.0)
17+
actionpack (>= 7.0.0)
18+
activesupport (>= 7.0.0)
19+
rack
20+
railties (>= 7.0.0)
21+
122
GEM
223
remote: https://rubygems.org/
324
specs:
@@ -135,10 +156,6 @@ GEM
135156
google-protobuf (3.25.2)
136157
i18n (1.14.1)
137158
concurrent-ruby (~> 1.0)
138-
importmap-rails (1.2.3)
139-
actionpack (>= 6.0.0)
140-
activesupport (>= 6.0.0)
141-
railties (>= 6.0.0)
142159
io-console (0.7.2)
143160
irb (1.11.1)
144161
rdoc
@@ -182,7 +199,7 @@ GEM
182199
nokogiri (1.16.0-x86_64-linux)
183200
racc (~> 1.4)
184201
parallel (1.24.0)
185-
parser (3.3.0.4)
202+
parser (3.3.0.5)
186203
ast (~> 2.4.1)
187204
racc
188205
pg (1.5.4)
@@ -197,11 +214,6 @@ GEM
197214
phlex-testing-capybara (0.1.0)
198215
capybara (~> 3.38)
199216
phlex (>= 0.5)
200-
propshaft (0.8.0)
201-
actionpack (>= 7.0.0)
202-
activesupport (>= 7.0.0)
203-
rack
204-
railties (>= 7.0.0)
205217
psych (5.1.2)
206218
stringio
207219
public_suffix (5.0.4)
@@ -289,7 +301,7 @@ GEM
289301
rexml (~> 3.2, >= 3.2.5)
290302
rubyzip (>= 1.2.2, < 3.0)
291303
websocket (~> 1.0)
292-
solid_cache (0.3.0)
304+
solid_cache (0.4.1)
293305
activejob (>= 7)
294306
activerecord (>= 7)
295307
railties (>= 7)
@@ -351,13 +363,13 @@ DEPENDENCIES
351363
dartsass-rails (~> 0.5.0)
352364
debug
353365
good_job
354-
importmap-rails (~> 1.0)
366+
importmap-rails!
355367
jbuilder
356368
js-routes
357369
pg (~> 1.1)
358370
phlex-rails
359371
phlex-testing-capybara
360-
propshaft
372+
propshaft!
361373
puma (>= 5.0)
362374
rails (~> 7.1.2)
363375
selenium-webdriver

app/assets/config/manifest.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//= link_tree ../images
2+
//= link_tree ../../javascript .js
3+
//= link_tree ../../../vendor/javascript .js
4+
//= link_tree ../builds

app/common/user.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def initialize(db_user:)
88
@db_user = db_user
99
end
1010

11-
def self.create(email:, password:)
11+
def self.create!(email:, password:)
1212
db_user = DbUser.new(email:, password:)
1313
if db_user.save
1414
User.new(db_user:)

app/features/authentication/components/login_form.rb

Whitespace-only changes.

app/features/authentication/components/register_form.rb

Lines changed: 0 additions & 23 deletions
This file was deleted.

app/features/authentication/pages/logout_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class Authentication::Actions::LogoutController < ApplicationController
1+
class Authentication::Pages::LogoutController < ApplicationController
22
def handle
33
Current.user&.remove_from_session(session)
44

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,81 @@
1-
class Authentication::Actions::RegisterController < ApplicationController
2-
def handle
1+
class Authentication::Pages::RegisterController < ApplicationController
2+
class ViewContext < ActiveSupport::CurrentAttributes
3+
attribute :form_object
4+
end
5+
6+
class FormObject
7+
include ActiveModel::Model
8+
include HasErrors
9+
10+
attr_accessor :email, :password, :confirm_password
11+
12+
validates :email, presence: true
13+
validates :password, presence: true, length: {minimum: 8, maximum: 64}
14+
validates :confirm_password, presence: true, comparison: {equal_to: -> { password }}
15+
end
16+
17+
class View
18+
def template
19+
h1 { "Create a user" }
20+
21+
render Form
22+
end
23+
end
24+
25+
class Form
26+
def template
27+
form_with(url: authentication_register_path, id: "register") do |f|
28+
f.label :email, "Email"
29+
f.text_field :email, value: @submission[:email]
30+
render @submission.errors_for(:email)
31+
32+
f.label :password, "Password"
33+
f.password_field :password
34+
render @submission.errors_for(:password)
35+
36+
f.label :confirm_password, "Confirm Password"
37+
f.password_field :confirm_password
38+
render @submission.errors_for(:confirm_password)
39+
40+
f.submit "Register"
41+
end
42+
end
43+
end
44+
45+
def view
346
redirect_to root_path if Current.user
447

5-
render Authentication::Views::Register
48+
ViewContext.form_object = FormObject.new
49+
50+
render View
51+
end
52+
53+
def submit
54+
ViewContext.form_object = FormObject.new(user_params)
55+
56+
if ViewContext.form_object.validations_passed?
57+
end
58+
59+
if ViewContext.form_object.validations_passed?
60+
user = User.create!(email: submission[:email], password: submission[:password])
61+
62+
user.add_to_session session
63+
64+
redirect_to dashboard_home_path, status: :see_other
65+
else
66+
render_or_replace_id(
67+
page: -> { View.new },
68+
target_id: "register",
69+
replacement: -> { Form.new }
70+
)
71+
end
72+
end
73+
74+
def user_params
75+
params.permit(
76+
:email,
77+
:password,
78+
:confirm_password
79+
)
680
end
781
end

app/features/authentication/pages/register_submit_controller.rb

Lines changed: 0 additions & 39 deletions
This file was deleted.

app/features/authentication/views/login.rb

Whitespace-only changes.

0 commit comments

Comments
 (0)