Created
January 23, 2019 15:39
-
-
Save dLobatog/41e0b47391e904fe3d6f00335ad4a7db to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 13: def authenticate_user | |
| 14: binding.pry | |
| => 15: return unauthenticated unless identity_header | |
| 16: | |
| 17: account = Account.find_or_create_by( | |
| 18: account_number: identity_header_content['account_number'] | |
| 19: ) | |
| 20: user = find_or_create_user(identity_header_content['user']['username'], | |
| 21: account) | |
| 22: return if performed? || !user.persisted? | |
| 23: | |
| 24: User.current = user | |
| 25: rescue JSON::ParserError | |
| 26: unauthenticated 'Error parsing the X-RH-IDENTITY header' | |
| 27: end | |
| [1] pry(#<GraphqlController>)> identity_header | |
| => "eyJpZGVudGl0eSI6eyJhY2NvdW50X251bWJlciI6IjE0NjAyOTAiLCJ0eXBlIjoiVXNlciIsInVzZXIiOnsidXNlcm5hbWUiOiJkbG9iYXRvZ0ByZWRoYXQuY29tIiwiZW1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment