n_base_rails 0.1.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.
Files changed (139) hide show
  1. checksums.yaml +7 -0
  2. data/.ruby-version +1 -0
  3. data/CHANGELOG.md +5 -0
  4. data/CODE_OF_CONDUCT.md +84 -0
  5. data/Gemfile +8 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +49 -0
  8. data/Rakefile +4 -0
  9. data/bin/console +15 -0
  10. data/bin/setup +8 -0
  11. data/lib/.env +4 -0
  12. data/lib/.rspec +1 -0
  13. data/lib/.rubocop.yml +288 -0
  14. data/lib/.rubocop_disabled.yml +31 -0
  15. data/lib/.rubocop_enabled.yml +0 -0
  16. data/lib/Capfile +46 -0
  17. data/lib/Gemfile +51 -0
  18. data/lib/config/database.yml +24 -0
  19. data/lib/config/deploy/development.rb +85 -0
  20. data/lib/config/deploy/production.rb +63 -0
  21. data/lib/config/deploy/staging.rb +56 -0
  22. data/lib/config/deploy.rb +7 -0
  23. data/lib/config/initializers/devise.rb +315 -0
  24. data/lib/config/locales/devise.en.yml +65 -0
  25. data/lib/config/locales/en.yml +33 -0
  26. data/lib/config/locales/errors.en.yml +57 -0
  27. data/lib/config/routes.rb +26 -0
  28. data/lib/config/settings.yml +22 -0
  29. data/lib/controllers/api/admin/base_controller.rb +5 -0
  30. data/lib/controllers/api/admin/sessions_controller.rb +39 -0
  31. data/lib/controllers/api/admin/users_controller.rb +9 -0
  32. data/lib/controllers/api/v1/base_controller.rb +5 -0
  33. data/lib/controllers/api/v1/sessions_controller.rb +39 -0
  34. data/lib/controllers/api/v1/users_controller.rb +7 -0
  35. data/lib/controllers/application_controller.rb +30 -0
  36. data/lib/controllers/concerns/.DS_Store +0 -0
  37. data/lib/controllers/concerns/.keep +0 -0
  38. data/lib/controllers/concerns/base_concern.rb +9 -0
  39. data/lib/controllers/concerns/json_renderer.rb +76 -0
  40. data/lib/controllers/concerns/pagination.rb +32 -0
  41. data/lib/controllers/concerns/rescue_exception.rb +73 -0
  42. data/lib/db/migrate/20220721091426_devise_create_users.rb +46 -0
  43. data/lib/db/migrate/20230113072522_create_devices.rb +13 -0
  44. data/lib/db/migrate/20230227135020_create_posts.rb +15 -0
  45. data/lib/db/migrate/20230303165318_devise_create_admins.rb +46 -0
  46. data/lib/db/schema.rb +62 -0
  47. data/lib/db/seeds.rb +7 -0
  48. data/lib/generators/n_base_rails/install_generator.rb +42 -0
  49. data/lib/lib/.DS_Store +0 -0
  50. data/lib/lib/active_record_validation/error.rb +33 -0
  51. data/lib/lib/api/error.rb +63 -0
  52. data/lib/lib/json_web_token.rb +13 -0
  53. data/lib/log/.keep +0 -0
  54. data/lib/log/capistrano.log +28367 -0
  55. data/lib/log/development.log +30201 -0
  56. data/lib/log/test.log +11768 -0
  57. data/lib/models/admin.rb +10 -0
  58. data/lib/models/application_record.rb +5 -0
  59. data/lib/models/concerns/.keep +0 -0
  60. data/lib/models/device.rb +11 -0
  61. data/lib/models/post.rb +5 -0
  62. data/lib/models/user.rb +9 -0
  63. data/lib/n_base_rails/version.rb +5 -0
  64. data/lib/n_base_rails.rb +9 -0
  65. data/lib/public/404.html +67 -0
  66. data/lib/public/422.html +67 -0
  67. data/lib/public/500.html +66 -0
  68. data/lib/public/apple-touch-icon-precomposed.png +0 -0
  69. data/lib/public/apple-touch-icon.png +0 -0
  70. data/lib/public/docs/api/admin/definitions/users.yaml +15 -0
  71. data/lib/public/docs/api/admin/paths/index.yaml +29 -0
  72. data/lib/public/docs/api/admin/paths/sessions.yaml +121 -0
  73. data/lib/public/docs/api/admin/paths/users.yaml +39 -0
  74. data/lib/public/docs/api/shared/meta_infos.yaml +41 -0
  75. data/lib/public/docs/api/shared/unauthorized_response.yaml +31 -0
  76. data/lib/public/docs/api/v1/definitions/users.yaml +13 -0
  77. data/lib/public/docs/api/v1/paths/example.yaml +431 -0
  78. data/lib/public/docs/api/v1/paths/index.yaml +28 -0
  79. data/lib/public/docs/api/v1/paths/sessions.yaml +121 -0
  80. data/lib/public/docs/api/v1/paths/users.yaml +24 -0
  81. data/lib/public/favicon.ico +0 -0
  82. data/lib/public/robots.txt +1 -0
  83. data/lib/public/swagger/admin/admin-swagger-initializer.js +24 -0
  84. data/lib/public/swagger/admin/admin.html +19 -0
  85. data/lib/public/swagger/favicon-16x16.png +0 -0
  86. data/lib/public/swagger/favicon-32x32.png +0 -0
  87. data/lib/public/swagger/index.css +16 -0
  88. data/lib/public/swagger/oauth2-redirect.html +79 -0
  89. data/lib/public/swagger/swagger-ui-bundle.js +3 -0
  90. data/lib/public/swagger/swagger-ui-bundle.js.map +1 -0
  91. data/lib/public/swagger/swagger-ui-es-bundle-core.js +2 -0
  92. data/lib/public/swagger/swagger-ui-es-bundle-core.js.map +1 -0
  93. data/lib/public/swagger/swagger-ui-es-bundle.js +3 -0
  94. data/lib/public/swagger/swagger-ui-es-bundle.js.map +1 -0
  95. data/lib/public/swagger/swagger-ui-standalone-preset.js +3 -0
  96. data/lib/public/swagger/swagger-ui-standalone-preset.js.map +1 -0
  97. data/lib/public/swagger/swagger-ui.css +4 -0
  98. data/lib/public/swagger/swagger-ui.css.map +1 -0
  99. data/lib/public/swagger/swagger-ui.js +2 -0
  100. data/lib/public/swagger/swagger-ui.js.map +1 -0
  101. data/lib/public/swagger/v1/app.html +19 -0
  102. data/lib/public/swagger/v1/swagger-initializer.js +25 -0
  103. data/lib/serializers/.DS_Store +0 -0
  104. data/lib/serializers/action_not_allowed_serializer.rb +18 -0
  105. data/lib/serializers/api/.DS_Store +0 -0
  106. data/lib/serializers/api/admin/base_serializer.rb +14 -0
  107. data/lib/serializers/api/admin/hash_serializer.rb +22 -0
  108. data/lib/serializers/api/admin/user_serializer.rb +9 -0
  109. data/lib/serializers/api/v1/base_serializer.rb +14 -0
  110. data/lib/serializers/api/v1/hash_serializer.rb +22 -0
  111. data/lib/serializers/api/v1/user_serializer.rb +9 -0
  112. data/lib/serializers/record_not_found_serializer.rb +28 -0
  113. data/lib/serializers/validation_error_serializer.rb +45 -0
  114. data/lib/services/api/admin/generate_access_token_service.rb +34 -0
  115. data/lib/services/api/admin/generate_refresh_token_service.rb +24 -0
  116. data/lib/services/api/authorize_request_service.rb +35 -0
  117. data/lib/services/api/v1/generate_access_token_service.rb +34 -0
  118. data/lib/services/api/v1/generate_refresh_token_service.rb +24 -0
  119. data/lib/spec/controllers/api/admin/sessions_controller_spec.rb +125 -0
  120. data/lib/spec/controllers/api/admin/users_controller_spec.rb +35 -0
  121. data/lib/spec/controllers/api/v1/sessions_controller_spec.rb +125 -0
  122. data/lib/spec/controllers/api/v1/users_controller_spec.rb +23 -0
  123. data/lib/spec/factories/admins.rb +8 -0
  124. data/lib/spec/factories/devices.rb +7 -0
  125. data/lib/spec/factories/posts.rb +6 -0
  126. data/lib/spec/factories/users.rb +8 -0
  127. data/lib/spec/helpers/request_helpers.rb +7 -0
  128. data/lib/spec/models/admin_spec.rb +9 -0
  129. data/lib/spec/models/device_spec.rb +13 -0
  130. data/lib/spec/models/post_spec.rb +6 -0
  131. data/lib/spec/models/user_spec.rb +9 -0
  132. data/lib/spec/rails_helper.rb +66 -0
  133. data/lib/spec/serializers/api/admin/user_serializer.rb +20 -0
  134. data/lib/spec/serializers/api/v1/user_serializer.rb +20 -0
  135. data/lib/spec/spec_helper.rb +94 -0
  136. data/lib/spec/supports/shared_context.rb +19 -0
  137. data/lib/spec/supports/shared_example/admin_authentication.rb +47 -0
  138. data/lib/spec/supports/shared_example/user_authentication.rb +47 -0
  139. metadata +181 -0
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ set :deploy_to, '/home/deploy/apps/aoumi_server'
4
+
5
+ set :linked_files, %w[.env config/database.yml]
6
+ set :linked_dirs, %w[log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads]
7
+ set :keep_releases, 5
8
+ set :stage, :development
9
+ set :rails_env, :development
10
+ set :branch, 'develop'
11
+ set :rvm_type, :user
12
+ set :rvm_ruby_version, 'ruby-3.0.0'
13
+ set :env_file, '.env'
14
+
15
+ set :puma_rackup, -> { File.join(current_path, 'config.ru') }
16
+ set :puma_state, "#{shared_path}/tmp/pids/puma.state"
17
+ set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
18
+ set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock"
19
+ set :puma_conf, "#{shared_path}/puma.rb"
20
+ set :puma_access_log, "#{shared_path}/log/puma_error.log"
21
+ set :puma_error_log, "#{shared_path}/log/puma_access.log"
22
+ set :puma_role, :app
23
+ set :puma_env, fetch(:rack_env, fetch(:rails_env, 'development'))
24
+ set :puma_threads, [0, 8]
25
+ set :puma_workers, 0
26
+ set :puma_worker_timeout, nil
27
+ set :puma_init_active_record, true
28
+ set :puma_preload_app, false
29
+ server '52.74.130.28', user: 'deploy', roles: %w[web app db], primary: true
30
+
31
+ # server-based syntax
32
+ # ======================
33
+ # Defines a single server with a list of roles and multiple properties.
34
+ # You can define all roles on a single server, or split them:
35
+
36
+ # server "example.com", user: "deploy", roles: %w{app db web}, my_property: :my_value
37
+ # server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value
38
+ # server "db.example.com", user: "deploy", roles: %w{db}
39
+
40
+ # role-based syntax
41
+ # ==================
42
+
43
+ # Defines a role with one or multiple servers. The primary server in each
44
+ # group is considered to be the first unless any hosts have the primary
45
+ # property set. Specify the username and a domain or IP for the server.
46
+ # Don't use `:all`, it's a meta role.
47
+
48
+ # role :app, %w{deploy@example.com}, my_property: :my_value
49
+ # role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
50
+ # role :db, %w{deploy@example.com}
51
+
52
+ # Configuration
53
+ # =============
54
+ # You can set any configuration variable like in config/deploy.rb
55
+ # These variables are then only loaded and set in this stage.
56
+ # For available Capistrano configuration variables see the documentation page.
57
+ # http://capistranorb.com/documentation/getting-started/configuration/
58
+ # Feel free to add new variables to customise your setup.
59
+
60
+ # Custom SSH Options
61
+ # ==================
62
+ # You may pass any option but keep in mind that net/ssh understands a
63
+ # limited set of options, consult the Net::SSH documentation.
64
+ # http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
65
+ #
66
+ # Global options
67
+ # --------------
68
+ # set :ssh_options, {
69
+ # keys: %w(/home/user_name/.ssh/id_rsa),
70
+ # forward_agent: false,
71
+ # auth_methods: %w(password)
72
+ # }
73
+ #
74
+ # The server-based syntax can be used to override options:
75
+ # ------------------------------------
76
+ # server "example.com",
77
+ # user: "user_name",
78
+ # roles: %w{web app},
79
+ # ssh_options: {
80
+ # user: "user_name", # overrides user setting above
81
+ # keys: %w(/home/user_name/.ssh/id_rsa),
82
+ # forward_agent: false,
83
+ # auth_methods: %w(publickey password)
84
+ # # password: "please use keys"
85
+ # }
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ set :stage, :production
4
+ set :rails_env, :production
5
+ set :deploy_to, '/deploy/apps/aoumi_server'
6
+ set :branch, :master
7
+ server '54.179.250.136', user: 'deploy', roles: %w[web app db]
8
+
9
+ # server-based syntax
10
+ # ======================
11
+ # Defines a single server with a list of roles and multiple properties.
12
+ # You can define all roles on a single server, or split them:
13
+
14
+ # server "example.com", user: "deploy", roles: %w{app db web}, my_property: :my_value
15
+ # server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value
16
+ # server "db.example.com", user: "deploy", roles: %w{db}
17
+
18
+ # role-based syntax
19
+ # ==================
20
+
21
+ # Defines a role with one or multiple servers. The primary server in each
22
+ # group is considered to be the first unless any hosts have the primary
23
+ # property set. Specify the username and a domain or IP for the server.
24
+ # Don't use `:all`, it's a meta role.
25
+
26
+ # role :app, %w{deploy@example.com}, my_property: :my_value
27
+ # role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
28
+ # role :db, %w{deploy@example.com}
29
+
30
+ # Configuration
31
+ # =============
32
+ # You can set any configuration variable like in config/deploy.rb
33
+ # These variables are then only loaded and set in this stage.
34
+ # For available Capistrano configuration variables see the documentation page.
35
+ # http://capistranorb.com/documentation/getting-started/configuration/
36
+ # Feel free to add new variables to customise your setup.
37
+
38
+ # Custom SSH Options
39
+ # ==================
40
+ # You may pass any option but keep in mind that net/ssh understands a
41
+ # limited set of options, consult the Net::SSH documentation.
42
+ # http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
43
+ #
44
+ # Global options
45
+ # --------------
46
+ # set :ssh_options, {
47
+ # keys: %w(/home/user_name/.ssh/id_rsa),
48
+ # forward_agent: false,
49
+ # auth_methods: %w(password)
50
+ # }
51
+ #
52
+ # The server-based syntax can be used to override options:
53
+ # ------------------------------------
54
+ # server "example.com",
55
+ # user: "user_name",
56
+ # roles: %w{web app},
57
+ # ssh_options: {
58
+ # user: "user_name", # overrides user setting above
59
+ # keys: %w(/home/user_name/.ssh/id_rsa),
60
+ # forward_agent: false,
61
+ # auth_methods: %w(publickey password)
62
+ # # password: "please use keys"
63
+ # }
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+ # server-based syntax
3
+ # ======================
4
+ # Defines a single server with a list of roles and multiple properties.
5
+ # You can define all roles on a single server, or split them:
6
+
7
+ # server "example.com", user: "deploy", roles: %w{app db web}, my_property: :my_value
8
+ # server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value
9
+ # server "db.example.com", user: "deploy", roles: %w{db}
10
+
11
+ # role-based syntax
12
+ # ==================
13
+
14
+ # Defines a role with one or multiple servers. The primary server in each
15
+ # group is considered to be the first unless any hosts have the primary
16
+ # property set. Specify the username and a domain or IP for the server.
17
+ # Don't use `:all`, it's a meta role.
18
+
19
+ # role :app, %w{deploy@example.com}, my_property: :my_value
20
+ # role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
21
+ # role :db, %w{deploy@example.com}
22
+
23
+ # Configuration
24
+ # =============
25
+ # You can set any configuration variable like in config/deploy.rb
26
+ # These variables are then only loaded and set in this stage.
27
+ # For available Capistrano configuration variables see the documentation page.
28
+ # http://capistranorb.com/documentation/getting-started/configuration/
29
+ # Feel free to add new variables to customise your setup.
30
+
31
+ # Custom SSH Options
32
+ # ==================
33
+ # You may pass any option but keep in mind that net/ssh understands a
34
+ # limited set of options, consult the Net::SSH documentation.
35
+ # http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
36
+ #
37
+ # Global options
38
+ # --------------
39
+ # set :ssh_options, {
40
+ # keys: %w(/home/user_name/.ssh/id_rsa),
41
+ # forward_agent: false,
42
+ # auth_methods: %w(password)
43
+ # }
44
+ #
45
+ # The server-based syntax can be used to override options:
46
+ # ------------------------------------
47
+ # server "example.com",
48
+ # user: "user_name",
49
+ # roles: %w{web app},
50
+ # ssh_options: {
51
+ # user: "user_name", # overrides user setting above
52
+ # keys: %w(/home/user_name/.ssh/id_rsa),
53
+ # forward_agent: false,
54
+ # auth_methods: %w(publickey password)
55
+ # # password: "please use keys"
56
+ # }
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # config valid only for current version of Capistrano
4
+ lock '3.17.2'
5
+
6
+ set :application, 'aoumi_server'
7
+ set :repo_url, 'git@github.com:huythanh176/aoumi_server.git'
@@ -0,0 +1,315 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Assuming you have not yet modified this file, each configuration option below
4
+ # is set to its default value. Note that some are commented out while others
5
+ # are not: uncommented lines are intended to protect your configuration from
6
+ # breaking changes in upgrades (i.e., in the event that future versions of
7
+ # Devise change the default values for those options).
8
+ #
9
+ # Use this hook to configure devise mailer, warden hooks and so forth.
10
+ # Many of these configuration options can be set straight in your model.
11
+ Devise.setup do |config|
12
+ # The secret key used by Devise. Devise uses this key to generate
13
+ # random tokens. Changing this key will render invalid all existing
14
+ # confirmation, reset password and unlock tokens in the database.
15
+ # Devise will use the `secret_key_base` as its `secret_key`
16
+ # by default. You can change it below and use your own secret key.
17
+ # config.secret_key = 'b9516b99f8b30c61d09915cc6ab935d8f455880af5fcf9b86534dddfee27a8c4da7058b22070054310d42f9fac025122b729dc75bdbb3679679761df27224ee5'
18
+
19
+ # ==> Controller configuration
20
+ # Configure the parent class to the devise controllers.
21
+ # config.parent_controller = 'DeviseController'
22
+
23
+ # ==> Mailer Configuration
24
+ # Configure the e-mail address which will be shown in Devise::Mailer,
25
+ # note that it will be overwritten if you use your own mailer class
26
+ # with default "from" parameter.
27
+ config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
28
+
29
+ # Configure the class responsible to send e-mails.
30
+ # config.mailer = 'Devise::Mailer'
31
+
32
+ # Configure the parent class responsible to send e-mails.
33
+ # config.parent_mailer = 'ActionMailer::Base'
34
+
35
+ # ==> ORM configuration
36
+ # Load and configure the ORM. Supports :active_record (default) and
37
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
38
+ # available as additional gems.
39
+ require 'devise/orm/active_record'
40
+
41
+ # ==> Configuration for any authentication mechanism
42
+ # Configure which keys are used when authenticating a user. The default is
43
+ # just :email. You can configure it to use [:username, :subdomain], so for
44
+ # authenticating a user, both parameters are required. Remember that those
45
+ # parameters are used only when authenticating and not when retrieving from
46
+ # session. If you need permissions, you should implement that in a before filter.
47
+ # You can also supply a hash where the value is a boolean determining whether
48
+ # or not authentication should be aborted when the value is not present.
49
+ # config.authentication_keys = [:email]
50
+
51
+ # Configure parameters from the request object used for authentication. Each entry
52
+ # given should be a request method and it will automatically be passed to the
53
+ # find_for_authentication method and considered in your model lookup. For instance,
54
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
55
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
56
+ # config.request_keys = []
57
+
58
+ # Configure which authentication keys should be case-insensitive.
59
+ # These keys will be downcased upon creating or modifying a user and when used
60
+ # to authenticate or find a user. Default is :email.
61
+ config.case_insensitive_keys = [:email]
62
+
63
+ # Configure which authentication keys should have whitespace stripped.
64
+ # These keys will have whitespace before and after removed upon creating or
65
+ # modifying a user and when used to authenticate or find a user. Default is :email.
66
+ config.strip_whitespace_keys = [:email]
67
+
68
+ # Tell if authentication through request.params is enabled. True by default.
69
+ # It can be set to an array that will enable params authentication only for the
70
+ # given strategies, for example, `config.params_authenticatable = [:database]` will
71
+ # enable it only for database (email + password) authentication.
72
+ # config.params_authenticatable = true
73
+
74
+ # Tell if authentication through HTTP Auth is enabled. False by default.
75
+ # It can be set to an array that will enable http authentication only for the
76
+ # given strategies, for example, `config.http_authenticatable = [:database]` will
77
+ # enable it only for database authentication.
78
+ # For API-only applications to support authentication "out-of-the-box", you will likely want to
79
+ # enable this with :database unless you are using a custom strategy.
80
+ # The supported strategies are:
81
+ # :database = Support basic authentication with authentication key + password
82
+ # config.http_authenticatable = false
83
+
84
+ # If 401 status code should be returned for AJAX requests. True by default.
85
+ # config.http_authenticatable_on_xhr = true
86
+
87
+ # The realm used in Http Basic Authentication. 'Application' by default.
88
+ # config.http_authentication_realm = 'Application'
89
+
90
+ # It will change confirmation, password recovery and other workflows
91
+ # to behave the same regardless if the e-mail provided was right or wrong.
92
+ # Does not affect registerable.
93
+ # config.paranoid = true
94
+
95
+ # By default Devise will store the user in session. You can skip storage for
96
+ # particular strategies by setting this option.
97
+ # Notice that if you are skipping storage for all authentication paths, you
98
+ # may want to disable generating routes to Devise's sessions controller by
99
+ # passing skip: :sessions to `devise_for` in your config/routes.rb
100
+ config.skip_session_storage = [:http_auth]
101
+
102
+ # By default, Devise cleans up the CSRF token on authentication to
103
+ # avoid CSRF token fixation attacks. This means that, when using AJAX
104
+ # requests for sign in and sign up, you need to get a new CSRF token
105
+ # from the server. You can disable this option at your own risk.
106
+ # config.clean_up_csrf_token_on_authentication = true
107
+
108
+ # When false, Devise will not attempt to reload routes on eager load.
109
+ # This can reduce the time taken to boot the app but if your application
110
+ # requires the Devise mappings to be loaded during boot time the application
111
+ # won't boot properly.
112
+ # config.reload_routes = true
113
+
114
+ # ==> Configuration for :database_authenticatable
115
+ # For bcrypt, this is the cost for hashing the password and defaults to 12. If
116
+ # using other algorithms, it sets how many times you want the password to be hashed.
117
+ # The number of stretches used for generating the hashed password are stored
118
+ # with the hashed password. This allows you to change the stretches without
119
+ # invalidating existing passwords.
120
+ #
121
+ # Limiting the stretches to just one in testing will increase the performance of
122
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
123
+ # a value less than 10 in other environments. Note that, for bcrypt (the default
124
+ # algorithm), the cost increases exponentially with the number of stretches (e.g.
125
+ # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
126
+ config.stretches = Rails.env.test? ? 1 : 12
127
+
128
+ # Set up a pepper to generate the hashed password.
129
+ # config.pepper = 'cce9bbc7cc95ce60083dbf5b531fde688f836326274898b773ead41a794628f0b0003f25aefa43401cf30bef894193f725874b10df7a9a73e92c83f32d5dcd41'
130
+
131
+ # Send a notification to the original email when the user's email is changed.
132
+ # config.send_email_changed_notification = false
133
+
134
+ # Send a notification email when the user's password is changed.
135
+ # config.send_password_change_notification = false
136
+
137
+ # ==> Configuration for :confirmable
138
+ # A period that the user is allowed to access the website even without
139
+ # confirming their account. For instance, if set to 2.days, the user will be
140
+ # able to access the website for two days without confirming their account,
141
+ # access will be blocked just in the third day.
142
+ # You can also set it to nil, which will allow the user to access the website
143
+ # without confirming their account.
144
+ # Default is 0.days, meaning the user cannot access the website without
145
+ # confirming their account.
146
+ # config.allow_unconfirmed_access_for = 2.days
147
+
148
+ # A period that the user is allowed to confirm their account before their
149
+ # token becomes invalid. For example, if set to 3.days, the user can confirm
150
+ # their account within 3 days after the mail was sent, but on the fourth day
151
+ # their account can't be confirmed with the token any more.
152
+ # Default is nil, meaning there is no restriction on how long a user can take
153
+ # before confirming their account.
154
+ # config.confirm_within = 3.days
155
+
156
+ # If true, requires any email changes to be confirmed (exactly the same way as
157
+ # initial account confirmation) to be applied. Requires additional unconfirmed_email
158
+ # db field (see migrations). Until confirmed, new email is stored in
159
+ # unconfirmed_email column, and copied to email column on successful confirmation.
160
+ config.reconfirmable = true
161
+
162
+ # Defines which key will be used when confirming an account
163
+ # config.confirmation_keys = [:email]
164
+
165
+ # ==> Configuration for :rememberable
166
+ # The time the user will be remembered without asking for credentials again.
167
+ # config.remember_for = 2.weeks
168
+
169
+ # Invalidates all the remember me tokens when the user signs out.
170
+ config.expire_all_remember_me_on_sign_out = true
171
+
172
+ # If true, extends the user's remember period when remembered via cookie.
173
+ # config.extend_remember_period = false
174
+
175
+ # Options to be passed to the created cookie. For instance, you can set
176
+ # secure: true in order to force SSL only cookies.
177
+ # config.rememberable_options = {}
178
+
179
+ # ==> Configuration for :validatable
180
+ # Range for password length.
181
+ config.password_length = 6..128
182
+
183
+ # Email regex used to validate email formats. It simply asserts that
184
+ # one (and only one) @ exists in the given string. This is mainly
185
+ # to give user feedback and not to assert the e-mail validity.
186
+ config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
187
+ # config.warden do |manager|
188
+ # manager.failure_app = CustomFailure
189
+ # end
190
+
191
+ # ==> Configuration for :timeoutable
192
+ # The time you want to timeout the user session without activity. After this
193
+ # time the user will be asked for credentials again. Default is 30 minutes.
194
+ # config.timeout_in = 30.minutes
195
+
196
+ # ==> Configuration for :lockable
197
+ # Defines which strategy will be used to lock an account.
198
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
199
+ # :none = No lock strategy. You should handle locking by yourself.
200
+ # config.lock_strategy = :failed_attempts
201
+
202
+ # Defines which key will be used when locking and unlocking an account
203
+ # config.unlock_keys = [:email]
204
+
205
+ # Defines which strategy will be used to unlock an account.
206
+ # :email = Sends an unlock link to the user email
207
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
208
+ # :both = Enables both strategies
209
+ # :none = No unlock strategy. You should handle unlocking by yourself.
210
+ # config.unlock_strategy = :both
211
+
212
+ # Number of authentication tries before locking an account if lock_strategy
213
+ # is failed attempts.
214
+ # config.maximum_attempts = 20
215
+
216
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
217
+ # config.unlock_in = 1.hour
218
+
219
+ # Warn on the last attempt before the account is locked.
220
+ # config.last_attempt_warning = true
221
+
222
+ # ==> Configuration for :recoverable
223
+ #
224
+ # Defines which key will be used when recovering the password for an account
225
+ # config.reset_password_keys = [:email]
226
+
227
+ # Time interval you can reset your password with a reset password key.
228
+ # Don't put a too small interval or your users won't have the time to
229
+ # change their passwords.
230
+ config.reset_password_within = 6.hours
231
+
232
+ # When set to false, does not sign a user in automatically after their password is
233
+ # reset. Defaults to true, so a user is signed in automatically after a reset.
234
+ # config.sign_in_after_reset_password = true
235
+
236
+ # ==> Configuration for :encryptable
237
+ # Allow you to use another hashing or encryption algorithm besides bcrypt (default).
238
+ # You can use :sha1, :sha512 or algorithms from others authentication tools as
239
+ # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
240
+ # for default behavior) and :restful_authentication_sha1 (then you should set
241
+ # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
242
+ #
243
+ # Require the `devise-encryptable` gem when using anything other than bcrypt
244
+ # config.encryptor = :sha512
245
+
246
+ # ==> Scopes configuration
247
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
248
+ # "users/sessions/new". It's turned off by default because it's slower if you
249
+ # are using only default views.
250
+ # config.scoped_views = false
251
+
252
+ # Configure the default scope given to Warden. By default it's the first
253
+ # devise role declared in your routes (usually :user).
254
+ # config.default_scope = :user
255
+
256
+ # Set this configuration to false if you want /users/sign_out to sign out
257
+ # only the current scope. By default, Devise signs out all scopes.
258
+ # config.sign_out_all_scopes = true
259
+
260
+ # ==> Navigation configuration
261
+ # Lists the formats that should be treated as navigational. Formats like
262
+ # :html, should redirect to the sign in page when the user does not have
263
+ # access, but formats like :xml or :json, should return 401.
264
+ #
265
+ # If you have any extra navigational formats, like :iphone or :mobile, you
266
+ # should add them to the navigational formats lists.
267
+ #
268
+ # The "*/*" below is required to match Internet Explorer requests.
269
+ # config.navigational_formats = ['*/*', :html]
270
+
271
+ # The default HTTP method used to sign out a resource. Default is :delete.
272
+ config.sign_out_via = :delete
273
+ config.navigational_formats = ['*/*', :html, :json]
274
+
275
+ # ==> OmniAuth
276
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
277
+ # up on your models and hooks.
278
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
279
+
280
+ # ==> Warden configuration
281
+ # If you want to use other strategies, that are not supported by Devise, or
282
+ # change the failure app, you can configure them inside the config.warden block.
283
+ #
284
+ # config.warden do |manager|
285
+ # manager.intercept_401 = false
286
+ # manager.default_strategies(scope: :user).unshift :some_external_strategy
287
+ # end
288
+
289
+ # ==> Mountable engine configurations
290
+ # When using Devise inside an engine, let's call it `MyEngine`, and this engine
291
+ # is mountable, there are some extra configurations to be taken into account.
292
+ # The following options are available, assuming the engine is mounted as:
293
+ #
294
+ # mount MyEngine, at: '/my_engine'
295
+ #
296
+ # The router that invoked `devise_for`, in the example above, would be:
297
+ # config.router_name = :my_engine
298
+ #
299
+ # When using OmniAuth, Devise cannot automatically set OmniAuth path,
300
+ # so you need to do it manually. For the users scope, it would be:
301
+ # config.omniauth_path_prefix = '/my_engine/users/auth'
302
+
303
+ # ==> Turbolinks configuration
304
+ # If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly:
305
+ #
306
+ # ActiveSupport.on_load(:devise_failure_app) do
307
+ # include Turbolinks::Controller
308
+ # end
309
+
310
+ # ==> Configuration for :registerable
311
+
312
+ # When set to false, does not sign a user in automatically after their password is
313
+ # changed. Defaults to true, so a user is signed in automatically after changing a password.
314
+ # config.sign_in_after_change_password = true
315
+ end
@@ -0,0 +1,65 @@
1
+ # Additional translations at https://github.com/heartcombo/devise/wiki/I18n
2
+
3
+ en:
4
+ devise:
5
+ confirmations:
6
+ confirmed: "Your email address has been successfully confirmed."
7
+ send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
8
+ send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
9
+ failure:
10
+ already_authenticated: "You are already signed in."
11
+ inactive: "Your account is not activated yet."
12
+ invalid: "Invalid email or password."
13
+ locked: "Your account is locked."
14
+ last_attempt: "You have one more attempt before your account is locked."
15
+ not_found_in_database: "Invalid %{authentication_keys} or password."
16
+ timeout: "Your session expired. Please sign in again to continue."
17
+ unauthenticated: "You need to sign in or sign up before continuing."
18
+ unconfirmed: "You have to confirm your email address before continuing."
19
+ mailer:
20
+ confirmation_instructions:
21
+ subject: "Confirmation instructions"
22
+ reset_password_instructions:
23
+ subject: "Reset password instructions"
24
+ unlock_instructions:
25
+ subject: "Unlock instructions"
26
+ email_changed:
27
+ subject: "Email Changed"
28
+ password_change:
29
+ subject: "Password Changed"
30
+ omniauth_callbacks:
31
+ failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
32
+ success: "Successfully authenticated from %{kind} account."
33
+ passwords:
34
+ no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
35
+ send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
36
+ send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
37
+ updated: "Your password has been changed successfully. You are now signed in."
38
+ updated_not_active: "Your password has been changed successfully."
39
+ registrations:
40
+ destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
41
+ signed_up: "Welcome! You have signed up successfully."
42
+ signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
43
+ signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
44
+ signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
45
+ update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address."
46
+ updated: "Your account has been updated successfully."
47
+ updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again."
48
+ sessions:
49
+ signed_in: "Signed in successfully."
50
+ signed_out: "Signed out successfully."
51
+ already_signed_out: "Signed out successfully."
52
+ unlocks:
53
+ send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
54
+ send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
55
+ unlocked: "Your account has been unlocked successfully. Please sign in to continue."
56
+ errors:
57
+ messages:
58
+ already_confirmed: "was already confirmed, please try signing in"
59
+ confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
60
+ expired: "has expired, please request a new one"
61
+ not_found: "not found"
62
+ not_locked: "was not locked"
63
+ not_saved:
64
+ one: "1 error prohibited this %{resource} from being saved:"
65
+ other: "%{count} errors prohibited this %{resource} from being saved:"
@@ -0,0 +1,33 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t "hello"
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t("hello") %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # The following keys must be escaped otherwise they will not be retrieved by
20
+ # the default I18n backend:
21
+ #
22
+ # true, false, on, off, yes, no
23
+ #
24
+ # Instead, surround them with single quotes.
25
+ #
26
+ # en:
27
+ # "true": "foo"
28
+ #
29
+ # To learn more, please read the Rails Internationalization guide
30
+ # available at https://guides.rubyonrails.org/i18n.html.
31
+
32
+ en:
33
+ hello: "Hello world"