-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename ShowUser to FindUser and add error handling, start authenticat…
…ion_controller Not currently passing spec, our log_in before_action currently must take a User.
- Loading branch information
Showing
8 changed files
with
28 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class AuthenticatedController < ApplicationController | ||
before_action :log_in | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class FindUser | ||
include Interactor | ||
|
||
def call | ||
begin | ||
context.user = User.find(context.id) | ||
rescue ActiveRecord::RecordNotFound | ||
context.user = User.find(context.current_id) | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c86f141
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks @enriikke! This is a work-in-progress (not passing spec). I've made the changes except for the
log_in
modifications (and I haven't added theEncryptor
model, I'll do that in a separate branch).On
log_in
, I've started to reorganize things. Theauthenticated_controller
is, I think, in good shape and I've got it callinglog_in
as abefore_action
where appropriate. I think though that we need to change the waylog_in
orcurrent_user
works. I don't have aUser
to give it as an argument (if it's happening before aUser
is found). Currently,current_user
relies on us already having logged someone in. There are likely a few ways to handle this but do you have a suggestion for which method I should be looking to modify? Also, these methods live insessions_helper.rb
. That should be fine if we're calling them from a controller but perhaps they could be moved to ourAuthenticated_controller
? Or perhaps that's not super RESTful....