sidecar_token_auth 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +13 -0
  3. data/README.md +12 -0
  4. data/Rakefile +42 -0
  5. data/app/controllers/devise_token_auth/application_controller.rb +79 -0
  6. data/app/controllers/devise_token_auth/concerns/resource_finder.rb +44 -0
  7. data/app/controllers/devise_token_auth/concerns/set_user_by_token.rb +162 -0
  8. data/app/controllers/devise_token_auth/confirmations_controller.rb +90 -0
  9. data/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +287 -0
  10. data/app/controllers/devise_token_auth/passwords_controller.rb +206 -0
  11. data/app/controllers/devise_token_auth/registrations_controller.rb +283 -0
  12. data/app/controllers/devise_token_auth/sessions_controller.rb +245 -0
  13. data/app/controllers/devise_token_auth/token_validations_controller.rb +31 -0
  14. data/app/controllers/devise_token_auth/unlocks_controller.rb +89 -0
  15. data/app/models/devise_token_auth/concerns/active_record_support.rb +16 -0
  16. data/app/models/devise_token_auth/concerns/confirmable_support.rb +28 -0
  17. data/app/models/devise_token_auth/concerns/mongoid_support.rb +19 -0
  18. data/app/models/devise_token_auth/concerns/tokens_serialization.rb +19 -0
  19. data/app/models/devise_token_auth/concerns/user.rb +257 -0
  20. data/app/models/devise_token_auth/concerns/user_omniauth_callbacks.rb +31 -0
  21. data/app/validators/devise_token_auth_email_validator.rb +23 -0
  22. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  23. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  24. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  25. data/app/views/devise_token_auth/omniauth_external_window.html.erb +38 -0
  26. data/config/locales/da-DK.yml +52 -0
  27. data/config/locales/de.yml +51 -0
  28. data/config/locales/en.yml +60 -0
  29. data/config/locales/es.yml +51 -0
  30. data/config/locales/fr.yml +51 -0
  31. data/config/locales/he.yml +52 -0
  32. data/config/locales/it.yml +48 -0
  33. data/config/locales/ja.yml +48 -0
  34. data/config/locales/ko.yml +51 -0
  35. data/config/locales/nl.yml +32 -0
  36. data/config/locales/pl.yml +51 -0
  37. data/config/locales/pt-BR.yml +48 -0
  38. data/config/locales/pt.yml +51 -0
  39. data/config/locales/ro.yml +48 -0
  40. data/config/locales/ru.yml +52 -0
  41. data/config/locales/sq.yml +48 -0
  42. data/config/locales/sv.yml +52 -0
  43. data/config/locales/uk.yml +61 -0
  44. data/config/locales/vi.yml +52 -0
  45. data/config/locales/zh-CN.yml +48 -0
  46. data/config/locales/zh-HK.yml +50 -0
  47. data/config/locales/zh-TW.yml +50 -0
  48. data/lib/devise_token_auth.rb +14 -0
  49. data/lib/devise_token_auth/blacklist.rb +2 -0
  50. data/lib/devise_token_auth/controllers/helpers.rb +157 -0
  51. data/lib/devise_token_auth/controllers/url_helpers.rb +10 -0
  52. data/lib/devise_token_auth/engine.rb +96 -0
  53. data/lib/devise_token_auth/errors.rb +8 -0
  54. data/lib/devise_token_auth/rails/routes.rb +116 -0
  55. data/lib/devise_token_auth/token_factory.rb +126 -0
  56. data/lib/devise_token_auth/url.rb +44 -0
  57. data/lib/devise_token_auth/version.rb +5 -0
  58. data/lib/generators/devise_token_auth/USAGE +31 -0
  59. data/lib/generators/devise_token_auth/install_generator.rb +91 -0
  60. data/lib/generators/devise_token_auth/install_generator_helpers.rb +98 -0
  61. data/lib/generators/devise_token_auth/install_mongoid_generator.rb +46 -0
  62. data/lib/generators/devise_token_auth/install_views_generator.rb +18 -0
  63. data/lib/generators/devise_token_auth/templates/devise_token_auth.rb +60 -0
  64. data/lib/generators/devise_token_auth/templates/devise_token_auth_create_users.rb.erb +49 -0
  65. data/lib/generators/devise_token_auth/templates/user.rb.erb +9 -0
  66. data/lib/generators/devise_token_auth/templates/user_mongoid.rb.erb +56 -0
  67. data/lib/tasks/devise_token_auth_tasks.rake +6 -0
  68. data/test/controllers/custom/custom_confirmations_controller_test.rb +25 -0
  69. data/test/controllers/custom/custom_omniauth_callbacks_controller_test.rb +33 -0
  70. data/test/controllers/custom/custom_passwords_controller_test.rb +79 -0
  71. data/test/controllers/custom/custom_registrations_controller_test.rb +63 -0
  72. data/test/controllers/custom/custom_sessions_controller_test.rb +39 -0
  73. data/test/controllers/custom/custom_token_validations_controller_test.rb +42 -0
  74. data/test/controllers/demo_group_controller_test.rb +151 -0
  75. data/test/controllers/demo_mang_controller_test.rb +284 -0
  76. data/test/controllers/demo_user_controller_test.rb +629 -0
  77. data/test/controllers/devise_token_auth/confirmations_controller_test.rb +191 -0
  78. data/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb +441 -0
  79. data/test/controllers/devise_token_auth/passwords_controller_test.rb +780 -0
  80. data/test/controllers/devise_token_auth/registrations_controller_test.rb +907 -0
  81. data/test/controllers/devise_token_auth/sessions_controller_test.rb +503 -0
  82. data/test/controllers/devise_token_auth/token_validations_controller_test.rb +102 -0
  83. data/test/controllers/devise_token_auth/unlocks_controller_test.rb +196 -0
  84. data/test/controllers/overrides/confirmations_controller_test.rb +47 -0
  85. data/test/controllers/overrides/omniauth_callbacks_controller_test.rb +53 -0
  86. data/test/controllers/overrides/passwords_controller_test.rb +64 -0
  87. data/test/controllers/overrides/registrations_controller_test.rb +46 -0
  88. data/test/controllers/overrides/sessions_controller_test.rb +35 -0
  89. data/test/controllers/overrides/token_validations_controller_test.rb +43 -0
  90. data/test/dummy/README.rdoc +28 -0
  91. data/test/dummy/app/active_record/confirmable_user.rb +11 -0
  92. data/test/dummy/app/active_record/lockable_user.rb +7 -0
  93. data/test/dummy/app/active_record/mang.rb +5 -0
  94. data/test/dummy/app/active_record/only_email_user.rb +7 -0
  95. data/test/dummy/app/active_record/scoped_user.rb +9 -0
  96. data/test/dummy/app/active_record/unconfirmable_user.rb +9 -0
  97. data/test/dummy/app/active_record/unregisterable_user.rb +9 -0
  98. data/test/dummy/app/active_record/user.rb +6 -0
  99. data/test/dummy/app/controllers/application_controller.rb +18 -0
  100. data/test/dummy/app/controllers/auth_origin_controller.rb +7 -0
  101. data/test/dummy/app/controllers/custom/confirmations_controller.rb +13 -0
  102. data/test/dummy/app/controllers/custom/omniauth_callbacks_controller.rb +13 -0
  103. data/test/dummy/app/controllers/custom/passwords_controller.rb +39 -0
  104. data/test/dummy/app/controllers/custom/registrations_controller.rb +39 -0
  105. data/test/dummy/app/controllers/custom/sessions_controller.rb +29 -0
  106. data/test/dummy/app/controllers/custom/token_validations_controller.rb +19 -0
  107. data/test/dummy/app/controllers/demo_group_controller.rb +15 -0
  108. data/test/dummy/app/controllers/demo_mang_controller.rb +14 -0
  109. data/test/dummy/app/controllers/demo_user_controller.rb +27 -0
  110. data/test/dummy/app/controllers/overrides/confirmations_controller.rb +28 -0
  111. data/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb +16 -0
  112. data/test/dummy/app/controllers/overrides/passwords_controller.rb +35 -0
  113. data/test/dummy/app/controllers/overrides/registrations_controller.rb +29 -0
  114. data/test/dummy/app/controllers/overrides/sessions_controller.rb +36 -0
  115. data/test/dummy/app/controllers/overrides/token_validations_controller.rb +23 -0
  116. data/test/dummy/app/helpers/application_helper.rb +1058 -0
  117. data/test/dummy/app/models/concerns/favorite_color.rb +19 -0
  118. data/test/dummy/app/mongoid/confirmable_user.rb +52 -0
  119. data/test/dummy/app/mongoid/lockable_user.rb +38 -0
  120. data/test/dummy/app/mongoid/mang.rb +46 -0
  121. data/test/dummy/app/mongoid/only_email_user.rb +33 -0
  122. data/test/dummy/app/mongoid/scoped_user.rb +50 -0
  123. data/test/dummy/app/mongoid/unconfirmable_user.rb +44 -0
  124. data/test/dummy/app/mongoid/unregisterable_user.rb +47 -0
  125. data/test/dummy/app/mongoid/user.rb +49 -0
  126. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  127. data/test/dummy/config.ru +18 -0
  128. data/test/dummy/config/application.rb +48 -0
  129. data/test/dummy/config/application.yml.bk +0 -0
  130. data/test/dummy/config/boot.rb +11 -0
  131. data/test/dummy/config/environment.rb +7 -0
  132. data/test/dummy/config/environments/development.rb +46 -0
  133. data/test/dummy/config/environments/production.rb +84 -0
  134. data/test/dummy/config/environments/test.rb +50 -0
  135. data/test/dummy/config/initializers/assets.rb +10 -0
  136. data/test/dummy/config/initializers/backtrace_silencers.rb +9 -0
  137. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  138. data/test/dummy/config/initializers/devise.rb +290 -0
  139. data/test/dummy/config/initializers/devise_token_auth.rb +55 -0
  140. data/test/dummy/config/initializers/figaro.rb +3 -0
  141. data/test/dummy/config/initializers/filter_parameter_logging.rb +6 -0
  142. data/test/dummy/config/initializers/inflections.rb +18 -0
  143. data/test/dummy/config/initializers/mime_types.rb +6 -0
  144. data/test/dummy/config/initializers/omniauth.rb +11 -0
  145. data/test/dummy/config/initializers/session_store.rb +5 -0
  146. data/test/dummy/config/initializers/wrap_parameters.rb +16 -0
  147. data/test/dummy/config/routes.rb +57 -0
  148. data/test/dummy/config/spring.rb +3 -0
  149. data/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb +58 -0
  150. data/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb +57 -0
  151. data/test/dummy/db/migrate/20140829044006_add_operating_thetan_to_user.rb +8 -0
  152. data/test/dummy/db/migrate/20140916224624_add_favorite_color_to_mangs.rb +7 -0
  153. data/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb +55 -0
  154. data/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb +56 -0
  155. data/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb +56 -0
  156. data/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb +56 -0
  157. data/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb +56 -0
  158. data/test/dummy/db/migrate/20190924101113_devise_token_auth_create_confirmable_users.rb +49 -0
  159. data/test/dummy/db/schema.rb +198 -0
  160. data/test/dummy/lib/migration_database_helper.rb +43 -0
  161. data/test/factories/users.rb +41 -0
  162. data/test/lib/devise_token_auth/blacklist_test.rb +11 -0
  163. data/test/lib/devise_token_auth/token_factory_test.rb +191 -0
  164. data/test/lib/devise_token_auth/url_test.rb +26 -0
  165. data/test/lib/generators/devise_token_auth/install_generator_test.rb +217 -0
  166. data/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb +222 -0
  167. data/test/lib/generators/devise_token_auth/install_views_generator_test.rb +25 -0
  168. data/test/models/concerns/mongoid_support_test.rb +31 -0
  169. data/test/models/concerns/tokens_serialization_test.rb +70 -0
  170. data/test/models/confirmable_user_test.rb +35 -0
  171. data/test/models/only_email_user_test.rb +29 -0
  172. data/test/models/user_test.rb +108 -0
  173. data/test/support/controllers/routes.rb +43 -0
  174. data/test/test_helper.rb +103 -0
  175. metadata +481 -0
@@ -0,0 +1,61 @@
1
+ uk:
2
+ devise_token_auth:
3
+ sessions:
4
+ not_confirmed: "Будь ласка підтвердіть реєстрацію згідно інструкціям як ми вислали на Вашу пошту %{email}"
5
+ bad_credentials: "Логін або пароль введені невірно. Будь ласка, спробуйте ще"
6
+ not_supported: "Використовуйте POST /sign_in для входу. GET запити не пітримуються."
7
+ user_not_found: "Користувач не знайдений або не увійшов в систему"
8
+ token_validations:
9
+ invalid: "Помилкові дані"
10
+ registrations:
11
+ missing_confirm_success_url: "Немає параметру 'confirm_success_url'"
12
+ redirect_url_not_allowed: "Перенаправлення до '%{redirect_url}' не дозволено."
13
+ email_already_exists: "Акаунт для емейлу '%{email}' вже існує"
14
+ account_with_uid_destroyed: "Акаунт з UID '%{uid}' було видалено."
15
+ account_to_destroy_not_found: "Неможливо знайти акаунт для видалення."
16
+ user_not_found: "Користувача не знайдено"
17
+ omniauth:
18
+ not_allowed_redirect_url: "Перенаправлення до '%{redirect_url}' не дозволено."
19
+ passwords:
20
+ missing_email: "Ви маєте ввести email адресу."
21
+ missing_redirect_url: "Немає URL для перенаправлення."
22
+ not_allowed_redirect_url: "Перенаправлення до '%{redirect_url}' не дозволено."
23
+ sended: "Лист з інструкціями для скидання паролю відправлено на '%{email}'."
24
+ user_not_found: "Неможливо знайти користувача по email '%{email}'."
25
+ password_not_required: "Цей акаунт не потребує паролю. Увійдіть використовуючи натомість акаунт провайдера '%{provider}'."
26
+ missing_passwords: "Ви маєте заповнити поля з назвами 'Пароль' та 'Підтвердження паролю'."
27
+ successfully_updated: "Ваш пароль було успішно оновлено."
28
+ unlocks:
29
+ missing_email: "Ви маєте вказати адресу електронної пошти."
30
+ missing_redirect_url: "Відсутня адреса переадресації."
31
+ not_allowed_redirect_url: "Переадресація до %{redirect_url} не дозволена."
32
+ sended: "Інструкція по відновленню паролю відправлена на Вашу електронну адресу."
33
+ user_not_found: "Не виходить знайти користувача з електронною адресою %{email}."
34
+ password_not_required: "Цей обліковий запис не потребує паролю. Увійдіть використовуючи обліковий запис '%{provider}'."
35
+ missing_passwords: "Ви маєте заповнити поля 'пароль' і 'підтвердіть пароль'."
36
+ successfully_updated: "Ваш пароль успішно оновлено."
37
+ errors:
38
+ messages:
39
+ validate_sign_up_params: "Будь ласка, відправте вірні дані для реєстрації в тілі запиту."
40
+ validate_account_update_params: "Будь ласка, відправте вірні дані для оновлення акаунту в тілі запиту."
41
+ not_email: "не є електронною адресою"
42
+ devise:
43
+ mailer:
44
+ confirmation_instructions:
45
+ subject: "Інструкції підтвердження"
46
+ confirm_link_msg: "Ви можете підтвердити вашу адресу електронної пошти через посилання нижче:"
47
+ confirm_account_link: "Підтвердіть свій обліковий запис"
48
+ reset_password_instructions:
49
+ subject: "Інструкція по скиданню паролю"
50
+ request_reset_link_msg: "Хтось зробив запит на зміну паролю. Ви можете зробити це через посилання нижче."
51
+ password_change_link: "Змінити пароль"
52
+ ignore_mail_msg: "Якщо Ви не робили запит на це, Ви можете проігнорувати цей лист."
53
+ no_changes_msg: "Ваш пароль не зміниться, доки Ви не відкриєте посилання вище і не створите новий пароль."
54
+ unlock_instructions:
55
+ subject: "Інструкції з розблокування"
56
+ account_lock_msg: "Ваш акаунт було заблоковано через надмірну кількість невдалих спроб входу."
57
+ unlock_link_msg: "Перейдіть за посиланням нижче, щоб розблокувати свій акаунт:"
58
+ unlock_link: "Розблокувати мій обліковий запис"
59
+ hello: "привіт"
60
+ welcome: "вітаємо"
61
+
@@ -0,0 +1,52 @@
1
+ vi:
2
+ devise_token_auth:
3
+ sessions:
4
+ not_confirmed: "Mail xác nhận tài khoản đã được gửi tới tài khoản của bạn tại '%{email}'. Bận cần phải làm theo những hướng dẫn trong email để tài khoản có thể xác nhận"
5
+ bad_credentials: "Thông tin đăng nhập không hợp lệ. Xin thử lại."
6
+ not_supported: "Sử dụng POST /sign_in để đăng nhập. Phương thức GET không được hỗ trợ."
7
+ user_not_found: "Người dùng đã không được tìm thấy hoặc không đăng nhập."
8
+ token_validations:
9
+ invalid: "Thông tin đăng nhập không hợp lệ."
10
+ registrations:
11
+ missing_confirm_success_url: "Thiếu 'confirm_success_url' tham số."
12
+ redirect_url_not_allowed: "Chuyển hướng tới '%{redirect_url}' không được phép."
13
+ email_already_exists: "Tài khoản đã tồn tại của '%{email}'"
14
+ account_with_uid_destroyed: "Tài khoản với UID '%{uid}' vừa bị phá hủy."
15
+ account_to_destroy_not_found: "Không thể xác định tài khoản cho việc phá hủy."
16
+ user_not_found: "Người dùng không tìm thấy."
17
+ omniauth:
18
+ not_allowed_redirect_url: "Chuyển hướng tới '%{redirect_url}' không được phép."
19
+ passwords:
20
+ missing_email: "Bạn cần cung cấp địa chỉ email."
21
+ missing_redirect_url: "Thiếu đường đẫn URL."
22
+ not_allowed_redirect_url: "Chuyển hướng tới '%{redirect_url}' không được phép."
23
+ sended: "Mail đã được gửi tới '%{email}' tiếp tục làm theo những hướng dẫn để khởi tạo lại mật khẩu."
24
+ user_not_found: "Không thể tìm ra người dùng với email '%{email}'."
25
+ password_not_required: "Tài khoản này không yêu cầu mật khẩu. Thay thế đăng nhập bằng cách sử dụng '%{provider}' của tài khoản ."
26
+ missing_passwords: "Bạn cần điền đủ những trường như 'mật khẩu' và 'xác nhận mật khẩu'."
27
+ successfully_updated: "Mật khẩu của bạn vừa được cập nhật thành công."
28
+ unlocks:
29
+ missing_email: "Bạn cần phải cung cấp địa chỉ email."
30
+ sended: "Mail đã được gửi tới '%{email}' tiếp tục làm theo những hướng đẫn để mở khóa tài khoản."
31
+ user_not_found: "Không thể tìm ra người dùng với email '%{email}'."
32
+ errors:
33
+ messages:
34
+ validate_sign_up_params: "Vui lòng gửi đúng dữ liệu đăng ký trong phần dữ liệu gửi lên."
35
+ validate_account_update_params: "Vui lòng gửi đúng dữ liệu cập nhật tài khoản trong phần dữ liệu gửi lên ."
36
+ not_email: "không phải là email"
37
+ devise:
38
+ mailer:
39
+ confirmation_instructions:
40
+ confirm_link_msg: "Bạn có thể xác nhận tài khoản email bằng đường link dưới đây:"
41
+ confirm_account_link: "Xác nhận tài khoản"
42
+ reset_password_instructions:
43
+ request_reset_link_msg: "Ai đó đã gửi yêu cầu để đổi mật khẩu của bạn. Bạn có thể thực hiện điều này thông qua đường dẫn bên dưới."
44
+ password_change_link: "Đổi mật khẩu của tôi"
45
+ ignore_mail_msg: "Nếu bạn đã không gửi yêu cầu này, thì vui lòng bỏ qua email này."
46
+ no_changes_msg: "Mật khẩu của bạn sẽ không thay đổi cho đến khi bạn truy cập liên kết ở trên và tạo một mật khẩu mới."
47
+ unlock_instructions:
48
+ account_lock_msg: "Tài khoản của bạn đã bị khóa do có quá nhiều lần đăng nhập không thành công."
49
+ unlock_link_msg: "Chọn vào đường dẫn bên dưới để mở khóa tài khoản:"
50
+ unlock_link: "Mở khóa tài khoản"
51
+ hello: "xin chào"
52
+ welcome: "chào mừng"
@@ -0,0 +1,48 @@
1
+ zh-CN:
2
+ devise_token_auth:
3
+ sessions:
4
+ not_confirmed: "您将在几分钟后收到一封电子邮件'%{email}',内有验证账号的步骤说明"
5
+ bad_credentials: "不正确的登录信息,请重试"
6
+ not_supported: "请使用 POST /sign_in 进行登录. GET 是不支持的."
7
+ user_not_found: "没有找到账号或没有成功登录"
8
+ token_validations:
9
+ invalid: "不正确的登录资料"
10
+ registrations:
11
+ missing_confirm_success_url: "缺少数据 'confirm_success_url'"
12
+ redirect_url_not_allowed: "不支持转向到 '%{redirect_url}'"
13
+ email_already_exists: "邮箱'%{email}'已被使用"
14
+ account_with_uid_destroyed: "账号 '%{uid}' 已被移除。"
15
+ account_to_destroy_not_found: "无法找到目标帐号。"
16
+ user_not_found: "找不到帐号。"
17
+ omniauth:
18
+ not_allowed_redirect_url: "不支持转向到 '%{redirect_url}'"
19
+ passwords:
20
+ missing_email: "必需提供邮箱。"
21
+ missing_redirect_url: "欠缺 redirect URL."
22
+ not_allowed_redirect_url: "不支持转向到 '%{redirect_url}'"
23
+ sended: "您将在几分钟后收到一封电子邮件'%{email},内含可重新设定密码的链接。"
24
+ user_not_found: "找不到帐号 '%{email}'。"
25
+ password_not_required: "这不是一个需要密码的帐号. 请使用 '%{provider}' 进行登入"
26
+ missing_passwords: "必需填写'密码'与'确认密码'。"
27
+ successfully_updated: "您的密码已被修改。"
28
+ errors:
29
+ messages:
30
+ validate_sign_up_params: "请在request body中填入有效的注册内容"
31
+ validate_account_update_params: "请在request body中填入有效的更新帐号资料"
32
+ not_email: "这不是一个合适的邮箱。"
33
+ devise:
34
+ mailer:
35
+ confirmation_instructions:
36
+ confirm_link_msg: "可以使用下面的链接确定你的邮箱"
37
+ confirm_account_link: "确定你的帐号"
38
+ reset_password_instructions:
39
+ request_reset_link_msg: "已申请修改您的密码,你可以用下面的链接进入"
40
+ password_change_link: "修改我的密码"
41
+ ignore_mail_msg: "如你没有申请,请忽略"
42
+ no_changes_msg: "在你点击上面链接前,你的密码都没有改变"
43
+ unlock_instructions:
44
+ account_lock_msg: "由于多次登入失败,我们已锁定你的帐号"
45
+ unlock_link_msg: "可以使用下面的链接解锁你的帐号"
46
+ unlock_link: "解锁帐号"
47
+ hello: "你好"
48
+ welcome: "欢迎"
@@ -0,0 +1,50 @@
1
+ # Additional translations at https://github.com/plataformatec/devise/wiki/I18n
2
+
3
+ zh-TW:
4
+ devise_token_auth:
5
+ sessions:
6
+ not_confirmed: "您將在幾分鐘後收到一封電子郵件'%{email}',內有驗證帳號的步驟說明。"
7
+ bad_credentials: "不正確的登入資料。請重試。"
8
+ not_supported: "請使用 POST /sign_in 進行登入. GET 是不支援的."
9
+ user_not_found: "未能找到帳號或未能成功登入。"
10
+ token_validations:
11
+ invalid: "不正確的登入資料。"
12
+ registrations:
13
+ missing_confirm_success_url: "欠缺數值 'confirm_success_url'"
14
+ redirect_url_not_allowed: "不支援轉向到'%{redirect_url}'"
15
+ email_already_exists: "電郵'%{email}'已被使用"
16
+ account_with_uid_destroyed: "帳號 '%{uid}' 已被移除。"
17
+ account_to_destroy_not_found: "無法找到目標帳號。"
18
+ user_not_found: "找不到帳號。"
19
+ omniauth:
20
+ not_allowed_redirect_url: "不支援轉向到 '%{redirect_url}'"
21
+ passwords:
22
+ missing_email: "必需提供電郵。"
23
+ missing_redirect_url: "欠缺 redirect URL."
24
+ not_allowed_redirect_url: "不支援轉向到 '%{redirect_url}'"
25
+ sended: "您將在幾分鐘後收到一封電子郵件'%{email},內含可重新設定密碼連結的電子郵件。"
26
+ user_not_found: "找不到帳號 '%{email}'。"
27
+ password_not_required: "這不是一個需要密碼的帳號. 請使用 '%{provider}' 進行登入"
28
+ missing_passwords: "必需填寫'密碼'與'確認密碼'。"
29
+ successfully_updated: "您的密碼已被修改。"
30
+ errors:
31
+ messages:
32
+ validate_sign_up_params: "請在request body中填入有效的註冊內容"
33
+ validate_account_update_params: "請在request body中填入有效的更新帳號資料"
34
+ not_email: "這不是一個合適的電郵。"
35
+ devise:
36
+ mailer:
37
+ confirmation_instructions:
38
+ confirm_link_msg: "可以使用下面連結確定你的電郵"
39
+ confirm_account_link: "確定你的帳號"
40
+ reset_password_instructions:
41
+ request_reset_link_msg: "已申請修改您的密碼,你可以用下面連結進入"
42
+ password_change_link: "修改我的密碼"
43
+ ignore_mail_msg: "如你沒有申請,請忽略"
44
+ no_changes_msg: "在你點擊上面連結前,你的密碼都沒有改變"
45
+ unlock_instructions:
46
+ account_lock_msg: "由於多失敗登入,我們已鎖定你的帳號"
47
+ unlock_link_msg: "可以使用下面連結解鎖你的帳號"
48
+ unlock_link: "解鎖帳號"
49
+ hello: "你好"
50
+ welcome: "歡迎"
@@ -0,0 +1,50 @@
1
+ # Additional translations at https://github.com/plataformatec/devise/wiki/I18n
2
+
3
+ zh-TW:
4
+ devise_token_auth:
5
+ sessions:
6
+ not_confirmed: "您將在幾分鐘後收到一封電子郵件'%{email}',內有驗證帳號的步驟說明。"
7
+ bad_credentials: "不正確的登入資料。請重試。"
8
+ not_supported: "請使用 POST /sign_in 進行登入. GET 是不支援的."
9
+ user_not_found: "未能找到帳號或未能成功登入。"
10
+ token_validations:
11
+ invalid: "不正確的登入資料。"
12
+ registrations:
13
+ missing_confirm_success_url: "欠缺數值 'confirm_success_url'"
14
+ redirect_url_not_allowed: "不支援轉向到'%{redirect_url}'"
15
+ email_already_exists: "電郵'%{email}'已被使用"
16
+ account_with_uid_destroyed: "帳號 '%{uid}' 已被移除。"
17
+ account_to_destroy_not_found: "無法找到目標帳號。"
18
+ user_not_found: "找不到帳號。"
19
+ omniauth:
20
+ not_allowed_redirect_url: "不支援轉向到 '%{redirect_url}'"
21
+ passwords:
22
+ missing_email: "必需提供電郵。"
23
+ missing_redirect_url: "欠缺 redirect URL."
24
+ not_allowed_redirect_url: "不支援轉向到 '%{redirect_url}'"
25
+ sended: "您將在幾分鐘後收到一封電子郵件'%{email},內含可重新設定密碼連結的電子郵件。"
26
+ user_not_found: "找不到帳號 '%{email}'。"
27
+ password_not_required: "這不是一個需要密碼的帳號. 請使用 '%{provider}' 進行登入"
28
+ missing_passwords: "必需填寫'密碼'與'確認密碼'。"
29
+ successfully_updated: "您的密碼已被修改。"
30
+ errors:
31
+ messages:
32
+ validate_sign_up_params: "請在request body中填入有效的註冊內容"
33
+ validate_account_update_params: "請在request body中填入有效的更新帳號資料"
34
+ not_email: "這不是一個合適的電郵。"
35
+ devise:
36
+ mailer:
37
+ confirmation_instructions:
38
+ confirm_link_msg: "可以使用下面連結確定你的電郵"
39
+ confirm_account_link: "確定你的帳號"
40
+ reset_password_instructions:
41
+ request_reset_link_msg: "已申請修改您的密碼,你可以用下面連結進入"
42
+ password_change_link: "修改我的密碼"
43
+ ignore_mail_msg: "如你沒有申請,請忽略"
44
+ no_changes_msg: "在你點擊上面連結前,你的密碼都沒有改變"
45
+ unlock_instructions:
46
+ account_lock_msg: "由於多失敗登入,我們已鎖定你的帳號"
47
+ unlock_link_msg: "可以使用下面連結解鎖你的帳號"
48
+ unlock_link: "解鎖帳號"
49
+ hello: "你好"
50
+ welcome: "歡迎"
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'devise'
4
+
5
+ module DeviseTokenAuth
6
+ end
7
+
8
+ require 'devise_token_auth/engine'
9
+ require 'devise_token_auth/controllers/helpers'
10
+ require 'devise_token_auth/controllers/url_helpers'
11
+ require 'devise_token_auth/url'
12
+ require 'devise_token_auth/errors'
13
+ require 'devise_token_auth/blacklist'
14
+ require 'devise_token_auth/token_factory'
@@ -0,0 +1,2 @@
1
+ # don't serialize tokens
2
+ Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION << :tokens
@@ -0,0 +1,157 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DeviseTokenAuth
4
+ module Controllers
5
+ module Helpers
6
+ extend ActiveSupport::Concern
7
+
8
+ module ClassMethods
9
+ # Define authentication filters and accessor helpers for a group of mappings.
10
+ # These methods are useful when you are working with multiple mappings that
11
+ # share some functionality. They are pretty much the same as the ones
12
+ # defined for normal mappings.
13
+ #
14
+ # Example:
15
+ #
16
+ # inside BlogsController (or any other controller, it doesn't matter which):
17
+ # devise_group :blogger, contains: [:user, :admin]
18
+ #
19
+ # Generated methods:
20
+ # authenticate_blogger! # Redirects unless user or admin are signed in
21
+ # blogger_signed_in? # Checks whether there is either a user or an admin signed in
22
+ # current_blogger # Currently signed in user or admin
23
+ # current_bloggers # Currently signed in user and admin
24
+ # render_authenticate_error # Render error unless user or admin are signed in
25
+ #
26
+ # Use:
27
+ # before_action :authenticate_blogger! # Redirects unless either a user or an admin are authenticated
28
+ # before_action ->{ authenticate_blogger! :admin } # Redirects to the admin login page
29
+ # current_blogger :user # Preferably returns a User if one is signed in
30
+ #
31
+ def devise_token_auth_group(group_name, opts = {})
32
+ mappings = "[#{opts[:contains].map { |m| ":#{m}" }.join(',')}]"
33
+
34
+ class_eval <<-METHODS, __FILE__, __LINE__ + 1
35
+ def authenticate_#{group_name}!(favourite=nil, opts={})
36
+ unless #{group_name}_signed_in?
37
+ unless current_#{group_name}
38
+ render_authenticate_error
39
+ end
40
+ end
41
+ end
42
+
43
+ def #{group_name}_signed_in?
44
+ !!current_#{group_name}
45
+ end
46
+
47
+ def current_#{group_name}(favourite=nil)
48
+ @current_#{group_name} ||= set_group_user_by_token(favourite)
49
+ end
50
+
51
+ def set_group_user_by_token(favourite)
52
+ mappings = #{mappings}
53
+ mappings.unshift mappings.delete(favourite.to_sym) if favourite
54
+ mappings.each do |mapping|
55
+ current = set_user_by_token(mapping)
56
+ return current if current
57
+ end
58
+ nil
59
+ end
60
+
61
+ def current_#{group_name.to_s.pluralize}
62
+ #{mappings}.map do |mapping|
63
+ set_user_by_token(mapping)
64
+ end.compact
65
+ end
66
+
67
+ def render_authenticate_error
68
+ return render json: {
69
+ errors: [I18n.t('devise.failure.unauthenticated')]
70
+ }, status: 401
71
+ end
72
+
73
+ if respond_to?(:helper_method)
74
+ helper_method(
75
+ "current_#{group_name}",
76
+ "current_#{group_name.to_s.pluralize}",
77
+ "#{group_name}_signed_in?",
78
+ "render_authenticate_error"
79
+ )
80
+ end
81
+ METHODS
82
+ end
83
+
84
+ def log_process_action(payload)
85
+ payload[:status] ||= 401 unless payload[:exception]
86
+ super
87
+ end
88
+ end
89
+
90
+ # Define authentication filters and accessor helpers based on mappings.
91
+ # These filters should be used inside the controllers as before_actions,
92
+ # so you can control the scope of the user who should be signed in to
93
+ # access that specific controller/action.
94
+ # Example:
95
+ #
96
+ # Roles:
97
+ # User
98
+ # Admin
99
+ #
100
+ # Generated methods:
101
+ # authenticate_user! # Signs user in or 401
102
+ # authenticate_admin! # Signs admin in or 401
103
+ # user_signed_in? # Checks whether there is a user signed in or not
104
+ # admin_signed_in? # Checks whether there is an admin signed in or not
105
+ # current_user # Current signed in user
106
+ # current_admin # Current signed in admin
107
+ # user_session # Session data available only to the user scope
108
+ # admin_session # Session data available only to the admin scope
109
+ # render_authenticate_error # Render error unless user or admin is signed in
110
+ #
111
+ # Use:
112
+ # before_action :authenticate_user! # Tell devise to use :user map
113
+ # before_action :authenticate_admin! # Tell devise to use :admin map
114
+ #
115
+ def self.define_helpers(mapping) #:nodoc:
116
+ mapping = mapping.name
117
+
118
+ class_eval <<-METHODS, __FILE__, __LINE__ + 1
119
+ def authenticate_#{mapping}!(opts={})
120
+ unless current_#{mapping}
121
+ render_authenticate_error
122
+ end
123
+ end
124
+
125
+ def #{mapping}_signed_in?
126
+ !!current_#{mapping}
127
+ end
128
+
129
+ def current_#{mapping}
130
+ @current_#{mapping} ||= set_user_by_token(:#{mapping})
131
+ end
132
+
133
+ def #{mapping}_session
134
+ current_#{mapping} && warden.session(:#{mapping})
135
+ end
136
+
137
+ def render_authenticate_error
138
+ return render json: {
139
+ errors: [I18n.t('devise.failure.unauthenticated')]
140
+ }, status: 401
141
+ end
142
+ METHODS
143
+
144
+ ActiveSupport.on_load(:action_controller) do
145
+ if respond_to?(:helper_method)
146
+ helper_method(
147
+ "current_#{mapping}",
148
+ "#{mapping}_signed_in?",
149
+ "#{mapping}_session",
150
+ 'render_authenticate_error'
151
+ )
152
+ end
153
+ end
154
+ end
155
+ end
156
+ end
157
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DeviseTokenAuth
4
+ module Controllers
5
+ module UrlHelpers
6
+ def self.define_helpers(mapping)
7
+ end
8
+ end
9
+ end
10
+ end