-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
88cea8a
commit 55691b2
Showing
3 changed files
with
28 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,4 +1,21 @@ | ||
module ApplicationCable | ||
class Connection < ActionCable::Connection::Base | ||
identified_by :current_user | ||
def connect | ||
self.current_user = find_verified_user | ||
end | ||
|
||
def find_verified_user | ||
if cookies.signed['user_token'] != nil | ||
user = User.where(persistence_token: cookies.signed['user_token']) | ||
if user.any? | ||
return user.first | ||
else | ||
return nil | ||
end | ||
else | ||
return nil | ||
end | ||
end | ||
end | ||
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