rails_jwt_auth 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 29c7fdf2a0ecc3b2b48adc80426f802e411a7d315ad3d502d54591ba7978abd1
4
- data.tar.gz: b7224f3281c49cb6c40ab28156c296a9cb74b3eefb68ac932940a931aa2886be
3
+ metadata.gz: 3ce38e7a38fa015a6dbf8b1504e41fd273cf3646d0b2d9053c63476d55b3c729
4
+ data.tar.gz: 9581d2075661754ed5d43f3a344c8d3fd0da631b9b5c8ea8e51b65fa14bb2c33
5
5
  SHA512:
6
- metadata.gz: e208d2d4fc4a900a584a03d718b8539f0f53717d2bbeb15189d125d6f235e135c6e8d7de77df60cf128611cf512b8380fa747c604572495eebca32abff8d26f6
7
- data.tar.gz: ab21acd7f88451742875b62f131c86243c715cc3c942ba94b7d6782c266800b68c35aef5b524c86e5bbbdbd2c9943f286d09e62d59a03562fdc667f4aae5dbd6
6
+ metadata.gz: f0bdc862727abcdc1db5d1a3e00bd124b7ac15e45d47e483b8487ba46854dfc68edda3a1dcef1d5cda55fb733840f7679f2bbd03996cae3ee4e775d0f12f5a5d
7
+ data.tar.gz: 58cd478adf9a9145fb33e7f531e8010faa6e68f86243478515333acc9aa5578531f047ca059620ae1ce867cff8fbbf7a03de5ceb81e30ede35b9d8360e5392b6
data/README.md CHANGED
@@ -5,9 +5,26 @@
5
5
 
6
6
  Rails-API authentication solution based on JWT and inspired by Devise.
7
7
 
8
- This is documentation for version `1.x`. If you are using `0.x` version use this
8
+ > This is documentation for version `1.x`. If you are using `0.x` version use this
9
9
  [link](https://github.com/rjurado01/rails_jwt_auth/tree/0.x)
10
10
 
11
+ ## Table of Contents
12
+
13
+ - [Installation](#installation)
14
+ - [Configuration](#configuration)
15
+ - [Modules](#modules)
16
+ - [ORMs support](#orms-support)
17
+ - [Controller helpers](#controller-helpers)
18
+ - [Default Controllers API](#default-controllers-api)
19
+ - [Customize]()
20
+ + [Controllers](#custom-controllers)
21
+ + [Payload](#custom-payload)
22
+ + [Responses](#custom-responses)
23
+ + [Strong parameters](#custom-strong-parameters)
24
+ - [Examples](#examples)
25
+ - [Testing](#testing-rspec)
26
+ - [License](#license)
27
+
11
28
  ## Installation
12
29
 
13
30
  Add this line to your application's Gemfile:
@@ -65,6 +82,8 @@ You can edit configuration options into `config/initializers/auth_token_auth.rb`
65
82
 
66
83
  ## Modules
67
84
 
85
+ It's composed of 5 modules:
86
+
68
87
  | Module | Description |
69
88
  | ------------- | --------------------------------------------------------------------------------------------------------------- |
70
89
  | Authenticable | Hashes and stores a password in the database to validate the authenticity of a user while signing in |
@@ -73,7 +92,9 @@ You can edit configuration options into `config/initializers/auth_token_auth.rb`
73
92
  | Trackable | Tracks sign in timestamps and IP address |
74
93
  | Invitable | Allows you to invite an user to your application sending an invitation mail |
75
94
 
76
- ### Examples
95
+ ## ORMs support
96
+
97
+ RailsJwtAuth support both Mongoid and ActiveRecord.
77
98
 
78
99
  For next examples `auth_field_name` and `email_field_name` are configured to use the field `email`.
79
100
 
@@ -90,11 +111,11 @@ class User < ApplicationRecord
90
111
 
91
112
  validates :email, presence: true,
92
113
  uniqueness: true,
93
- format: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
114
+ format: URI::MailTo::EMAIL_REGEXP
94
115
  end
95
116
  ```
96
117
 
97
- Ensure you have executed migrate task: `rails g rails_jwt_auth:migrate` and you have uncomented all modules fields.
118
+ Ensure you have executed migrate task: `rails g rails_jwt_auth:migrate` and you have uncomented all modules fields into generated [migration file](https://github.com/rjurado01/rails_jwt_auth/blob/master/lib/generators/templates/migration.rb).
98
119
 
99
120
  **Mongoid**
100
121
 
@@ -111,7 +132,7 @@ class User
111
132
 
112
133
  validates :email, presence: true,
113
134
  uniqueness: true,
114
- format: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
135
+ format: URI::MailTo::EMAIL_REGEXP
115
136
  end
116
137
  ```
117
138
 
@@ -321,7 +342,11 @@ Invitations api is provided by `RailsJwtAuth::InvitationsController`.
321
342
 
322
343
  Note: To add more fields, see "Custom strong parameters" below.
323
344
 
324
- ## Custom controllers
345
+ ## Customize
346
+
347
+ RailsJwtAuth offers an easy way to customize certain parts.
348
+
349
+ ### Custom controllers
325
350
 
326
351
  You can overwrite RailsJwtAuth controllers to edit actions, responses,
327
352
  permitted parameters...
@@ -351,7 +376,7 @@ And edit route resource to use it:
351
376
  resource :registration, controller: 'registrations', only: [:create, :update, :destroy]
352
377
  ```
353
378
 
354
- ## Custom payload
379
+ ### Custom payload
355
380
 
356
381
  If you need edit default payload used to generate jwt you can overwrite the method `to_token_payload` into your User class:
357
382
 
@@ -369,15 +394,17 @@ class User < ApplicationRecord
369
394
  end
370
395
  ```
371
396
 
372
- ## Custom responses
397
+ ### Custom responses
373
398
 
374
399
  You can overwrite `RailsJwtAuth::RenderHelper` to customize controllers responses.
375
400
 
376
- ## Custom strong parameters
401
+ ### Custom strong parameters
377
402
 
378
403
  You can overwrite `RailsJwtAuth::ParamsHelper` to customize controllers strong parameters.
379
404
 
380
- ## Edit user information
405
+ ## Examples
406
+
407
+ ### Edit user information
381
408
 
382
409
  This is a controller example that allows users to edit their `email` and `password`.
383
410
 
@@ -401,7 +428,7 @@ class CurrentUserController < ApplicationController
401
428
  end
402
429
  ```
403
430
 
404
- ## Register users with random password
431
+ ### Register users with random password
405
432
 
406
433
  This is a controller example that allows admins to register users with random password and send email to reset it.
407
434
  If registration is sucess it will send email to `set_password_url` with reset password token.
@@ -5,7 +5,7 @@ module RailsJwtAuth
5
5
  .to receive(:authenticate!).and_return(true)
6
6
 
7
7
  allow_any_instance_of(RailsJwtAuth::AuthenticableHelper)
8
- .to receive(:current_user).and_return(user)
8
+ .to receive(:current_user).and_return(user.class.find(user.id))
9
9
  end
10
10
 
11
11
  def sign_out
@@ -1,3 +1,3 @@
1
1
  module RailsJwtAuth
2
- VERSION = '1.3.0'
2
+ VERSION = '1.3.1'
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: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - rjurado
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-23 00:00:00.000000000 Z
11
+ date: 2019-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt
@@ -42,16 +42,22 @@ dependencies:
42
42
  name: rails
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '5.0'
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: '6.1'
48
51
  type: :runtime
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
52
- - - "~>"
55
+ - - ">="
53
56
  - !ruby/object:Gem::Version
54
57
  version: '5.0'
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '6.1'
55
61
  description: Rails authentication solution based on Warden and JWT and inspired by
56
62
  Devise.
57
63
  email:
@@ -113,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
119
  version: '0'
114
120
  requirements: []
115
121
  rubyforge_project:
116
- rubygems_version: 2.7.6
122
+ rubygems_version: 2.7.3
117
123
  signing_key:
118
124
  specification_version: 4
119
125
  summary: Rails jwt authentication.