-
Notifications
You must be signed in to change notification settings - Fork 0
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
Issue39 auth save token #41
Conversation
lib/etna/auth.rb
Outdated
@@ -77,6 +77,7 @@ def approve_user(request) | |||
|
|||
begin | |||
payload, header = application.sign.jwt_decode(token) | |||
payload['token'] = token |
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.
Are we sure the payload will never contain the parameter 'token' in the future? Can we instead pass the token as an optional second argument to Etna::User.new?
spec/test_auth_spec.rb
Outdated
@@ -37,6 +37,12 @@ class Server < Etna::Server; end | |||
expect(user).to be_a(Etna::User) | |||
expect(user.is_admin?('labors')).to be_truthy | |||
expect(user.can_edit?('constellations')).to be_falsy | |||
expect(user.token).to eq(Base64.strict_encode64({ | |||
email: 'janus@two-faces.org', |
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.
This could be replaced with the same hash as above in a variable.
expect(u.token).to eq('xyz123randomtoken') | ||
end | ||
|
||
it 'returns basic user info without token param' do |
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.
This first test is barely necessary, two of these is too much methinks.
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.
I wasn't super confident I had the syntax right for the optional part, so wanted an objective validation :-)
Seems fine to merge this. |
#39
Note that this is on top of your
graft-repair-hmac
branch, and not on top of master.Adds a
token
attribute to theUser
class, and passes that data in during the Auth process (plus for TestAuth).