class JwtApi::SetupGenerator
Public Instance Methods
add_api_namespace_to_routes()
click to toggle source
# File lib/generators/jwt_api/setup_generator.rb, line 15 def add_api_namespace_to_routes routes = 'config/routes.rb' inject_into_file routes, after: 'Rails.application.routes.draw do' do # TODO: this is ugly, there has to be a better way to do this "\n\n# API routes namespace :api, defaults: { format: :json } do namespace :v1 do # Auth post 'auth' => 'authentication#authenticate_user' delete 'auth' => 'authentication#logout' # Users resource :users get 'me' => 'users#me' # User Password Reset Flow post 'passwords/reset' => 'passwords#reset_password_instructions' get 'passwords/verify' => 'passwords#verify' post 'passwords/update' => 'passwords#update_password' end end\n\n" end end
copy_api_controllers()
click to toggle source
# File lib/generators/jwt_api/setup_generator.rb, line 11 def copy_api_controllers directory 'templates/api', 'app/controllers/api' end
copy_jwt_class()
click to toggle source
# File lib/generators/jwt_api/setup_generator.rb, line 49 def copy_jwt_class copy_file 'templates/initializers/json_web_token.rb', 'config/initializers/json_web_token.rb' end
copy_password_reset_mailer()
click to toggle source
# File lib/generators/jwt_api/setup_generator.rb, line 41 def copy_password_reset_mailer copy_file 'templates/mailers/jwt_mailer.rb', 'app/mailers/jwt_mailer.rb' end
copy_password_reset_views()
click to toggle source
# File lib/generators/jwt_api/setup_generator.rb, line 45 def copy_password_reset_views directory 'templates/views/jwt_mailer', 'app/views/jwt_mailer' end
copy_user_views()
click to toggle source
# File lib/generators/jwt_api/setup_generator.rb, line 37 def copy_user_views directory 'templates/views/users', 'app/views/users' end
generate_jti_migration()
click to toggle source
# File lib/generators/jwt_api/setup_generator.rb, line 53 def generate_jti_migration generate 'migration', 'add_jti_to_users', 'jti:string:uniq:index' end
run_migration()
click to toggle source
# File lib/generators/jwt_api/setup_generator.rb, line 57 def run_migration rake 'db:migrate' end
source_paths()
click to toggle source
# File lib/generators/jwt_api/setup_generator.rb, line 7 def source_paths [__dir__] end