1
1
# README
2
2
3
+ ## Production Readyness
4
+
5
+ There are two goals for this project
6
+ 1 . To try and build a starting point which I can use to put together a project in a very short amount of time.
7
+ 2 . To try and answer some of the "what ifs" that I end up thinking about at my day job, but would be wholly
8
+ inapropriate to implement in a work setting due to their "unrailsy" nature
9
+
10
+ While this is a project that I'm using in apps that I hope will serve real customers, and I'm putting a reasonable
11
+ effort into mantaining this. Given the fact that there are experiemental code structure choises and dev builds
12
+ importmaps, caution is advised!
13
+
3
14
## Development environment setup
4
15
5
16
### Pre-Commit Hooks
@@ -60,6 +71,7 @@ Everyone should have pre-commit hooks setup!
60
71
omniauth, or replace with another authentication system.
61
72
- Caching
62
73
- [ Solid Cache] ( https://github.com/rails/solid_cache )
74
+ - N+1 catching via [ Bullet] ( https://github.com/flyerhzm/bullet )
63
75
64
76
## Style
65
77
@@ -110,13 +122,17 @@ class Authentication::Pages::LoginController < ApplicationController
110
122
validates_presence_of :email
111
123
validates_presence_of :password
112
124
125
+ validate :ensure_user_exists # Must run last for security
126
+
113
127
def user
114
128
@user ||= User .from_login_details(email: , password: )
115
129
end
116
130
117
131
def ensure_user_exists
132
+ return unless errors.blank?
133
+
118
134
if user.nil?
119
- errors.add :email , :no_user , message: " The email and password provided did not match our records"
135
+ errors.add :email , :no_user , message: " and password provided did not match our records"
120
136
end
121
137
end
122
138
end
@@ -156,11 +172,7 @@ class Authentication::Pages::LoginController < ApplicationController
156
172
def submit
157
173
ViewContext .form_object = FormObject .new (user_params)
158
174
159
- if ViewContext .form_object.validations_passed?
160
- ViewContext .form_object.ensure_user_exists
161
- end
162
-
163
- if ViewContext .form_object.validations_passed?
175
+ if ViewContext .form_object.valid?
164
176
ViewContext .form_object.user.add_to_session(session)
165
177
166
178
redirect_to dashboard_home_path, status: :see_other
@@ -181,5 +193,3 @@ class Authentication::Pages::LoginController < ApplicationController
181
193
end
182
194
end
183
195
```
184
-
185
-
0 commit comments