devise_token_auth 0.1.39 → 0.1.40

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of devise_token_auth might be problematic. Click here for more details.

Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -6
  3. data/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +2 -1
  4. data/app/controllers/devise_token_auth/passwords_controller.rb +2 -3
  5. data/app/controllers/devise_token_auth/registrations_controller.rb +1 -1
  6. data/app/controllers/devise_token_auth/sessions_controller.rb +6 -1
  7. data/app/models/devise_token_auth/concerns/user_omniauth_callbacks.rb +1 -1
  8. data/config/locales/de.yml +22 -23
  9. data/config/locales/en.yml +1 -2
  10. data/config/locales/es.yml +1 -2
  11. data/config/locales/fr.yml +1 -2
  12. data/config/locales/it.yml +46 -0
  13. data/config/locales/ja.yml +0 -1
  14. data/config/locales/nl.yml +0 -1
  15. data/config/locales/pl.yml +1 -3
  16. data/config/locales/pt-BR.yml +1 -2
  17. data/config/locales/pt.yml +1 -3
  18. data/config/locales/ro.yml +46 -0
  19. data/config/locales/ru.yml +3 -4
  20. data/config/locales/zh-CN.yml +1 -9
  21. data/config/locales/zh-HK.yml +0 -1
  22. data/config/locales/zh-TW.yml +0 -1
  23. data/lib/devise_token_auth/rails/routes.rb +4 -1
  24. data/lib/devise_token_auth/url.rb +22 -1
  25. data/lib/devise_token_auth/version.rb +1 -1
  26. data/lib/generators/devise_token_auth/USAGE +1 -1
  27. data/lib/generators/devise_token_auth/templates/devise_token_auth_create_users.rb.erb +5 -5
  28. data/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb +17 -0
  29. data/test/controllers/devise_token_auth/passwords_controller_test.rb +15 -0
  30. data/test/controllers/devise_token_auth/sessions_controller_test.rb +89 -0
  31. data/test/dummy/app/models/lockable_user.rb +5 -0
  32. data/test/dummy/config/routes.rb +2 -0
  33. data/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb +60 -0
  34. data/test/dummy/db/schema.rb +21 -1
  35. data/test/models/user_test.rb +22 -0
  36. metadata +8 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 69aefa1a60b35d0639a7ce60d2145992a1421288
4
- data.tar.gz: 99d081fe410204ca5b64eb0406a602731d564b4b
3
+ metadata.gz: f3e318b47eb34d368c22c9fb6858d558e877322f
4
+ data.tar.gz: 36100cc69480a97cfcd99ab3ef0ec6bf142b9e89
5
5
  SHA512:
6
- metadata.gz: 187e75b7fc83677e77b11cadcdcb7f30ca60e825d246d83a5f68530ca1dd3aa034183f9750efd16b826c4ed83bd50f7b99e6eb48329b4933f5b6e7c7997c1894
7
- data.tar.gz: 1b95f3264baece0776433da8f186c2e48a47b52f8308212ed1038c78458e4ddf5fc601560cdb191cc40a504a69d2faaa4cc339e5397094dedaf821dd7ab1c144
6
+ metadata.gz: 5b9d347ffaa08b281d78a9155c26093824ec8fea9e21693dc1e6a699a8254d409d5dee86606561607aa33675eceb5282c02525ce2df2c5e282d3f20b23709e33
7
+ data.tar.gz: d851b30ebc2fe9d7fce6ad65cfb7b7bd507abc34757743c0487736f13fedd2627166c82c129d9e0ba2609810fcbfe3d405900a247ef79ba144544830b5844834
data/README.md CHANGED
@@ -12,7 +12,10 @@
12
12
 
13
13
  This gem provides the following features:
14
14
 
15
- * Seamless integration with both the the venerable [ng-token-auth](https://github.com/lynndylanhurley/ng-token-auth) module for [angular.js](https://github.com/angular/angular.js) and the outstanding [jToker](https://github.com/lynndylanhurley/j-toker) plugin for [jQuery](https://jquery.com/).
15
+ * Seamless integration with:
16
+ * [ng-token-auth](https://github.com/lynndylanhurley/ng-token-auth) for [AngularJS](https://github.com/angular/angular.js)
17
+ * [Angular2-Token](https://github.com/neroniaky/angular2-token) for [Angular2](https://github.com/angular/angular)
18
+ * [jToker](https://github.com/lynndylanhurley/j-toker) for [jQuery](https://jquery.com/)
16
19
  * Oauth2 authentication using [OmniAuth](https://github.com/intridea/omniauth).
17
20
  * Email authentication using [Devise](https://github.com/plataformatec/devise), including:
18
21
  * User registration
@@ -24,7 +27,9 @@ This gem provides the following features:
24
27
 
25
28
  # Live Demos
26
29
 
27
- [Here is a demo](http://ng-token-auth-demo.herokuapp.com/) of this app running with the [ng-token-auth](https://github.com/lynndylanhurley/ng-token-auth) module and [AngularJS](https://angularjs.org/).
30
+ [Here is a demo](http://ng-token-auth-demo.herokuapp.com/) of this app running with the [ng-token-auth](https://github.com/lynndylanhurley/ng-token-auth) module and [AngularJS](https://github.com/angular/angular.js).
31
+
32
+ [Here is a demo](https://angular2-token.herokuapp.com) of this app running with the [Angular2-Token](https://github.com/neroniaky/angular2-token) service and [Angular2](https://github.com/angular/angular).
28
33
 
29
34
  [Here is a demo](https://j-toker-demo.herokuapp.com/) of this app using the [jToker](https://github.com/lynndylanhurley/j-toker) plugin and [React](http://facebook.github.io/react/).
30
35
 
@@ -163,7 +168,7 @@ The following settings are available for configuration in `config/initializers/d
163
168
  | **`omniauth_prefix`** | `"/omniauth"` | This route will be the prefix for all oauth2 redirect callbacks. For example, using the default '/omniauth' setting, the github oauth2 provider will redirect successful authentications to '/omniauth/github/callback'. [Read more](#omniauth-provider-settings). |
164
169
  | **`default_confirm_success_url`** | `nil` | By default this value is expected to be sent by the client so that the API knows where to redirect users after successful email confirmation. If this param is set, the API will redirect to this value when no value is provided by the client. |
165
170
  | **`default_password_reset_url`** | `nil` | By default this value is expected to be sent by the client so that the API knows where to redirect users after successful password resets. If this param is set, the API will redirect to this value when no value is provided by the client. |
166
- | **`redirect_whitelist`** | `nil` | As an added security measure, you can limit the URLs to which the API will redirect after email token validation (password reset, email confirmation, etc.). This value should be an array containing exact matches to the client URLs to be visited after validation. |
171
+ | **`redirect_whitelist`** | `nil` | As an added security measure, you can limit the URLs to which the API will redirect after email token validation (password reset, email confirmation, etc.). This value should be an array containing matches to the client URLs to be visited after validation. Wildcards are supported. |
167
172
  | **`enable_standard_devise_support`** | `false` | By default, only Bearer Token authentication is implemented out of the box. If, however, you wish to integrate with legacy Devise authentication, you can do so by enabling this flag. NOTE: This feature is highly experimental! |
168
173
  | **`remove_tokens_after_password_reset`** | `false` | By default, old tokens are not invalidated when password is changed. Enable this option if you want to make passwords updates to logout other devices. |
169
174
  | **`default_callbacks`** | `true` | By default User model will include the `DeviseTokenAuth::Concerns::UserOmniauthCallbacks` concern, which has `email`, `uid` validations & `uid` synchronization callbacks. |
@@ -499,6 +504,7 @@ Models that include the `DeviseTokenAuth::Concerns::User` concern will have acce
499
504
  ### View Live Multi-User Demos
500
505
 
501
506
  * [AngularJS](http://ng-token-auth-demo.herokuapp.com/multi-user)
507
+ * [Angular2](https://angular2-token.herokuapp.com)
502
508
  * [React + jToker](http://j-toker-demo.herokuapp.com/#/alt-user)
503
509
 
504
510
  This gem supports the use of multiple user models. One possible use case is to authenticate visitors using a model called `User`, and to authenticate administrators with a model called `Admin`. Take the following steps to add another authentication model to your app:
@@ -764,20 +770,20 @@ These files may be edited to suit your taste. You can customize the e-mail subje
764
770
 
765
771
  When posting issues, please include the following information to speed up the troubleshooting process:
766
772
 
767
- * **Version**: which version of this gem (and [ng-token-auth](https://github.com/lynndylanhurley/ng-token-auth) / [jToker](https://github.com/lynndylanhurley/j-toker) if applicable) are you using?
773
+ * **Version**: which version of this gem (and [ng-token-auth](https://github.com/lynndylanhurley/ng-token-auth), [jToker](https://github.com/lynndylanhurley/j-toker) or [Angular2-Token](https://github.com/neroniaky/angular2-token) if applicable) are you using?
768
774
  * **Request and response headers**: these can be found in the "Network" tab of your browser's web inspector.
769
775
  * **Rails Stacktrace**: this can be found in the `log/development.log` of your API.
770
776
  * **Environmental Info**: How is your application different from the [reference implementation](https://github.com/lynndylanhurley/devise_token_auth_demo)? This may include (but is not limited to) the following details:
771
777
  * **Routes**: are you using some crazy namespace, scope, or constraint?
772
778
  * **Gems**: are you using MongoDB, Grape, RailsApi, ActiveAdmin, etc.?
773
779
  * **Custom Overrides**: what have you done in terms of [custom controller overrides](#custom-controller-overrides)?
774
- * **Custom Frontend**: are you using [ng-token-auth](https://github.com/lynndylanhurley/ng-token-auth), [jToker](https://github.com/lynndylanhurley/j-toker), or something else?
780
+ * **Custom Frontend**: are you using [ng-token-auth](https://github.com/lynndylanhurley/ng-token-auth), [jToker](https://github.com/lynndylanhurley/j-toker), [Angular2-Token](https://github.com/neroniaky/angular2-token), or something else?
775
781
 
776
782
  # FAQ
777
783
 
778
784
  ### Can I use this gem alongside standard Devise?
779
785
 
780
- Yes! But you will need to enable the support use separate routes for standard Devise. So do something like this:
786
+ Yes! But you will need to enable the support of separate routes for standard Devise. So do something like this:
781
787
 
782
788
  #### config/initializers/devise_token_auth.rb
783
789
  ~~~ruby
@@ -930,6 +936,7 @@ To run the test suite do the following:
930
936
  The last command will open the [guard](https://github.com/guard/guard) test-runner. Guard will re-run each test suite when changes are made to its corresponding files.
931
937
 
932
938
  To run just one test:
939
+
933
940
  1. Clone this repo
934
941
  2. Run `bundle install`
935
942
  3. Run `rake db:migrate`
@@ -13,7 +13,8 @@ module DeviseTokenAuth
13
13
  # before authentication.
14
14
  devise_mapping = [request.env['omniauth.params']['namespace_name'],
15
15
  request.env['omniauth.params']['resource_class'].underscore.gsub('/', '_')].compact.join('_')
16
- redirect_route = "#{request.protocol}#{request.host_with_port}/#{Devise.mappings[devise_mapping.to_sym].fullpath}/#{params[:provider]}/callback"
16
+ path = "#{Devise.mappings[devise_mapping.to_sym].fullpath}/#{params[:provider]}/callback"
17
+ redirect_route = URI::HTTP.build(scheme: request.scheme, host: request.host, port: request.port, path: path).to_s
17
18
 
18
19
  # preserve omniauth info for success route. ignore 'extra' in twitter
19
20
  # auth response to avoid CookieOverflow.
@@ -22,7 +22,7 @@ module DeviseTokenAuth
22
22
 
23
23
  # if whitelist is set, validate redirect_url against whitelist
24
24
  if DeviseTokenAuth.redirect_whitelist
25
- unless DeviseTokenAuth.redirect_whitelist.include?(@redirect_url)
25
+ unless DeviseTokenAuth::Url.whitelisted?(@redirect_url)
26
26
  return render_create_error_not_allowed_redirect_url
27
27
  end
28
28
  end
@@ -168,7 +168,6 @@ module DeviseTokenAuth
168
168
  def render_create_success
169
169
  render json: {
170
170
  success: true,
171
- data: resource_data,
172
171
  message: I18n.t("devise_token_auth.passwords.sended", email: @email)
173
172
  }
174
173
  end
@@ -223,7 +222,7 @@ module DeviseTokenAuth
223
222
  private
224
223
 
225
224
  def resource_params
226
- params.permit(:email, :password, :password_confirmation, :current_password, :reset_password_token)
225
+ params.permit(:email, :password, :password_confirmation, :current_password, :reset_password_token, :redirect_url, :config)
227
226
  end
228
227
 
229
228
  def password_resource_params
@@ -29,7 +29,7 @@ module DeviseTokenAuth
29
29
 
30
30
  # if whitelist is set, validate redirect_url against whitelist
31
31
  if DeviseTokenAuth.redirect_whitelist
32
- unless DeviseTokenAuth.redirect_whitelist.include?(@redirect_url)
32
+ unless DeviseTokenAuth::Url.whitelisted?(@redirect_url)
33
33
  return render_create_error_redirect_url_not_allowed
34
34
  end
35
35
  end
@@ -29,7 +29,12 @@ module DeviseTokenAuth
29
29
  @resource = resource_class.where(q, q_value).first
30
30
  end
31
31
 
32
- if @resource and valid_params?(field, q_value) and @resource.valid_password?(resource_params[:password]) and (!@resource.respond_to?(:active_for_authentication?) or @resource.active_for_authentication?)
32
+ if @resource and valid_params?(field, q_value) and (!@resource.respond_to?(:active_for_authentication?) or @resource.active_for_authentication?)
33
+ valid_password = @resource.valid_password?(resource_params[:password])
34
+ if (@resource.respond_to?(:valid_for_authentication?) && !@resource.valid_for_authentication? { valid_password }) || !valid_password
35
+ render_create_error_bad_credentials
36
+ return
37
+ end
33
38
  # create client id
34
39
  @client_id = SecureRandom.urlsafe_base64(nil, false)
35
40
  @token = SecureRandom.urlsafe_base64(nil, false)
@@ -18,7 +18,7 @@ module DeviseTokenAuth::Concerns::UserOmniauthCallbacks
18
18
  # only validate unique email among users that registered by email
19
19
  def unique_email_user
20
20
  if provider == 'email' and self.class.where(provider: 'email', email: email).count > 0
21
- errors.add(:email, I18n.t("errors.messages.already_in_use"))
21
+ errors.add(:email, :taken)
22
22
  end
23
23
  end
24
24
 
@@ -1,7 +1,7 @@
1
1
  de:
2
2
  devise_token_auth:
3
3
  sessions:
4
- not_confirmed: "Ein E-Mail zu Bestätigung wurde an Ihre Adresse '%{email}' gesendet. Sie müssen den Anleitungsschritten im E-Mail folgen, um Ihren Account zu aktivieren"
4
+ not_confirmed: "Eine Bestätigungs-E-Mail wurde an Ihre Adresse '%{email}' gesendet. Sie müssen der Anleitung in der E-Mail folgen, um Ihren Account zu aktivieren."
5
5
  bad_credentials: "Ungültige Anmeldeinformationen. Bitte versuchen Sie es erneut."
6
6
  not_supported: "Verwenden Sie POST /sign_in zur Anmeldung. GET wird nicht unterstützt."
7
7
  user_not_found: "Benutzer wurde nicht gefunden oder konnte nicht angemeldet werden."
@@ -12,39 +12,38 @@ de:
12
12
  redirect_url_not_allowed: "Weiterleitung zu '%{redirect_url}' ist nicht gestattet."
13
13
  email_already_exists: "Es gibt bereits einen Account für '%{email}'."
14
14
  account_with_uid_destroyed: "Account mit der uid '%{uid}' wurde gelöscht."
15
- account_to_destroy_not_found: "Der Account, der gelöscht werden soll, kann nicht gefunden werden."
15
+ account_to_destroy_not_found: "Der zu löschende Account kann nicht gefunden werden."
16
16
  user_not_found: "Benutzer kann nicht gefunden werden."
17
17
  passwords:
18
- missing_email: "Sie müssen eine E-Mail Adresse angeben."
19
- missing_redirect_url: "Es fehlt der URL zu Weiterleitung."
18
+ missing_email: "Sie müssen eine E-Mail-Adresse angeben."
19
+ missing_redirect_url: "Es fehlt die URL zu Weiterleitung."
20
20
  not_allowed_redirect_url: "Weiterleitung zu '%{redirect_url}' ist nicht gestattet."
21
- sended: "Ein E-Mail mit Anleitung zum Rücksetzen Ihres Passwortes wurde an '%{email}' gesendet."
22
- user_not_found: "Der Benutzer mit E-Mail-Adresse '%{email}' kann nicht gefunden werden."
23
- password_not_required: "Dieser Account benötigt kein Passwort. Melden Sie Sich stattdessen über Ihren Account bei '%{provider}' an."
24
- missing_passwords: "Sie müssen die Felder 'Passwort' and 'Passwortbestätigung' ausfüllen."
21
+ sended: "Ein E-Mail mit der Anleitung zum Zurücksetzen Ihres Passwortes wurde an '%{email}' gesendet."
22
+ user_not_found: "Der Benutzer mit der E-Mail-Adresse '%{email}' kann nicht gefunden werden."
23
+ password_not_required: "Dieser Account benötigt kein Passwort. Melden Sie sich stattdessen über Ihren Account bei '%{provider}' an."
24
+ missing_passwords: "Sie müssen die Felder 'Passwort' und 'Passwortbestätigung' ausfüllen."
25
25
  successfully_updated: "Ihr Passwort wurde erfolgreich aktualisiert."
26
26
  errors:
27
27
  messages:
28
28
  validate_sign_up_params: "Bitte übermitteln sie vollständige Anmeldeinformationen im Body des Requests."
29
29
  validate_account_update_params: "Bitte übermitteln sie vollständige Informationen zur Aktualisierung im Body des Requests."
30
- not_email: "ist keine E-Mail Adresse"
31
- already_in_use: "bereits in Verwendung"
30
+ not_email: "ist keine E-Mail-Adresse"
32
31
  devise:
33
32
  mailer:
34
33
  confirmation_instructions:
35
- subject: "Bestätigungs-"
36
- confirm_link_msg: "Sie können Ihr Konto E-Mail über den untenstehenden Link bestätigen:"
37
- confirm_account_link: "Ihr Konto zu bestätigen"
34
+ subject: "Bestätigung Ihres Kontos"
35
+ confirm_link_msg: "Sie können Ihr Konto über den untenstehenden Link bestätigen:"
36
+ confirm_account_link: "Konto bestätigen"
38
37
  reset_password_instructions:
39
- subject: "Wiederherstellungskennwort Anweisungen"
40
- request_reset_link_msg: "Jemand hat einen Link auf Ihr Kennwort zu ändern angefordert. Sie können dies durch den folgenden Link tun:"
41
- password_change_link: "Kennwort ändern"
42
- ignore_mail_msg: "Wenn Sie nicht angefordert haben diese , ignorieren Sie bitte diese E-Mail:"
43
- no_changes_msg: "Ihr Passwort wird nicht geändert , bis Sie auf den obigen Link zugreifen und eine neue erstellen ."
38
+ subject: "Passwort zurücksetzen"
39
+ request_reset_link_msg: "Jemand hat einen Link zur Änderungen Ihres Passwortes angefordert. Sie können dies durch den folgenden Link tun:"
40
+ password_change_link: "Passwort ändern"
41
+ ignore_mail_msg: "Wenn Sie keine Änderung Ihres Passwortes angefordert haben, ignorieren Sie bitte diese E-Mail:"
42
+ no_changes_msg: "Ihr Passwort wird nicht geändert, bis Sie auf den obigen Link zugreifen und eine neues Passwort erstellen."
44
43
  unlock_instructions:
45
- subject: "entsperren Anweisungen"
46
- account_lock_msg: "Ihr Konto wurde aufgrund einer übermäßigen Anzahl von erfolglosen Zeichen in Versuchen gesperrt."
47
- unlock_link_msg: "Klicken Sie auf den Link unten , um Ihr Konto zu entsperren :"
48
- unlock_link: "Entsperren Sie Ihr Konto "
44
+ subject: "Anweisungen zum Entsperren Ihres Kontos"
45
+ account_lock_msg: "Ihr Konto wurde aufgrund einer übermäßigen Anzahl von erfolglosen Anmeldeversuchen gesperrt."
46
+ unlock_link_msg: "Klicken Sie auf den Link unten, um Ihr Konto zu entsperren:"
47
+ unlock_link: "Entsperren Sie Ihr Konto"
49
48
  hello: "hallo"
50
- welcome: "willkommen"
49
+ welcome: "willkommen"
@@ -25,7 +25,6 @@ en:
25
25
  successfully_updated: "Your password has been successfully updated."
26
26
  errors:
27
27
  messages:
28
- already_in_use: "already in use"
29
28
  validate_sign_up_params: "Please submit proper sign up data in request body."
30
29
  validate_account_update_params: "Please submit proper account update data in request body."
31
30
  not_email: "is not an email"
@@ -44,4 +43,4 @@ en:
44
43
  unlock_link_msg: "Click the link below to unlock your account:"
45
44
  unlock_link: "Unlock my account"
46
45
  hello: "hello"
47
- welcome: "welcome"
46
+ welcome: "welcome"
@@ -28,7 +28,6 @@ es:
28
28
  validate_sign_up_params: "Los datos introducidos en la solicitud de acceso no son válidos."
29
29
  validate_account_update_params: "Los datos introducidos en la solicitud de actualización no son válidos."
30
30
  not_email: "no es un correo electrónico"
31
- already_in_use: "ya ha sido ocupado"
32
31
  devise:
33
32
  mailer:
34
33
  confirmation_instructions:
@@ -47,4 +46,4 @@ es:
47
46
  unlock_link_msg: "Para desbloquear su cuenta ingrese en el siguiente link:"
48
47
  unlock_link: "Desbloquear cuenta"
49
48
  hello: "hola"
50
- welcome: "bienvenido"
49
+ welcome: "bienvenido"
@@ -25,7 +25,6 @@ fr:
25
25
  successfully_updated: "Votre mot de passe a été correctement mis à jour."
26
26
  errors:
27
27
  messages:
28
- already_in_use: "déjà utilisé(e)"
29
28
  validate_sign_up_params: "Les données d'inscription dans le corps de la requête ne sont pas valides."
30
29
  validate_account_update_params: "Les données de mise à jour dans le corps de la requête ne sont pas valides."
31
30
  not_email: "n'est pas une adresse e-mail"
@@ -47,4 +46,4 @@ fr:
47
46
  unlock_link_msg: "Cliquez sur le lien ci-dessous pour déverrouiller votre compte:"
48
47
  unlock_link: "Déverrouiller mon compte"
49
48
  hello: "bonjour"
50
- welcome: "bienvenue"
49
+ welcome: "bienvenue"
@@ -0,0 +1,46 @@
1
+ it:
2
+ devise_token_auth:
3
+ sessions:
4
+ not_confirmed: "Un'email di conferma è stata mandata al tuo account '%{email}'. Segui le istruzioni nell'email per attivare il tuo account."
5
+ bad_credentials: "Credenziali di login non valide. Riprova."
6
+ not_supported: "Usa POST /sign_in per eseguire il login. GET non è supportato."
7
+ user_not_found: "Utente non trovato o non autenticato."
8
+ token_validations:
9
+ invalid: "Credenziali di login non valide"
10
+ registrations:
11
+ missing_confirm_success_url: "Parametro 'confirm_success_url' mancante."
12
+ redirect_url_not_allowed: "Redirezione a '%{redirect_url}' non consentita."
13
+ email_already_exists: "Esiste già un account per '%{email}'"
14
+ account_with_uid_destroyed: "L'account con UID '%{uid}' è stato eliminato."
15
+ account_to_destroy_not_found: "Impossibile trovare l'account da eliminare."
16
+ user_not_found: "Utente non trovato."
17
+ passwords:
18
+ missing_email: "Devi fornire un indirizzo email."
19
+ missing_redirect_url: "Redirect URL mancante."
20
+ not_allowed_redirect_url: "Redirezione a '%{redirect_url}' non consentita."
21
+ sended: "E' stata inviata un'email a '%{email}' contenente le istruzioni per reimpostare la password."
22
+ user_not_found: "Impossibile trovare un utente con email '%{email}'."
23
+ password_not_required: "Questo account non richiede una password. Accedi utilizzando l'account di '%{provider}'."
24
+ missing_passwords: "Devi riempire i campi 'Password' e 'Password confirmation'."
25
+ successfully_updated: "La tua password è stata aggiornata correttamente."
26
+ errors:
27
+ messages:
28
+ validate_sign_up_params: "Dati di registrazione non validi."
29
+ validate_account_update_params: "Dati di aggiornamento dell'account non validi."
30
+ not_email: "non è un'email"
31
+ devise:
32
+ mailer:
33
+ confirmation_instructions:
34
+ confirm_link_msg: "Puoi confermare il tuo account email cliccando sul seguente link:"
35
+ confirm_account_link: "Conferma il mio account"
36
+ reset_password_instructions:
37
+ request_reset_link_msg: "Qualcuno ha richiesto un link per cambiare la tua password. Puoi farlo cliccando sul seguente link."
38
+ password_change_link: "Cambia la mia password"
39
+ ignore_mail_msg: "Se non hai richiesto questa operazione, puoi ignorare l'email."
40
+ no_changes_msg: "La tua password non cambierà finchè non cliccherai sul link sopra per crearne una nuova."
41
+ unlock_instructions:
42
+ account_lock_msg: "Il tuo account è stato bloccato a causa di un numero eccessivo di tentativi di accesso non validi."
43
+ unlock_link_msg: "Clicca sul seguente link per sbloccare il tuo account:"
44
+ unlock_link: "Sblocca il mio account"
45
+ hello: "ciao"
46
+ welcome: "benvenuto"
@@ -25,7 +25,6 @@ ja:
25
25
  successfully_updated: "パスワードの更新に成功しました。"
26
26
  errors:
27
27
  messages:
28
- already_in_use: "すでに利用されています。"
29
28
  validate_sign_up_params: "リクエストボディに適切なアカウント新規登録データを送信してください。"
30
29
  validate_account_update_params: "リクエストボディに適切なアカウント更新のデータを送信してください。"
31
30
  not_email: "はメールアドレスではありません"
@@ -25,7 +25,6 @@ nl:
25
25
  successfully_updated: "Uw wachtwoord is aangepast."
26
26
  errors:
27
27
  messages:
28
- already_in_use: "al in gebruik"
29
28
  validate_sign_up_params: "Gegevens voor aanmaken van het account zijn niet geldig."
30
29
  validate_account_update_params: "Gegevens voor updaten van het account zijn niet geldig."
31
30
  not_email: "is geen geldig e-emailadres"
@@ -27,8 +27,6 @@ pl:
27
27
  validate_sign_up_params: "Proszę dostarczyć odpowiednie dane logowania w ciele zapytania."
28
28
  validate_account_update_params: "Proszę dostarczyć odpowiednie dane aktualizacji konta w ciele zapytania."
29
29
  not_email: "nie jest prawidłowym adresem e-mail"
30
- messages:
31
- already_in_use: "już w użyciu"
32
30
  devise:
33
31
  mailer:
34
32
  confirmation_instructions:
@@ -47,4 +45,4 @@ pl:
47
45
  unlock_link_msg: "Kliknij poniższy link, aby odblokować konto :"
48
46
  unlock_link: "Odblokować konto"
49
47
  hello: "halo"
50
- welcome: "witam"
48
+ welcome: "witam"
@@ -25,7 +25,6 @@ pt-BR:
25
25
  successfully_updated: "Senha atualizada com sucesso."
26
26
  errors:
27
27
  messages:
28
- already_in_use: "em uso"
29
28
  validate_sign_up_params: "Os dados submetidos na requisição de cadastro são inválidos."
30
29
  validate_account_update_params: "Os dados submetidos para atualização de conta são inválidos."
31
30
  not_email: "não é um e-mail"
@@ -44,4 +43,4 @@ pt-BR:
44
43
  unlock_link_msg: "Clique no link abaixo para desbloquear sua conta:"
45
44
  unlock_link: "Desbloquear minha conta"
46
45
  hello: "olá"
47
- welcome: "bem-vindo"
46
+ welcome: "bem-vindo"
@@ -27,8 +27,6 @@ pt:
27
27
  validate_sign_up_params: "Os dados submetidos na requisição de registo são inválidos."
28
28
  validate_account_update_params: "Os dados submetidos para atualização de conta são inválidos."
29
29
  not_email: "não é um e-mail"
30
- messages:
31
- already_in_use: "em uso"
32
30
  devise:
33
31
  mailer:
34
32
  confirmation_instructions:
@@ -47,4 +45,4 @@ pt:
47
45
  unlock_link_msg: "Clique no link abaixo para desbloquear sua conta:"
48
46
  unlock_link: "Desbloquear minha conta"
49
47
  hello: "olá"
50
- welcome: "bem-vindo"
48
+ welcome: "bem-vindo"
@@ -0,0 +1,46 @@
1
+ ro:
2
+ devise_token_auth:
3
+ sessions:
4
+ not_confirmed: "Un email de confirmare a fost trimis către contul tău la '%{email}'. Pentru a-ți activa contul este necesar să urmezi instrucțiunile din acesta."
5
+ bad_credentials: "Datele introduse sunt incorecte. Te rugăm să incerci din nou."
6
+ not_supported: "Folosește functionalitatea POST /sign_in pentru a te autentifica. GET nu este suportat."
7
+ user_not_found: "Utilizatorul nu a fost găsit sau nu este logat în cont."
8
+ token_validations:
9
+ invalid: "Datele introduse pentru autentificare sunt invalide."
10
+ registrations:
11
+ missing_confirm_success_url: "Parametrul 'confirm_success_url' lipsește."
12
+ redirect_url_not_allowed: "Redirecționarea către '%{redirect_url}' nu este permisă."
13
+ email_already_exists: "Un cont cu email '%{email} deja există.'"
14
+ account_with_uid_destroyed: "Contul cu UID '%{uid}' a fost șters."
15
+ account_to_destroy_not_found: "Nu se poate localiza contul pentru ștergere."
16
+ user_not_found: "Utilizatorul nu a fost găsit."
17
+ passwords:
18
+ missing_email: "Trebuie să introduci o adresă de e-mail."
19
+ missing_redirect_url: "URL-ul pentru redirecționare lipsește."
20
+ not_allowed_redirect_url: "Redirecționarea către '%{redirect_url}' nu este permisă."
21
+ sended: "Un e-mail cu instrucțiuni pentru resetare a parolei a fost trimis către '%{email}'."
22
+ user_not_found: "Utilizatorul cu email-ul '%{email}' nu a fost găsit."
23
+ password_not_required: "Acest cont nu necesită parolă. Autentifică-te in schimb cu '%{provider}'."
24
+ missing_passwords: "Cămpurile 'Parolă' și 'Confirmare parolă' trebuiesc completate."
25
+ successfully_updated: "Parola contului a fost schimbată cu succes."
26
+ errors:
27
+ messages:
28
+ validate_sign_up_params: "Trimite credențiale valide în body-ul request-ului."
29
+ validate_account_update_params: "Trimite credențiale valide în body-ul request-ului."
30
+ not_email: "nu este un email"
31
+ devise:
32
+ mailer:
33
+ confirmation_instructions:
34
+ confirm_link_msg: "Poți confirma contul accesănd link-ul de mai jos:"
35
+ confirm_account_link: "Confirmă cont"
36
+ reset_password_instructions:
37
+ request_reset_link_msg: "Cineva a solicitat un link pentru schimbarea parolei contului tău. Poți face această schimbare accesând link-ul de mai jos."
38
+ password_change_link: "Schimbă parola"
39
+ ignore_mail_msg: "Dacă nu ai solicitat această schimbare ignoră acest e-mail."
40
+ no_changes_msg: "Parola ta nu se va schimba până când nu vei accesa link-ul de mai sus și vei crea o nouă parolă."
41
+ unlock_instructions:
42
+ account_lock_msg: "Contul tău a fost blocat din cauză că cineva a încercat accesarea lui de mai mult ori într-un timp foarte scurt."
43
+ unlock_link_msg: "Click pe acest link pentru a debloca contul:"
44
+ unlock_link: "Deblochează contul."
45
+ hello: "salut"
46
+ welcome: "bun venit"
@@ -24,11 +24,10 @@ ru:
24
24
  missing_passwords: "Вы должны заполнить поля 'пароль' и 'повторите пароль'."
25
25
  successfully_updated: "Ваш пароль успешно обновлён."
26
26
  errors:
27
- validate_sign_up_params: "Пожалуйста, укажите надлежащие данные для регистрации в теле запроса."
28
- validate_account_update_params: "Пожалуйста, укажите надлежащие данные для обновления учетной записи в теле запроса."
29
- not_email: "не является электронной почтой"
30
27
  messages:
31
- already_in_use: "уже используется"
28
+ validate_sign_up_params: "Пожалуйста, укажите надлежащие данные для регистрации в теле запроса."
29
+ validate_account_update_params: "Пожалуйста, укажите надлежащие данные для обновления учетной записи в теле запроса."
30
+ not_email: "не является электронной почтой"
32
31
  devise:
33
32
  mailer:
34
33
  confirmation_instructions:
@@ -25,7 +25,6 @@ zh-CN:
25
25
  successfully_updated: "您的密码已被修改。"
26
26
  errors:
27
27
  messages:
28
- already_in_use: "已被使用。"
29
28
  validate_sign_up_params: "请在request body中填入有效的注册内容"
30
29
  validate_account_update_params: "请在request body中填入有效的更新帐号资料"
31
30
  not_email: "这不是一个合适的邮箱。"
@@ -43,12 +42,5 @@ zh-CN:
43
42
  account_lock_msg: "由于多次登入失败,我们已锁定你的帐号"
44
43
  unlock_link_msg: "可以使用下面的链接解锁你的帐号"
45
44
  unlock_link: "解锁帐号"
46
- activerecord:
47
- errors:
48
- models:
49
- user:
50
- attributes:
51
- email:
52
- already_in_use: "邮箱已被使用"
53
45
  hello: "你好"
54
- welcome: "欢迎"
46
+ welcome: "欢迎"
@@ -27,7 +27,6 @@ zh-TW:
27
27
  successfully_updated: "您的密碼已被修改。"
28
28
  errors:
29
29
  messages:
30
- already_in_use: "已被使用。"
31
30
  validate_sign_up_params: "請在request body中填入有效的註冊內容"
32
31
  validate_account_update_params: "請在request body中填入有效的更新帳號資料"
33
32
  not_email: "這不是一個合適的電郵。"
@@ -27,7 +27,6 @@ zh-TW:
27
27
  successfully_updated: "您的密碼已被修改。"
28
28
  errors:
29
29
  messages:
30
- already_in_use: "已被使用。"
31
30
  validate_sign_up_params: "請在request body中填入有效的註冊內容"
32
31
  validate_account_update_params: "請在request body中填入有效的更新帳號資料"
33
32
  not_email: "這不是一個合適的電郵。"
@@ -12,6 +12,7 @@ module ActionDispatch::Routing
12
12
  confirmations_ctrl = opts[:controllers][:confirmations] || "devise_token_auth/confirmations"
13
13
  token_validations_ctrl = opts[:controllers][:token_validations] || "devise_token_auth/token_validations"
14
14
  omniauth_ctrl = opts[:controllers][:omniauth_callbacks] || "devise_token_auth/omniauth_callbacks"
15
+ unlocks_ctrl = opts[:controllers][:unlocks]
15
16
 
16
17
  # define devise controller mappings
17
18
  controllers = {:sessions => sessions_ctrl,
@@ -19,6 +20,8 @@ module ActionDispatch::Routing
19
20
  :passwords => passwords_ctrl,
20
21
  :confirmations => confirmations_ctrl}
21
22
 
23
+ controllers[:unlocks] = unlocks_ctrl if unlocks_ctrl
24
+
22
25
  # remove any unwanted devise modules
23
26
  opts[:skip].each{|item| controllers.delete(item)}
24
27
 
@@ -77,7 +80,7 @@ module ActionDispatch::Routing
77
80
 
78
81
  if DeviseTokenAuth.redirect_whitelist
79
82
  redirect_url = request.params['auth_origin_url']
80
- unless DeviseTokenAuth.redirect_whitelist.include?(redirect_url)
83
+ unless DeviseTokenAuth::Url.whitelisted?(redirect_url)
81
84
  message = I18n.t(
82
85
  'devise_token_auth.registrations.redirect_url_not_allowed',
83
86
  redirect_url: redirect_url
@@ -5,7 +5,7 @@ module DeviseTokenAuth::Url
5
5
 
6
6
  res = "#{uri.scheme}://#{uri.host}"
7
7
  res += ":#{uri.port}" if (uri.port and uri.port != 80 and uri.port != 443)
8
- res += "#{uri.path}" if uri.path
8
+ res += "#{uri.path}" if uri.path
9
9
  query = [uri.query, params.to_query].reject(&:blank?).join('&')
10
10
  res += "?#{query}"
11
11
  res += "##{uri.fragment}" if uri.fragment
@@ -13,4 +13,25 @@ module DeviseTokenAuth::Url
13
13
  return res
14
14
  end
15
15
 
16
+ def self.whitelisted?(url)
17
+ !!DeviseTokenAuth.redirect_whitelist.find { |pattern| !!Wildcat.new(pattern).match(url) }
18
+ end
19
+
20
+
21
+ # wildcard convenience class
22
+ class Wildcat
23
+ def self.parse_to_regex(str)
24
+ escaped = Regexp.escape(str).gsub('\*','.*?')
25
+ Regexp.new("^#{escaped}$", Regexp::IGNORECASE)
26
+ end
27
+
28
+ def initialize(str)
29
+ @regex = self.class.parse_to_regex(str)
30
+ end
31
+
32
+ def match(str)
33
+ !!@regex.match(str)
34
+ end
35
+ end
36
+
16
37
  end
@@ -1,3 +1,3 @@
1
1
  module DeviseTokenAuth
2
- VERSION = "0.1.39"
2
+ VERSION = "0.1.40"
3
3
  end
@@ -8,7 +8,7 @@ Arguments:
8
8
  # 'User'
9
9
  MOUNT_PATH # The path at which to mount the authentication routes. Default is
10
10
  # 'auth'. More detail documentation is here:
11
- # https://github.com/lynndylanhurley/devise_token_auth#usage
11
+ # https://github.com/lynndylanhurley/devise_token_auth#usage-tldr
12
12
 
13
13
  Example:
14
14
  rails generate devise_token_auth:install User auth
@@ -45,10 +45,10 @@ class DeviseTokenAuthCreate<%= user_class.pluralize %> < ActiveRecord::Migration
45
45
  t.timestamps
46
46
  end
47
47
 
48
- add_index :<%= user_class.pluralize.underscore %>, :email
49
- add_index :<%= user_class.pluralize.underscore %>, [:uid, :provider], :unique => true
50
- add_index :<%= user_class.pluralize.underscore %>, :reset_password_token, :unique => true
51
- # add_index :<%= user_class.pluralize.underscore %>, :confirmation_token, :unique => true
52
- # add_index :<%= user_class.pluralize.underscore %>, :unlock_token, :unique => true
48
+ add_index :<%= user_class.pluralize.underscore %>, :email, unique: true
49
+ add_index :<%= user_class.pluralize.underscore %>, [:uid, :provider], unique: true
50
+ add_index :<%= user_class.pluralize.underscore %>, :reset_password_token, unique: true
51
+ add_index :<%= user_class.pluralize.underscore %>, :confirmation_token, unique: true
52
+ # add_index :<%= user_class.pluralize.underscore %>, :unlock_token, unique: true
53
53
  end
54
54
  end
@@ -66,6 +66,11 @@ class OmniauthTest < ActionDispatch::IntegrationTest
66
66
  get_success
67
67
  end
68
68
 
69
+ test 'should be redirected via valid url' do
70
+ get_success
71
+ assert_equal 'http://www.example.com/auth/facebook/callback', request.original_url
72
+ end
73
+
69
74
  describe 'with default user model' do
70
75
  before do
71
76
  get_success
@@ -320,5 +325,17 @@ class OmniauthTest < ActionDispatch::IntegrationTest
320
325
  data = ActiveSupport::JSON.decode(data_json)
321
326
  assert_equal @user_email, data['email']
322
327
  end
328
+
329
+ test 'should support wildcards' do
330
+ DeviseTokenAuth.redirect_whitelist = ["#{@good_redirect_url[0..8]}*"]
331
+ get_via_redirect '/auth/facebook',
332
+ auth_origin_url: @good_redirect_url,
333
+ omniauth_window_type: 'newWindow'
334
+
335
+ data_json = @response.body.match(/var data \= (.+)\;/)[1]
336
+ data = ActiveSupport::JSON.decode(data_json)
337
+ assert_equal @user_email, data['email']
338
+ end
339
+
323
340
  end
324
341
  end
@@ -73,6 +73,21 @@ class DeviseTokenAuth::PasswordsControllerTest < ActionController::TestCase
73
73
  end
74
74
  end
75
75
 
76
+ describe 'successfully requested password reset' do
77
+ before do
78
+ xhr :post, :create, {
79
+ email: @resource.email,
80
+ redirect_url: @redirect_url
81
+ }
82
+
83
+ @data = JSON.parse(response.body)
84
+ end
85
+
86
+ test 'response should not contain extra data' do
87
+ assert_equal @data['data'], nil
88
+ end
89
+ end
90
+
76
91
 
77
92
  describe 'case-sensitive email' do
78
93
  before do
@@ -389,5 +389,94 @@ class DeviseTokenAuth::SessionsControllerTest < ActionController::TestCase
389
389
  refute OnlyEmailUser.method_defined?(:confirmed_at)
390
390
  end
391
391
  end
392
+
393
+ describe "Lockable User" do
394
+ setup do
395
+ @request.env['devise.mapping'] = Devise.mappings[:lockable_user]
396
+ end
397
+
398
+ teardown do
399
+ @request.env['devise.mapping'] = Devise.mappings[:user]
400
+ end
401
+
402
+ before do
403
+ @original_lock_strategy = Devise.lock_strategy
404
+ @original_unlock_strategy = Devise.unlock_strategy
405
+ @original_maximum_attempts = Devise.maximum_attempts
406
+ Devise.lock_strategy = :failed_attempts
407
+ Devise.unlock_strategy = :email
408
+ Devise.maximum_attempts = 5
409
+ end
410
+
411
+ after do
412
+ Devise.lock_strategy = @original_lock_strategy
413
+ Devise.maximum_attempts = @original_maximum_attempts
414
+ Devise.unlock_strategy = @original_unlock_strategy
415
+ end
416
+
417
+ describe "locked user" do
418
+ before do
419
+ @locked_user = lockable_users(:locked_user)
420
+ xhr :post, :create, {
421
+ email: @locked_user.email,
422
+ password: 'secret123'
423
+ }
424
+ @data = JSON.parse(response.body)
425
+ end
426
+
427
+ test "request should fail" do
428
+ assert_equal 401, response.status
429
+ end
430
+
431
+ test "response should contain errors" do
432
+ assert @data['errors']
433
+ assert_equal @data['errors'], [I18n.t("devise_token_auth.sessions.not_confirmed", email: @locked_user.email)]
434
+ end
435
+ end
436
+
437
+ describe "unlocked user with bad password" do
438
+ before do
439
+ @unlocked_user = lockable_users(:unlocked_user)
440
+ xhr :post, :create, {
441
+ email: @unlocked_user.email,
442
+ password: 'bad-password'
443
+ }
444
+ @data = JSON.parse(response.body)
445
+ end
446
+
447
+ test "request should fail" do
448
+ assert_equal 401, response.status
449
+ end
450
+
451
+ test "should increase failed_attempts" do
452
+ assert_equal 1, @unlocked_user.reload.failed_attempts
453
+ end
454
+
455
+ test "response should contain errors" do
456
+ assert @data['errors']
457
+ assert_equal @data['errors'], [I18n.t("devise_token_auth.sessions.bad_credentials")]
458
+ end
459
+
460
+ describe 'after maximum_attempts should block the user' do
461
+ before do
462
+ 4.times do
463
+ xhr :post, :create, {
464
+ email: @unlocked_user.email,
465
+ password: 'bad-password'
466
+ }
467
+ end
468
+ @data = JSON.parse(response.body)
469
+ end
470
+
471
+ test "should increase failed_attempts" do
472
+ assert_equal 5, @unlocked_user.reload.failed_attempts
473
+ end
474
+
475
+ test "should block the user" do
476
+ assert_equal true, @unlocked_user.reload.access_locked?
477
+ end
478
+ end
479
+ end
480
+ end
392
481
  end
393
482
  end
@@ -0,0 +1,5 @@
1
+ class LockableUser < ActiveRecord::Base
2
+ # Include default devise modules.
3
+ devise :database_authenticatable, :registerable, :lockable
4
+ include DeviseTokenAuth::Concerns::User
5
+ end
@@ -34,6 +34,8 @@ Rails.application.routes.draw do
34
34
 
35
35
  mount_devise_token_auth_for 'UnconfirmableUser', at: 'unconfirmable_user_auth'
36
36
 
37
+ mount_devise_token_auth_for 'LockableUser', at: 'lockable_user_auth'
38
+
37
39
  # test namespacing
38
40
  namespace :api do
39
41
  scope :v1 do
@@ -0,0 +1,60 @@
1
+ include MigrationDatabaseHelper
2
+
3
+ class DeviseTokenAuthCreateLockableUsers < ActiveRecord::Migration
4
+ def change
5
+ create_table(:lockable_users) do |t|
6
+ ## Required
7
+ t.string :provider, :null => false
8
+ t.string :uid, :null => false, :default => ""
9
+
10
+ ## Database authenticatable
11
+ t.string :encrypted_password, :null => false, :default => ""
12
+
13
+ ## Recoverable
14
+ # t.string :reset_password_token
15
+ # t.datetime :reset_password_sent_at
16
+
17
+ ## Rememberable
18
+ # t.datetime :remember_created_at
19
+
20
+ ## Trackable
21
+ # t.integer :sign_in_count, :default => 0, :null => false
22
+ # t.datetime :current_sign_in_at
23
+ # t.datetime :last_sign_in_at
24
+ # t.string :current_sign_in_ip
25
+ # t.string :last_sign_in_ip
26
+
27
+ ## Confirmable
28
+ # t.string :confirmation_token
29
+ # t.datetime :confirmed_at
30
+ # t.datetime :confirmation_sent_at
31
+ # t.string :unconfirmed_email # Only if using reconfirmable
32
+
33
+ ## Lockable
34
+ t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
35
+ t.string :unlock_token # Only if unlock strategy is :email or :both
36
+ t.datetime :locked_at
37
+
38
+ ## User Info
39
+ t.string :name
40
+ t.string :nickname
41
+ t.string :image
42
+ t.string :email
43
+
44
+ ## Tokens
45
+ if json_supported_database?
46
+ t.json :tokens
47
+ else
48
+ t.text :tokens
49
+ end
50
+
51
+ t.timestamps
52
+ end
53
+
54
+ add_index :lockable_users, :email
55
+ add_index :lockable_users, [:uid, :provider], :unique => true
56
+ # add_index :lockable_users, :reset_password_token, :unique => true
57
+ # add_index :lockable_users, :confirmation_token, :unique => true
58
+ add_index :lockable_users, :unlock_token, :unique => true
59
+ end
60
+ end
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20160103235141) do
14
+ ActiveRecord::Schema.define(version: 20160629184441) do
15
15
 
16
16
  create_table "evil_users", force: :cascade do |t|
17
17
  t.string "email"
@@ -44,6 +44,26 @@ ActiveRecord::Schema.define(version: 20160103235141) do
44
44
  add_index "evil_users", ["reset_password_token"], name: "index_evil_users_on_reset_password_token", unique: true
45
45
  add_index "evil_users", ["uid", "provider"], name: "index_evil_users_on_uid_and_provider", unique: true
46
46
 
47
+ create_table "lockable_users", force: :cascade do |t|
48
+ t.string "provider", null: false
49
+ t.string "uid", default: "", null: false
50
+ t.string "encrypted_password", default: "", null: false
51
+ t.integer "failed_attempts", default: 0, null: false
52
+ t.string "unlock_token"
53
+ t.datetime "locked_at"
54
+ t.string "name"
55
+ t.string "nickname"
56
+ t.string "image"
57
+ t.string "email"
58
+ t.text "tokens"
59
+ t.datetime "created_at"
60
+ t.datetime "updated_at"
61
+ end
62
+
63
+ add_index "lockable_users", ["email"], name: "index_lockable_users_on_email"
64
+ add_index "lockable_users", ["uid", "provider"], name: "index_lockable_users_on_uid_and_provider", unique: true
65
+ add_index "lockable_users", ["unlock_token"], name: "index_lockable_users_on_unlock_token", unique: true
66
+
47
67
  create_table "mangs", force: :cascade do |t|
48
68
  t.string "email"
49
69
  t.string "encrypted_password", default: "", null: false
@@ -35,6 +35,28 @@ class UserTest < ActiveSupport::TestCase
35
35
  end
36
36
  end
37
37
 
38
+ describe 'email uniqueness' do
39
+ test 'model should not save if email is taken' do
40
+ provider = 'email'
41
+
42
+ User.create(
43
+ email: @email,
44
+ provider: provider,
45
+ password: @password,
46
+ password_confirmation: @password
47
+ )
48
+
49
+ @resource.email = @email
50
+ @resource.provider = provider
51
+ @resource.password = @password
52
+ @resource.password_confirmation = @password
53
+
54
+ refute @resource.save
55
+ assert @resource.errors.messages[:email] == [I18n.t('errors.messages.taken')]
56
+ assert @resource.errors.messages[:email].none? { |e| e =~ /translation missing/ }
57
+ end
58
+ end
59
+
38
60
  describe 'oauth2 authentication' do
39
61
  test 'model should save even if email is blank' do
40
62
  @resource.provider = 'facebook'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_token_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.39
4
+ version: 0.1.40
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lynn Hurley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-16 00:00:00.000000000 Z
11
+ date: 2017-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -116,11 +116,13 @@ files:
116
116
  - config/locales/en.yml
117
117
  - config/locales/es.yml
118
118
  - config/locales/fr.yml
119
+ - config/locales/it.yml
119
120
  - config/locales/ja.yml
120
121
  - config/locales/nl.yml
121
122
  - config/locales/pl.yml
122
123
  - config/locales/pt-BR.yml
123
124
  - config/locales/pt.yml
125
+ - config/locales/ro.yml
124
126
  - config/locales/ru.yml
125
127
  - config/locales/zh-CN.yml
126
128
  - config/locales/zh-HK.yml
@@ -180,6 +182,7 @@ files:
180
182
  - test/dummy/app/controllers/overrides/token_validations_controller.rb
181
183
  - test/dummy/app/helpers/application_helper.rb
182
184
  - test/dummy/app/models/evil_user.rb
185
+ - test/dummy/app/models/lockable_user.rb
183
186
  - test/dummy/app/models/mang.rb
184
187
  - test/dummy/app/models/nice_user.rb
185
188
  - test/dummy/app/models/only_email_user.rb
@@ -220,6 +223,7 @@ files:
220
223
  - test/dummy/db/migrate/20150409095712_devise_token_auth_create_nice_users.rb
221
224
  - test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb
222
225
  - test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb
226
+ - test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb
223
227
  - test/dummy/db/schema.rb
224
228
  - test/dummy/lib/migration_database_helper.rb
225
229
  - test/dummy/tmp/generators/app/views/devise/mailer/confirmation_instructions.html.erb
@@ -296,6 +300,7 @@ test_files:
296
300
  - test/dummy/app/controllers/overrides/token_validations_controller.rb
297
301
  - test/dummy/app/helpers/application_helper.rb
298
302
  - test/dummy/app/models/evil_user.rb
303
+ - test/dummy/app/models/lockable_user.rb
299
304
  - test/dummy/app/models/mang.rb
300
305
  - test/dummy/app/models/nice_user.rb
301
306
  - test/dummy/app/models/only_email_user.rb
@@ -336,6 +341,7 @@ test_files:
336
341
  - test/dummy/db/migrate/20150409095712_devise_token_auth_create_nice_users.rb
337
342
  - test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb
338
343
  - test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb
344
+ - test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb
339
345
  - test/dummy/db/schema.rb
340
346
  - test/dummy/lib/migration_database_helper.rb
341
347
  - test/dummy/README.rdoc