rails_jwt_auth 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a4b26a2187fcea5e112d830e6fe4c359b6c254e
4
- data.tar.gz: c03420a5b617a85fcf3abe79029d12e1fc28d05d
3
+ metadata.gz: 808b8e1b69bc9436608046e8f55038edeb682471
4
+ data.tar.gz: fdeb6c11cb065a111e93745fa58340c66ba87c2d
5
5
  SHA512:
6
- metadata.gz: 147277f3faf5e26b7df0d2ba902de62c3ab5ddc2cb11f9f851c058202612d2686a31e2adc8d89d34d84123a757d744e0d012df18569d1cbbfb9c82a726577195
7
- data.tar.gz: 0d694343c935a6968417523c43853eabe68d521e15c09b0387b604bc6bf30a388659ea23c9a9ddd483738d19fb8321f3a5679c4277b4176c3dc14fc6861aab65
6
+ metadata.gz: e29a0701f454f1ea0d7b3eac33475c2c5451649676014c11ab37111aec834d62071f856716a01dde03b6dfa0129a5151a16f7f27e97695a9ab5d4292abc9bae5
7
+ data.tar.gz: 0cc896578dc215894bc5cec3a2333a47452d16a4034ccc365d9d0e56fde105ccd0bd1fffbfaf227929ace52b7cf8190b54954c4b980a85048ff7e7500045c03c
@@ -1,6 +1,11 @@
1
1
  module RailsJwtAuth
2
2
  module RenderHelper
3
- def render_201(resource)
3
+ def render_session(jwt, user)
4
+ auth_field = RailsJwtAuth.auth_field_name
5
+ render json: {session: {jwt: jwt, auth_field => user[auth_field]}}, status: 201
6
+ end
7
+
8
+ def render_registration(resource)
4
9
  render json: resource, root: true, status: 201
5
10
  end
6
11
 
@@ -5,7 +5,7 @@ module RailsJwtAuth
5
5
 
6
6
  def create
7
7
  user = RailsJwtAuth.model.new(registration_create_params)
8
- user.save ? render_201(user) : render_422(user.errors)
8
+ user.save ? render_registration(user) : render_422(user.errors)
9
9
  end
10
10
  end
11
11
  end
@@ -15,7 +15,7 @@ module RailsJwtAuth
15
15
  elsif user.respond_to?('confirmed?') && !user.confirmed?
16
16
  render_422 session: [I18n.t('rails_jwt_auth.errors.unconfirmed')]
17
17
  elsif user.authenticate(session_create_params[:password])
18
- render_201 session: {jwt: get_jwt(user)}
18
+ render_session get_jwt(user), user
19
19
  else
20
20
  render_422 session: [create_session_error]
21
21
  end
@@ -24,6 +24,7 @@ module RailsJwtAuth
24
24
  def destroy
25
25
  authenticate!
26
26
  current_user.destroy_auth_token Jwt::Request.new(request).auth_token
27
+ render_204
27
28
  end
28
29
 
29
30
  private
@@ -1,3 +1,3 @@
1
1
  module RailsJwtAuth
2
- VERSION = '0.9.0'
2
+ VERSION = '0.10.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_jwt_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - rjurado
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-12 00:00:00.000000000 Z
11
+ date: 2017-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails