Commit b2aa1906fe3915c74902063ed7c0adad7a4bb9a0

Authored by kpeclipse@up.edu.ph
1 parent de611157

OJT21-58: Add initial sign-up feature

... ... @@ -18,6 +18,9 @@ gem 'puma', '~> 5.0'
18 18 # Use Active Model has_secure_password
19 19 # gem 'bcrypt', '~> 3.1.7'
20 20
  21 +gem 'devise', '~> 4.8'
  22 +gem 'devise-jwt', '~> 0.8.1'
  23 +
21 24 # Use Active Storage variant
22 25 # gem 'image_processing', '~> 1.2'
23 26
... ... @@ -25,7 +28,8 @@ gem 'puma', '~> 5.0'
25 28 gem 'bootsnap', '>= 1.4.4', require: false
26 29
27 30 # Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
28   -# gem 'rack-cors'
  31 +gem 'active_model_serializers', '~> 0.10.12'
  32 +gem 'rack-cors'
29 33
30 34 group :development, :test do
31 35 # Call 'byebug' anywhere in the code to stop execution and get a debugger console
... ...
... ... @@ -39,6 +39,11 @@ GEM
39 39 erubi (~> 1.4)
40 40 rails-dom-testing (~> 2.0)
41 41 rails-html-sanitizer (~> 1.1, >= 1.2.0)
  42 + active_model_serializers (0.10.12)
  43 + actionpack (>= 4.1, < 6.2)
  44 + activemodel (>= 4.1, < 6.2)
  45 + case_transform (>= 0.2)
  46 + jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
42 47 activejob (6.1.4)
43 48 activesupport (= 6.1.4)
44 49 globalid (>= 0.3.6)
... ... @@ -61,22 +66,47 @@ GEM
61 66 tzinfo (~> 2.0)
62 67 zeitwerk (~> 2.3)
63 68 ast (2.4.2)
  69 + bcrypt (3.1.16)
64 70 bootsnap (1.7.6)
65 71 msgpack (~> 1.0)
66 72 builder (3.2.4)
67 73 byebug (11.1.3)
  74 + case_transform (0.2)
  75 + activesupport
68 76 concurrent-ruby (1.1.9)
69 77 crass (1.0.6)
  78 + devise (4.8.0)
  79 + bcrypt (~> 3.0)
  80 + orm_adapter (~> 0.1)
  81 + railties (>= 4.1.0)
  82 + responders
  83 + warden (~> 1.2.3)
  84 + devise-jwt (0.8.1)
  85 + devise (~> 4.0)
  86 + warden-jwt_auth (~> 0.5)
  87 + dry-auto_inject (0.8.0)
  88 + dry-container (>= 0.3.4)
  89 + dry-configurable (0.12.1)
  90 + concurrent-ruby (~> 1.0)
  91 + dry-core (~> 0.5, >= 0.5.0)
  92 + dry-container (0.8.0)
  93 + concurrent-ruby (~> 1.0)
  94 + dry-configurable (~> 0.1, >= 0.1.3)
  95 + dry-core (0.7.1)
  96 + concurrent-ruby (~> 1.0)
70 97 erubi (1.10.0)
  98 + ffi (1.15.3)
71 99 ffi (1.15.3-x64-mingw32)
72 100 globalid (0.5.1)
73 101 activesupport (>= 5.0)
74 102 i18n (1.8.10)
75 103 concurrent-ruby (~> 1.0)
  104 + jsonapi-renderer (0.2.2)
  105 + jwt (2.2.3)
76 106 listen (3.6.0)
77 107 rb-fsevent (~> 0.10, >= 0.10.3)
78 108 rb-inotify (~> 0.9, >= 0.9.10)
79   - loofah (2.10.0)
  109 + loofah (2.11.0)
80 110 crass (~> 1.0.2)
81 111 nokogiri (>= 1.5.9)
82 112 mail (2.7.1)
... ... @@ -86,10 +116,14 @@ GEM
86 116 mini_mime (1.1.0)
87 117 minitest (5.14.4)
88 118 msgpack (1.4.2)
  119 + mysql2 (0.5.3)
89 120 mysql2 (0.5.3-x64-mingw32)
90 121 nio4r (2.5.7)
91 122 nokogiri (1.11.7-x64-mingw32)
92 123 racc (~> 1.4)
  124 + nokogiri (1.11.7-x86_64-linux)
  125 + racc (~> 1.4)
  126 + orm_adapter (0.5.0)
93 127 parallel (1.20.1)
94 128 parser (3.0.2.0)
95 129 ast (~> 2.4.1)
... ... @@ -97,6 +131,8 @@ GEM
97 131 nio4r (~> 2.0)
98 132 racc (1.5.2)
99 133 rack (2.2.3)
  134 + rack-cors (1.1.1)
  135 + rack (>= 2.0.0)
100 136 rack-test (1.1.0)
101 137 rack (>= 1.0, < 3)
102 138 rails (6.1.4)
... ... @@ -131,6 +167,9 @@ GEM
131 167 rb-inotify (0.10.1)
132 168 ffi (~> 1.0)
133 169 regexp_parser (2.1.1)
  170 + responders (3.0.1)
  171 + actionpack (>= 5.0)
  172 + railties (>= 5.0)
134 173 rexml (3.2.5)
135 174 rubocop (1.18.4)
136 175 parallel (~> 1.10)
... ... @@ -158,6 +197,13 @@ GEM
158 197 tzinfo-data (1.2021.1)
159 198 tzinfo (>= 1.0.0)
160 199 unicode-display_width (2.0.0)
  200 + warden (1.2.9)
  201 + rack (>= 2.0.9)
  202 + warden-jwt_auth (0.5.0)
  203 + dry-auto_inject (~> 0.6)
  204 + dry-configurable (~> 0.9)
  205 + jwt (~> 2.1)
  206 + warden (~> 1.2)
161 207 websocket-driver (0.7.5)
162 208 websocket-extensions (>= 0.1.0)
163 209 websocket-extensions (0.1.5)
... ... @@ -168,11 +214,15 @@ PLATFORMS
168 214 x86_64-linux
169 215
170 216 DEPENDENCIES
  217 + active_model_serializers (~> 0.10.12)
171 218 bootsnap (>= 1.4.4)
172 219 byebug
  220 + devise (~> 4.8)
  221 + devise-jwt (~> 0.8.1)
173 222 listen (~> 3.3)
174 223 mysql2 (~> 0.5)
175 224 puma (~> 5.0)
  225 + rack-cors
176 226 rails (~> 6.1.4)
177 227 rubocop
178 228 spring
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +module V1
  4 + class RegistrationsController < Devise::RegistrationsController
  5 + respond_to :json
  6 + end
  7 +end
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +class User < ApplicationRecord
  4 + # Include default devise modules. Others available are:
  5 + # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  6 + devise :database_authenticatable, :registerable,
  7 + :recoverable, :rememberable, :validatable
  8 +end
... ...
... ... @@ -16,7 +16,6 @@ require 'action_view/railtie'
16 16 require 'action_cable/engine'
17 17 # require "sprockets/railtie"
18 18 require 'rails/test_unit/railtie'
19   -resss
20 19
21 20 # Require the gems listed in Gemfile, including any gems
22 21 # you've limited to :test, :development, or :production.
... ...
... ... @@ -37,6 +37,8 @@ Rails.application.configure do
37 37
38 38 config.action_mailer.perform_caching = false
39 39
  40 + config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
  41 +
40 42 # Print deprecation notices to the Rails logger.
41 43 config.active_support.deprecation = :log
42 44
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +# frozen_string_literal: true
  4 +
  5 +# Assuming you have not yet modified this file, each configuration option below
  6 +# is set to its default value. Note that some are commented out while others
  7 +# are not: uncommented lines are intended to protect your configuration from
  8 +# breaking changes in upgrades (i.e., in the event that future versions of
  9 +# Devise change the default values for those options).
  10 +#
  11 +# Use this hook to configure devise mailer, warden hooks and so forth.
  12 +# Many of these configuration options can be set straight in your model.
  13 +Devise.setup do |config|
  14 + # The secret key used by Devise. Devise uses this key to generate
  15 + # random tokens. Changing this key will render invalid all existing
  16 + # confirmation, reset password and unlock tokens in the database.
  17 + # Devise will use the `secret_key_base` as its `secret_key`
  18 + # by default. You can change it below and use your own secret key.
  19 + # rubocop:todo Layout/LineLength
  20 + # config.secret_key = '7d8e38a5fab0957a46e4216f9ad7f815b633b51ba6586eefe59144df2746a5aa2a1a8b0093892052a9ccc90e70e0703bdac02bb596b2cdb87c70bec4dc51f5b6'
  21 + # rubocop:enable Layout/LineLength
  22 +
  23 + # ==> Controller configuration
  24 + # Configure the parent class to the devise controllers.
  25 + # config.parent_controller = 'DeviseController'
  26 +
  27 + # ==> Mailer Configuration
  28 + # Configure the e-mail address which will be shown in Devise::Mailer,
  29 + # note that it will be overwritten if you use your own mailer class
  30 + # with default "from" parameter.
  31 + config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
  32 +
  33 + # Configure the class responsible to send e-mails.
  34 + # config.mailer = 'Devise::Mailer'
  35 +
  36 + # Configure the parent class responsible to send e-mails.
  37 + # config.parent_mailer = 'ActionMailer::Base'
  38 +
  39 + # ==> ORM configuration
  40 + # Load and configure the ORM. Supports :active_record (default) and
  41 + # :mongoid (bson_ext recommended) by default. Other ORMs may be
  42 + # available as additional gems.
  43 + require 'devise/orm/active_record'
  44 +
  45 + # ==> Configuration for any authentication mechanism
  46 + # Configure which keys are used when authenticating a user. The default is
  47 + # just :email. You can configure it to use [:username, :subdomain], so for
  48 + # authenticating a user, both parameters are required. Remember that those
  49 + # parameters are used only when authenticating and not when retrieving from
  50 + # session. If you need permissions, you should implement that in a before filter.
  51 + # You can also supply a hash where the value is a boolean determining whether
  52 + # or not authentication should be aborted when the value is not present.
  53 + # config.authentication_keys = [:email]
  54 +
  55 + # Configure parameters from the request object used for authentication. Each entry
  56 + # given should be a request method and it will automatically be passed to the
  57 + # find_for_authentication method and considered in your model lookup. For instance,
  58 + # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
  59 + # The same considerations mentioned for authentication_keys also apply to request_keys.
  60 + # config.request_keys = []
  61 +
  62 + # Configure which authentication keys should be case-insensitive.
  63 + # These keys will be downcased upon creating or modifying a user and when used
  64 + # to authenticate or find a user. Default is :email.
  65 + config.case_insensitive_keys = [:email]
  66 +
  67 + # Configure which authentication keys should have whitespace stripped.
  68 + # These keys will have whitespace before and after removed upon creating or
  69 + # modifying a user and when used to authenticate or find a user. Default is :email.
  70 + config.strip_whitespace_keys = [:email]
  71 +
  72 + # Tell if authentication through request.params is enabled. True by default.
  73 + # It can be set to an array that will enable params authentication only for the
  74 + # given strategies, for example, `config.params_authenticatable = [:database]` will
  75 + # enable it only for database (email + password) authentication.
  76 + # config.params_authenticatable = true
  77 +
  78 + # Tell if authentication through HTTP Auth is enabled. False by default.
  79 + # It can be set to an array that will enable http authentication only for the
  80 + # given strategies, for example, `config.http_authenticatable = [:database]` will
  81 + # enable it only for database authentication.
  82 + # For API-only applications to support authentication "out-of-the-box", you will likely want to
  83 + # enable this with :database unless you are using a custom strategy.
  84 + # The supported strategies are:
  85 + # :database = Support basic authentication with authentication key + password
  86 + # config.http_authenticatable = false
  87 +
  88 + # If 401 status code should be returned for AJAX requests. True by default.
  89 + # config.http_authenticatable_on_xhr = true
  90 +
  91 + # The realm used in Http Basic Authentication. 'Application' by default.
  92 + # config.http_authentication_realm = 'Application'
  93 +
  94 + # It will change confirmation, password recovery and other workflows
  95 + # to behave the same regardless if the e-mail provided was right or wrong.
  96 + # Does not affect registerable.
  97 + # config.paranoid = true
  98 +
  99 + # By default Devise will store the user in session. You can skip storage for
  100 + # particular strategies by setting this option.
  101 + # Notice that if you are skipping storage for all authentication paths, you
  102 + # may want to disable generating routes to Devise's sessions controller by
  103 + # passing skip: :sessions to `devise_for` in your config/routes.rb
  104 + config.skip_session_storage = [:http_auth]
  105 +
  106 + # By default, Devise cleans up the CSRF token on authentication to
  107 + # avoid CSRF token fixation attacks. This means that, when using AJAX
  108 + # requests for sign in and sign up, you need to get a new CSRF token
  109 + # from the server. You can disable this option at your own risk.
  110 + # config.clean_up_csrf_token_on_authentication = true
  111 +
  112 + # When false, Devise will not attempt to reload routes on eager load.
  113 + # This can reduce the time taken to boot the app but if your application
  114 + # requires the Devise mappings to be loaded during boot time the application
  115 + # won't boot properly.
  116 + # config.reload_routes = true
  117 +
  118 + # ==> Configuration for :database_authenticatable
  119 + # For bcrypt, this is the cost for hashing the password and defaults to 12. If
  120 + # using other algorithms, it sets how many times you want the password to be hashed.
  121 + # The number of stretches used for generating the hashed password are stored
  122 + # with the hashed password. This allows you to change the stretches without
  123 + # invalidating existing passwords.
  124 + #
  125 + # Limiting the stretches to just one in testing will increase the performance of
  126 + # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
  127 + # a value less than 10 in other environments. Note that, for bcrypt (the default
  128 + # algorithm), the cost increases exponentially with the number of stretches (e.g.
  129 + # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
  130 + config.stretches = Rails.env.test? ? 1 : 12
  131 +
  132 + # Set up a pepper to generate the hashed password.
  133 + # rubocop:todo Layout/LineLength
  134 + # config.pepper = 'ebea61cb22496cb93b330ea8fc5267fbc95ceb201f71d85b7fa0886d62310b4ac552905066c7bbff42429e0c9b02cb211592a169d888cb6bf0bf0fa88da573c1'
  135 + # rubocop:enable Layout/LineLength
  136 +
  137 + # Send a notification to the original email when the user's email is changed.
  138 + # config.send_email_changed_notification = false
  139 +
  140 + # Send a notification email when the user's password is changed.
  141 + # config.send_password_change_notification = false
  142 +
  143 + # ==> Configuration for :confirmable
  144 + # A period that the user is allowed to access the website even without
  145 + # confirming their account. For instance, if set to 2.days, the user will be
  146 + # able to access the website for two days without confirming their account,
  147 + # access will be blocked just in the third day.
  148 + # You can also set it to nil, which will allow the user to access the website
  149 + # without confirming their account.
  150 + # Default is 0.days, meaning the user cannot access the website without
  151 + # confirming their account.
  152 + # config.allow_unconfirmed_access_for = 2.days
  153 +
  154 + # A period that the user is allowed to confirm their account before their
  155 + # token becomes invalid. For example, if set to 3.days, the user can confirm
  156 + # their account within 3 days after the mail was sent, but on the fourth day
  157 + # their account can't be confirmed with the token any more.
  158 + # Default is nil, meaning there is no restriction on how long a user can take
  159 + # before confirming their account.
  160 + # config.confirm_within = 3.days
  161 +
  162 + # If true, requires any email changes to be confirmed (exactly the same way as
  163 + # initial account confirmation) to be applied. Requires additional unconfirmed_email
  164 + # db field (see migrations). Until confirmed, new email is stored in
  165 + # unconfirmed_email column, and copied to email column on successful confirmation.
  166 + config.reconfirmable = true
  167 +
  168 + # Defines which key will be used when confirming an account
  169 + # config.confirmation_keys = [:email]
  170 +
  171 + # ==> Configuration for :rememberable
  172 + # The time the user will be remembered without asking for credentials again.
  173 + # config.remember_for = 2.weeks
  174 +
  175 + # Invalidates all the remember me tokens when the user signs out.
  176 + config.expire_all_remember_me_on_sign_out = true
  177 +
  178 + # If true, extends the user's remember period when remembered via cookie.
  179 + # config.extend_remember_period = false
  180 +
  181 + # Options to be passed to the created cookie. For instance, you can set
  182 + # secure: true in order to force SSL only cookies.
  183 + # config.rememberable_options = {}
  184 +
  185 + # ==> Configuration for :validatable
  186 + # Range for password length.
  187 + config.password_length = 6..128
  188 +
  189 + # Email regex used to validate email formats. It simply asserts that
  190 + # one (and only one) @ exists in the given string. This is mainly
  191 + # to give user feedback and not to assert the e-mail validity.
  192 + config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
  193 +
  194 + # ==> Configuration for :timeoutable
  195 + # The time you want to timeout the user session without activity. After this
  196 + # time the user will be asked for credentials again. Default is 30 minutes.
  197 + # config.timeout_in = 30.minutes
  198 +
  199 + # ==> Configuration for :lockable
  200 + # Defines which strategy will be used to lock an account.
  201 + # :failed_attempts = Locks an account after a number of failed attempts to sign in.
  202 + # :none = No lock strategy. You should handle locking by yourself.
  203 + # config.lock_strategy = :failed_attempts
  204 +
  205 + # Defines which key will be used when locking and unlocking an account
  206 + # config.unlock_keys = [:email]
  207 +
  208 + # Defines which strategy will be used to unlock an account.
  209 + # :email = Sends an unlock link to the user email
  210 + # :time = Re-enables login after a certain amount of time (see :unlock_in below)
  211 + # :both = Enables both strategies
  212 + # :none = No unlock strategy. You should handle unlocking by yourself.
  213 + # config.unlock_strategy = :both
  214 +
  215 + # Number of authentication tries before locking an account if lock_strategy
  216 + # is failed attempts.
  217 + # config.maximum_attempts = 20
  218 +
  219 + # Time interval to unlock the account if :time is enabled as unlock_strategy.
  220 + # config.unlock_in = 1.hour
  221 +
  222 + # Warn on the last attempt before the account is locked.
  223 + # config.last_attempt_warning = true
  224 +
  225 + # ==> Configuration for :recoverable
  226 + #
  227 + # Defines which key will be used when recovering the password for an account
  228 + # config.reset_password_keys = [:email]
  229 +
  230 + # Time interval you can reset your password with a reset password key.
  231 + # Don't put a too small interval or your users won't have the time to
  232 + # change their passwords.
  233 + config.reset_password_within = 6.hours
  234 +
  235 + # When set to false, does not sign a user in automatically after their password is
  236 + # reset. Defaults to true, so a user is signed in automatically after a reset.
  237 + # config.sign_in_after_reset_password = true
  238 +
  239 + # ==> Configuration for :encryptable
  240 + # Allow you to use another hashing or encryption algorithm besides bcrypt (default).
  241 + # You can use :sha1, :sha512 or algorithms from others authentication tools as
  242 + # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
  243 + # for default behavior) and :restful_authentication_sha1 (then you should set
  244 + # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
  245 + #
  246 + # Require the `devise-encryptable` gem when using anything other than bcrypt
  247 + # config.encryptor = :sha512
  248 +
  249 + # ==> Scopes configuration
  250 + # Turn scoped views on. Before rendering "sessions/new", it will first check for
  251 + # "users/sessions/new". It's turned off by default because it's slower if you
  252 + # are using only default views.
  253 + # config.scoped_views = false
  254 +
  255 + # Configure the default scope given to Warden. By default it's the first
  256 + # devise role declared in your routes (usually :user).
  257 + # config.default_scope = :user
  258 +
  259 + # Set this configuration to false if you want /users/sign_out to sign out
  260 + # only the current scope. By default, Devise signs out all scopes.
  261 + # config.sign_out_all_scopes = true
  262 +
  263 + # ==> Navigation configuration
  264 + # Lists the formats that should be treated as navigational. Formats like
  265 + # :html, should redirect to the sign in page when the user does not have
  266 + # access, but formats like :xml or :json, should return 401.
  267 + #
  268 + # If you have any extra navigational formats, like :iphone or :mobile, you
  269 + # should add them to the navigational formats lists.
  270 + #
  271 + # The "*/*" below is required to match Internet Explorer requests.
  272 + # config.navigational_formats = ['*/*', :html]
  273 +
  274 + # The default HTTP method used to sign out a resource. Default is :delete.
  275 + config.sign_out_via = :delete
  276 +
  277 + # ==> OmniAuth
  278 + # Add a new OmniAuth provider. Check the wiki for more information on setting
  279 + # up on your models and hooks.
  280 + # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
  281 +
  282 + # ==> Warden configuration
  283 + # If you want to use other strategies, that are not supported by Devise, or
  284 + # change the failure app, you can configure them inside the config.warden block.
  285 + #
  286 + # config.warden do |manager|
  287 + # manager.intercept_401 = false
  288 + # manager.default_strategies(scope: :user).unshift :some_external_strategy
  289 + # end
  290 +
  291 + # ==> Mountable engine configurations
  292 + # When using Devise inside an engine, let's call it `MyEngine`, and this engine
  293 + # is mountable, there are some extra configurations to be taken into account.
  294 + # The following options are available, assuming the engine is mounted as:
  295 + #
  296 + # mount MyEngine, at: '/my_engine'
  297 + #
  298 + # The router that invoked `devise_for`, in the example above, would be:
  299 + # config.router_name = :my_engine
  300 + #
  301 + # When using OmniAuth, Devise cannot automatically set OmniAuth path,
  302 + # so you need to do it manually. For the users scope, it would be:
  303 + # config.omniauth_path_prefix = '/my_engine/users/auth'
  304 +
  305 + # ==> Turbolinks configuration
  306 + # If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly:
  307 + #
  308 + # ActiveSupport.on_load(:devise_failure_app) do
  309 + # include Turbolinks::Controller
  310 + # end
  311 +
  312 + # ==> Configuration for :registerable
  313 +
  314 + # When set to false, does not sign a user in automatically after their password is
  315 + # changed. Defaults to true, so a user is signed in automatically after changing a password.
  316 + # config.sign_in_after_change_password = true
  317 +end
... ...
  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 %{authentication_keys} 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:"
... ...
1 1 # frozen_string_literal: true
2 2
  3 +# frozen_string_literal: true
  4 +
3 5 Rails.application.routes.draw do
  6 + devise_for :users,
  7 + path_names: {
  8 + registration: 'signup'
  9 + },
  10 + controllers: {
  11 + registrations: 'v1/registrations'
  12 + }
4 13 # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
5 14 end
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +# frozen_string_literal: true
  4 +
  5 +class DeviseCreateUsers < ActiveRecord::Migration[6.1] # rubocop:todo Style/Documentation
  6 + def change
  7 + create_table :users do |t|
  8 + ## Database authenticatable
  9 + t.string :email, null: false, default: ''
  10 + t.string :encrypted_password, null: false, default: ''
  11 +
  12 + ## Recoverable
  13 + t.string :reset_password_token
  14 + t.datetime :reset_password_sent_at
  15 +
  16 + ## Rememberable
  17 + t.datetime :remember_created_at
  18 +
  19 + ## Trackable
  20 + # t.integer :sign_in_count, default: 0, null: false
  21 + # t.datetime :current_sign_in_at
  22 + # t.datetime :last_sign_in_at
  23 + # t.string :current_sign_in_ip
  24 + # t.string :last_sign_in_ip
  25 +
  26 + ## Confirmable
  27 + # t.string :confirmation_token
  28 + # t.datetime :confirmed_at
  29 + # t.datetime :confirmation_sent_at
  30 + # t.string :unconfirmed_email # Only if using reconfirmable
  31 +
  32 + ## Lockable
  33 + # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
  34 + # t.string :unlock_token # Only if unlock strategy is :email or :both
  35 + # t.datetime :locked_at
  36 +
  37 + t.timestamps null: false
  38 + end
  39 +
  40 + add_index :users, :email, unique: true
  41 + add_index :users, :reset_password_token, unique: true
  42 + # add_index :users, :confirmation_token, unique: true
  43 + # add_index :users, :unlock_token, unique: true
  44 + end
  45 +end
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +# This file is auto-generated from the current state of the database. Instead
  4 +# of editing this file, please use the migrations feature of Active Record to
  5 +# incrementally modify your database, and then regenerate this schema definition.
  6 +#
  7 +# This file is the source Rails uses to define your schema when running `bin/rails
  8 +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
  9 +# be faster and is potentially less error prone than running all of your
  10 +# migrations from scratch. Old migrations may fail to apply correctly if those
  11 +# migrations use external dependencies or application code.
  12 +#
  13 +# It's strongly recommended that you check this file into your version control system.
  14 +
  15 +ActiveRecord::Schema.define(version: 20_210_802_021_826) do
  16 + create_table 'users', charset: 'utf8mb4', collation: 'utf8mb4_0900_ai_ci', force: :cascade do |t|
  17 + t.string 'email', default: '', null: false
  18 + t.string 'encrypted_password', default: '', null: false
  19 + t.string 'reset_password_token'
  20 + t.datetime 'reset_password_sent_at'
  21 + t.datetime 'remember_created_at'
  22 + t.datetime 'created_at', precision: 6, null: false
  23 + t.datetime 'updated_at', precision: 6, null: false
  24 + t.index ['email'], name: 'index_users_on_email', unique: true
  25 + t.index ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true
  26 + end
  27 +end
... ...
  1 +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
  2 +
  3 +# This model initially had no columns defined. If you add columns to the
  4 +# model remove the '{}' from the fixture names and add the columns immediately
  5 +# below each fixture, per the syntax in the comments below
  6 +#
  7 +one: {}
  8 +# column: value
  9 +#
  10 +two: {}
  11 +# column: value
... ...
  1 +# frozen_string_literal: true
  2 +
  3 +require 'test_helper'
  4 +
  5 +class UserTest < ActiveSupport::TestCase
  6 + # test "the truth" do
  7 + # assert true
  8 + # end
  9 +end
... ...