rails_jwt_auth 0.19.3 → 0.20.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a7954b3c32181adbad0fc1353f87503eb3c1a9da366aa57019121249bb0d859
|
4
|
+
data.tar.gz: dc7d92d0ad939cfc508284986ad11671abe6d8ec1d8ec8476d4ec1d1b9d99468
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d8b93466166a0ecee271dcce19b0bcdfba81006d50f05253120cb8b2605f8c7c35407c994352c2cb7829801e01a297778d01610c3fb32a04e43c71cc17d30cd
|
7
|
+
data.tar.gz: 1ae8ee7ec75ac8685e64a5662d3372cca533f4a78088fa1ce4d9a1bd0109652e02c88ddb4341238bd3be8d20d65f8401a3e2ea0c5c05b01a09ce99634abcc617
|
data/README.md
CHANGED
@@ -453,17 +453,21 @@ Note: To add more fields, see "Custom strong parameters" below.
|
|
453
453
|
You can overwrite RailsJwtAuth controllers to edit actions, responses,
|
454
454
|
permitted parameters...
|
455
455
|
|
456
|
-
For example, if we want to
|
456
|
+
For example, if we want to call custom method when user is created we need to
|
457
457
|
create new registration controller inherited from default controller:
|
458
458
|
|
459
459
|
```ruby
|
460
460
|
# app/controllers/registrations_controller.rb
|
461
461
|
class RegistrationsController < RailsJwtAuth::RegistrationsController
|
462
|
-
|
462
|
+
...
|
463
463
|
|
464
|
-
def
|
465
|
-
|
464
|
+
def create
|
465
|
+
user = RailsJwtAuth.model.new(create_params)
|
466
|
+
user.do_something_custom
|
467
|
+
...
|
466
468
|
end
|
469
|
+
|
470
|
+
...
|
467
471
|
end
|
468
472
|
```
|
469
473
|
|
@@ -474,6 +478,32 @@ And edit route resource to use it:
|
|
474
478
|
resource :registration, controller: 'registrations', only: [:create, :update, :destroy]
|
475
479
|
```
|
476
480
|
|
481
|
+
## Custom payload
|
482
|
+
|
483
|
+
If you need edit default payload used to generate jwt you can overwrite the method `to_token_payload` into your User class:
|
484
|
+
|
485
|
+
```ruby
|
486
|
+
class User < ApplicationRecord
|
487
|
+
include RailsJwtAuth::Authenticatable
|
488
|
+
...
|
489
|
+
|
490
|
+
def to_token_payload(request)
|
491
|
+
{
|
492
|
+
auth_token: regenerate_auth_token,
|
493
|
+
# add here your custom info
|
494
|
+
}
|
495
|
+
end
|
496
|
+
end
|
497
|
+
```
|
498
|
+
|
499
|
+
## Custom responses
|
500
|
+
|
501
|
+
You can overwrite `RailsJwtAuth::RenderHelper` to customize controllers responses.
|
502
|
+
|
503
|
+
## Custom strong parameters
|
504
|
+
|
505
|
+
You can overwrite `RailsJwtAuth::ParamsHelper` to customize controllers strong parameters.
|
506
|
+
|
477
507
|
## Edit user information
|
478
508
|
|
479
509
|
This is a controller example that allows users to edit their `email` and `password`.
|
@@ -520,14 +550,6 @@ class UsersController < ApplicationController
|
|
520
550
|
end
|
521
551
|
```
|
522
552
|
|
523
|
-
## Custom responses
|
524
|
-
|
525
|
-
You can overwrite `RailsJwtAuth::RenderHelper` to customize controllers responses.
|
526
|
-
|
527
|
-
## Custom strong parameters
|
528
|
-
|
529
|
-
You can overwrite `RailsJwtAuth::ParamsHelper` to customize controllers strong parameters.
|
530
|
-
|
531
553
|
## Testing (rspec)
|
532
554
|
|
533
555
|
Require the RailsJwtAuth::Spec::Helpers helper module in `rails_helper.rb`.
|
@@ -38,6 +38,10 @@ module RailsJwtAuth
|
|
38
38
|
errors.empty? ? update_attributes(params) : false
|
39
39
|
end
|
40
40
|
|
41
|
+
def to_token_payload(_request)
|
42
|
+
{auth_token: regenerate_auth_token}
|
43
|
+
end
|
44
|
+
|
41
45
|
module ClassMethods
|
42
46
|
def get_by_token(token)
|
43
47
|
if defined?(Mongoid) && ancestors.include?(Mongoid::Document)
|
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.
|
4
|
+
version: 0.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rjurado
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|