Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Current user from channel. #760

Closed
MTEKode opened this issue Nov 4, 2016 · 4 comments
Closed

Current user from channel. #760

MTEKode opened this issue Nov 4, 2016 · 4 comments

Comments

@MTEKode
Copy link

MTEKode commented Nov 4, 2016

Hi,
How I can get current_user from channel?
I am using angularjs with ng-token-auth.

Thanks.

@merqlove
Copy link
Contributor

Something like this:

def find_verified_user
  ApplicationRecord.connection_pool.with_connection do |conn|
    headers = JSON.parse(cookies['auth_headers'] || '{}')
    uid       = headers['uid']
    token     = headers['access-token']
    client_id = headers['client']

    return nil unless token

    user = uid && User.find_by_uid(uid)

    if user && user.valid_token?(token, client_id)
      user
    end
  end
end

@brunowego
Copy link

Thanks @merqlove. I have similar issue but with multitenancy (apartment gem). Have a experience with this situation?

@merqlove
Copy link
Contributor

@brunowego it's different question kind, but I think you can run dta as shared service, and check tokens/session per tenant.

@zachfeldman
Copy link
Contributor

Possible solutions posted (Thanks @merqlove ), closing for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants