rails_jwt_auth 0.10.1 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -0
- data/app/models/concerns/rails_jwt_auth/authenticatable.rb +12 -0
- data/config/locales/en.yml +1 -0
- data/lib/rails_jwt_auth/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb1e415a9ec09f06237ed0aa2a020044cc72c8ea
|
4
|
+
data.tar.gz: e8772b6b9e8e711d4803ee63ce3fdaf21e6b374b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 232806debf45ed172ff4db611bb25ce530f5c0312e51de21c4995af25133963bd1045f4078ebf1c646872e5e151ed9b6092d32ab07647abc6641f13ef129f39e
|
7
|
+
data.tar.gz: 50cca6d19567f8c2ceb2c80b338fd9ee3a34edb20c237378f52e955c66620de6e9371f9a0bea73b2c8b48d24ead03a2ca4f042df0ca6127cb2a382c38f7c0431
|
data/README.md
CHANGED
@@ -352,6 +352,31 @@ And edit route resource to use it:
|
|
352
352
|
resource :registration, controller: 'registrations', only: [:create, :update, :destroy]
|
353
353
|
```
|
354
354
|
|
355
|
+
## Edit user information
|
356
|
+
|
357
|
+
This is a controller example that allows users to edit their `email` and `password`.
|
358
|
+
|
359
|
+
```ruby
|
360
|
+
class CurrentUserController < ApplicationController
|
361
|
+
before_action 'authenticate!'
|
362
|
+
|
363
|
+
def update
|
364
|
+
if update_params[:password]
|
365
|
+
current_user.update_with_password(update_params)
|
366
|
+
else
|
367
|
+
current_user.update_attributes(update_params)
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
private
|
372
|
+
|
373
|
+
def update_params
|
374
|
+
params.require(:user).permit(:email, :current_password, :password)
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
```
|
379
|
+
|
355
380
|
## Custom responses
|
356
381
|
|
357
382
|
You can overwrite `RailsJwtAuth::RenderHelper` to customize controllers responses.
|
@@ -24,6 +24,18 @@ module RailsJwtAuth
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
def update_with_password(params)
|
28
|
+
if (current_password = params.delete(:current_password)).blank?
|
29
|
+
errors.add(:current_password, I18n.t('rails_jwt_auth.errors.blank'))
|
30
|
+
false
|
31
|
+
elsif authenticate(current_password)
|
32
|
+
update_attributes(params)
|
33
|
+
else
|
34
|
+
errors.add(:current_password, I18n.t('rails_jwt_auth.errors.invalid'))
|
35
|
+
false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
27
39
|
module ClassMethods
|
28
40
|
def get_by_token(token)
|
29
41
|
if defined?(Mongoid) && ancestors.include?(Mongoid::Document)
|
data/config/locales/en.yml
CHANGED
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.11.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-
|
11
|
+
date: 2017-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|