├── log └── .keep ├── tmp └── .keep ├── vendor └── .keep ├── lib ├── assets │ └── .keep └── tasks │ └── .keep ├── public ├── favicon.ico ├── apple-touch-icon.png ├── apple-touch-icon-precomposed.png ├── robots.txt ├── 500.html ├── 422.html └── 404.html ├── test ├── helpers │ └── .keep ├── mailers │ └── .keep ├── models │ └── .keep ├── system │ └── .keep ├── controllers │ └── .keep ├── fixtures │ ├── .keep │ └── files │ │ └── .keep ├── integration │ └── .keep ├── application_system_test_case.rb └── test_helper.rb ├── app ├── assets │ ├── images │ │ └── .keep │ ├── javascripts │ │ ├── channels │ │ │ └── .keep │ │ ├── cable.js │ │ ├── admin │ │ │ └── custom_admin.js │ │ ├── application.js │ │ └── admin.js │ ├── config │ │ └── manifest.js │ └── stylesheets │ │ ├── application.scss │ │ ├── admin.scss │ │ └── admin │ │ └── sb-admin.min.css ├── models │ ├── concerns │ │ └── .keep │ ├── application_record.rb │ ├── admin.rb │ ├── access_token.rb │ └── user.rb ├── controllers │ ├── concerns │ │ └── .keep │ ├── home_controller.rb │ ├── users_controller.rb │ ├── admin │ │ ├── base_controller.rb │ │ ├── dashboard_controller.rb │ │ └── admins_controller.rb │ ├── api │ │ ├── v1 │ │ │ ├── helpers │ │ │ │ └── authentication_helpers.rb │ │ │ ├── base.rb │ │ │ └── users.rb │ │ ├── v2 │ │ │ ├── helpers │ │ │ │ └── authentication_helpers.rb │ │ │ ├── users.rb │ │ │ └── base.rb │ │ ├── base.rb │ │ └── defaults.rb │ └── application_controller.rb ├── views │ ├── layouts │ │ ├── mailer.text.haml │ │ ├── mailer.html.haml │ │ ├── admin │ │ │ ├── _footer.html.haml │ │ │ ├── _logout_modal.html.haml │ │ │ └── _navigation.html.haml │ │ ├── application.html.haml │ │ ├── _meta_tags.html.haml │ │ └── admin.html.haml │ ├── api │ │ └── users │ │ │ ├── get_user.json.jbuilder │ │ │ └── _details.json.jbuilder │ ├── home │ │ └── index.html.haml │ ├── users │ │ └── show.html.haml │ └── admin │ │ ├── dashboard │ │ ├── _card.html.haml │ │ └── index.html.haml │ │ ├── sessions │ │ └── new.html.haml │ │ └── admins │ │ └── change_password.html.haml ├── jobs │ └── application_job.rb ├── lib │ └── constant.rb ├── channels │ └── application_cable │ │ ├── channel.rb │ │ └── connection.rb ├── mailers │ └── application_mailer.rb ├── serializers │ └── user_serializer.rb └── helpers │ ├── application_helper.rb │ ├── meta_tags_helper.rb │ └── flash_helper.rb ├── .ruby-version ├── _config.yml ├── package.json ├── bin ├── bundle ├── rake ├── rails ├── yarn ├── spring ├── update └── setup ├── config ├── initializers │ ├── default_meta.rb │ ├── swagger.rb │ ├── mime_types.rb │ ├── filter_parameter_logging.rb │ ├── application_controller_renderer.rb │ ├── cookies_serializer.rb │ ├── backtrace_silencers.rb │ ├── wrap_parameters.rb │ ├── assets.rb │ ├── inflections.rb │ ├── content_security_policy.rb │ └── devise.rb ├── spring.rb ├── environment.rb ├── meta.yml ├── boot.rb ├── cable.yml ├── routes.rb ├── credentials.yml.enc ├── database.yml ├── database.yml.example ├── application.rb ├── locales │ ├── en.yml │ └── devise.en.yml ├── storage.yml ├── puma.rb └── environments │ ├── test.rb │ ├── development.rb │ └── production.rb ├── Rakefile ├── config.ru ├── db ├── migrate │ ├── 20180424083654_create_access_tokens.rb │ ├── 20190218131410_devise_create_admins.rb │ └── 20180424071905_devise_create_users.rb ├── seeds.rb └── schema.rb ├── .gitignore ├── Gemfile ├── README.md └── Gemfile.lock /log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tmp/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/system/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fixtures/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/apple-touch-icon.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fixtures/files/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | 2.6.3@ror_plus 2 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/assets/javascripts/channels/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman 2 | -------------------------------------------------------------------------------- /public/apple-touch-icon-precomposed.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.text.haml: -------------------------------------------------------------------------------- 1 | = yield 2 | -------------------------------------------------------------------------------- /app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | end 3 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "RorPlus", 3 | "private": true, 4 | "dependencies": {} 5 | } 6 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | -------------------------------------------------------------------------------- /app/views/api/users/get_user.json.jbuilder: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | json.partial! 'users/details', user: @user 4 | -------------------------------------------------------------------------------- /app/lib/constant.rb: -------------------------------------------------------------------------------- 1 | module Constant 2 | TOKEN_EXPIRY_IN_DAYS = 7 3 | AUTH_DESCRIPTION = 'Authorization key'.freeze 4 | end 5 | -------------------------------------------------------------------------------- /app/channels/application_cable/channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Channel < ActionCable::Channel::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/views/home/index.html.haml: -------------------------------------------------------------------------------- 1 | - if current_user.blank? 2 | = link_to 'User Login', new_user_session_path, class: 'btn btn-success' 3 | -------------------------------------------------------------------------------- /app/views/users/show.html.haml: -------------------------------------------------------------------------------- 1 | = 'Hi User' 2 | = link_to 'Logout', destroy_user_session_path, class: 'btn btn-danger', method: :delete 3 | -------------------------------------------------------------------------------- /app/assets/config/manifest.js: -------------------------------------------------------------------------------- 1 | //= link_tree ../images 2 | //= link_directory ../javascripts .js 3 | //= link_directory ../stylesheets .css 4 | -------------------------------------------------------------------------------- /app/channels/application_cable/connection.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Connection < ActionCable::Connection::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /config/initializers/default_meta.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | DEFAULT_META = YAML.load_file(Rails.root.join('config/meta.yml')) 4 | -------------------------------------------------------------------------------- /app/controllers/home_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class HomeController < ApplicationController 4 | def index; end 5 | end 6 | -------------------------------------------------------------------------------- /app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: 'from@example.com' 3 | layout 'mailer' 4 | end 5 | -------------------------------------------------------------------------------- /config/spring.rb: -------------------------------------------------------------------------------- 1 | %w[ 2 | .ruby-version 3 | .rbenv-vars 4 | tmp/restart.txt 5 | tmp/caching-dev.txt 6 | ].each { |path| Spring.watch(path) } 7 | -------------------------------------------------------------------------------- /app/views/api/users/_details.json.jbuilder: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | json.user do 4 | json.call(user, :id, :email, :first_name) 5 | end 6 | -------------------------------------------------------------------------------- /app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class ApplicationRecord < ActiveRecord::Base 4 | self.abstract_class = true 5 | end 6 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative 'application' 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /app/controllers/users_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class UsersController < ApplicationController 4 | before_action :authenticate_user! 5 | 6 | def show; end 7 | end 8 | -------------------------------------------------------------------------------- /config/initializers/swagger.rb: -------------------------------------------------------------------------------- 1 | GrapeSwaggerRails.options.url = '/api/api_docs.json' 2 | GrapeSwaggerRails.options.app_name = 'RorPlus' 3 | GrapeSwaggerRails.options.app_url = $secret[:base_url] 4 | -------------------------------------------------------------------------------- /app/controllers/admin/base_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Admin::BaseController < ApplicationController 4 | before_action :authenticate_admin! 5 | layout 'admin' 6 | end 7 | -------------------------------------------------------------------------------- /app/serializers/user_serializer.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class UserSerializer 4 | include FastJsonapi::ObjectSerializer 5 | attributes :id, :email, :first_name, :last_name 6 | end 7 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /test/application_system_test_case.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | class ApplicationSystemTestCase < ActionDispatch::SystemTestCase 4 | driven_by :selenium, using: :chrome, screen_size: [1400, 1400] 5 | end 6 | -------------------------------------------------------------------------------- /config/meta.yml: -------------------------------------------------------------------------------- 1 | meta_title: "RoR Plus" 2 | meta_description: "Production ready boilerplate for RoR web application, Rails boilerplate" 3 | meta_image: "https://drive.google.com/uc?id=1HAGX3lPk2W46XrMcg0vpdUB5ejmpa-bC" 4 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.html.haml: -------------------------------------------------------------------------------- 1 | !!! 2 | %html 3 | %head 4 | %meta{content: 'text/html; charset=UTF-8', 'http-equiv': 'Content-Type'} 5 | :css 6 | /* Email styles need to be inline */ 7 | %body 8 | = yield 9 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | require 'bootsnap/setup' # Speed up boot time by caching expensive operations. 5 | -------------------------------------------------------------------------------- /app/views/layouts/admin/_footer.html.haml: -------------------------------------------------------------------------------- 1 | %footer.sticky-footer 2 | .container 3 | .text-center 4 | %small 5 | Copyright © 6 | / Scroll to Top Button 7 | %a.scroll-to-top.rounded{:href => '#page-top'} 8 | %i.fa.fa-angle-up 9 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module ApplicationHelper 4 | def show_error(object, attribute_name) 5 | object.errors.full_messages_for(attribute_name).join(',') if object.errors.any? 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: async 6 | 7 | production: 8 | adapter: redis 9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> 10 | channel_prefix: RoRPlus_production 11 | -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require_relative 'config/application' 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /app/controllers/admin/dashboard_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Admin::DashboardController < Admin::BaseController 4 | before_action :authenticate_admin! 5 | 6 | def index 7 | @users = User.all 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | require_relative '../config/boot' 8 | require 'rake' 9 | Rake.application.run 10 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative 'config/environment' 4 | 5 | use Rack::Config do |env| 6 | env['api.tilt.root'] = "#{Rails.root}/app/views/api/" 7 | end 8 | 9 | run Rails.application 10 | -------------------------------------------------------------------------------- /config/initializers/application_controller_renderer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # ActiveSupport::Reloader.to_prepare do 4 | # ApplicationController.renderer.defaults.merge!( 5 | # http_host: 'example.org', 6 | # https: false 7 | # ) 8 | # end 9 | -------------------------------------------------------------------------------- /config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Specify a serializer for the signed and encrypted cookie jars. 4 | # Valid options are :json, :marshal, and :hybrid. 5 | Rails.application.config.action_dispatch.cookies_serializer = :json 6 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | APP_PATH = File.expand_path('../config/application', __dir__) 8 | require_relative '../config/boot' 9 | require 'rails/commands' 10 | -------------------------------------------------------------------------------- /app/models/admin.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Admin < ApplicationRecord 4 | # Include default devise modules. Others available are: 5 | # :confirmable, :lockable, :timeoutable and :omniauthable 6 | devise :database_authenticatable, :registerable, 7 | :recoverable, :rememberable, :trackable, :validatable 8 | end 9 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV['RAILS_ENV'] ||= 'test' 2 | require_relative '../config/environment' 3 | require 'rails/test_help' 4 | 5 | class ActiveSupport::TestCase 6 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. 7 | fixtures :all 8 | 9 | # Add more helper methods to be used by all tests here... 10 | end 11 | -------------------------------------------------------------------------------- /bin/yarn: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_ROOT = File.expand_path('..', __dir__) 3 | Dir.chdir(APP_ROOT) do 4 | begin 5 | exec "yarnpkg", *ARGV 6 | rescue Errno::ENOENT 7 | $stderr.puts "Yarn executable was not detected in the system." 8 | $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" 9 | exit 1 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /app/controllers/api/v1/helpers/authentication_helpers.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module API::V1::Helpers::AuthenticationHelpers 4 | extend Grape::API::Helpers 5 | 6 | params :authentication_params do 7 | requires :user, type: Hash do 8 | requires :access_token, type: String, desc: 'Access Token' 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /app/controllers/api/v2/helpers/authentication_helpers.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module API::V2::Helpers::AuthenticationHelpers 4 | extend Grape::API::Helpers 5 | 6 | params :authentication_params do 7 | requires :user, type: Hash do 8 | requires :access_token, type: String, desc: 'Access Token' 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/migrate/20180424083654_create_access_tokens.rb: -------------------------------------------------------------------------------- 1 | class CreateAccessTokens < ActiveRecord::Migration[5.2] 2 | def change 3 | create_table :access_tokens do |t| 4 | t.string :token, null: false 5 | t.boolean :active, null: false, default: true 6 | t.integer :user_id, null: false 7 | 8 | t.timestamps 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) 7 | # Character.create(name: 'Luke', movie: movies.first) 8 | -------------------------------------------------------------------------------- /app/assets/javascripts/cable.js: -------------------------------------------------------------------------------- 1 | // Action Cable provides the framework to deal with WebSockets in Rails. 2 | // You can generate new channels where WebSocket features live using the `rails generate channel` command. 3 | // 4 | //= require action_cable 5 | //= require_self 6 | //= require_tree ./channels 7 | 8 | (function() { 9 | this.App || (this.App = {}); 10 | 11 | App.cable = ActionCable.createConsumer(); 12 | 13 | }).call(this); 14 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class ApplicationController < ActionController::Base 4 | def after_sign_in_path_for(_resource_or_scope) 5 | current_user.present? ? user_path(current_user) : admin_dashboard_index_path 6 | end 7 | 8 | def after_sign_out_path_for(resource_or_scope) 9 | resource_or_scope.to_s == 'user' ? new_user_session_path : new_admin_session_path 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.haml: -------------------------------------------------------------------------------- 1 | !!! 2 | %html 3 | %head 4 | %meta{content: 'text/html; charset=UTF-8', 'http-equiv': 'Content-Type'} 5 | = render 'layouts/meta_tags' 6 | %title RorPlus 7 | = csrf_meta_tags 8 | = csp_meta_tag 9 | = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' 10 | = javascript_include_tag 'application', 'data-turbolinks-track': 'reload' 11 | %body 12 | = yield 13 | -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /app/views/admin/dashboard/_card.html.haml: -------------------------------------------------------------------------------- 1 | .row 2 | .col-xl-3.col-sm-6.mb-3 3 | .card.text-white.bg-primary.o-hidden.h-100 4 | .card-body 5 | .card-body-icon 6 | %i.fa.fa-fw.fa-user 7 | .mr-5 8 | = User.count 9 | User 10 | = link_to "javascript:void(0)", {class: 'card-footer text-white clearfix small z-1'} do 11 | %span.float-left View Details 12 | %span.float-right 13 | %i.fa.fa-angle-right 14 | -------------------------------------------------------------------------------- /app/helpers/meta_tags_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MetaTagsHelper 4 | def meta_title 5 | content_for(:meta_title) || DEFAULT_META['meta_title'] 6 | end 7 | 8 | def meta_description 9 | content_for(:meta_description) || DEFAULT_META['meta_description'] 10 | end 11 | 12 | def meta_image 13 | meta_image = content_for(:meta_image) || DEFAULT_META['meta_image'] 14 | meta_image.starts_with?('http') ? meta_image : image_url(meta_image) 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/controllers/api/base.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module API 4 | class Base < Grape::API 5 | mount API::V1::Base 6 | mount API::V2::Base 7 | 8 | add_swagger_documentation mount_path: '/api_docs', 9 | api_version: 'v1', 10 | info: { 11 | title: "RorPlus API's", 12 | description: "API's available for RorPlus users" 13 | } 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | Rails.application.routes.draw do 4 | devise_for :admin 5 | root 'home#index' 6 | 7 | devise_for :users 8 | 9 | mount API::Base => '/api' 10 | mount GrapeSwaggerRails::Engine => '/swagger' 11 | 12 | resources :users, only: [:show] 13 | 14 | namespace :admin do 15 | resources :dashboard, only: [:index] 16 | resources :admins, only: [], path: '' do 17 | get :change_password 18 | patch :update_password 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /app/assets/javascripts/admin/custom_admin.js: -------------------------------------------------------------------------------- 1 | $( document ).on('turbolinks:load', function() { 2 | $(".alert" ).fadeOut(7000); 3 | $("#sidenavToggler").click(function(e) { 4 | e.preventDefault(); 5 | $("body").toggleClass("sidenav-toggled"); 6 | $(".navbar-sidenav .nav-link-collapse").addClass("collapsed"); 7 | $(".navbar-sidenav .sidenav-second-level, .navbar-sidenav .sidenav-third-level").removeClass("show"); 8 | }); 9 | $(".form-control").on("change",function(){ 10 | $(this.closest(".form-group")).find(".server-validation").hide() 11 | }) 12 | }); 13 | -------------------------------------------------------------------------------- /app/models/access_token.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AccessToken < ApplicationRecord 4 | # Associations 5 | belongs_to :user 6 | 7 | before_create :generate_token 8 | 9 | private 10 | 11 | def generate_token 12 | begin 13 | exp = Time.zone.now.to_i + Constant::TOKEN_EXPIRY_IN_DAYS.days.to_i 14 | exp_payload = { data: 'ror-plus-api', exp: exp } 15 | token = JWT.encode exp_payload, $secret[:api_hmac_secret], 'HS256' 16 | self.token = token 17 | end while self.class.exists?(token: token) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] 9 | end 10 | 11 | # To enable root element in JSON for ActiveRecord objects. 12 | # ActiveSupport.on_load(:active_record) do 13 | # self.include_root_in_json = true 14 | # end 15 | -------------------------------------------------------------------------------- /bin/spring: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # This file loads spring without using Bundler, in order to be fast. 4 | # It gets overwritten when you run the `spring binstub` command. 5 | 6 | unless defined?(Spring) 7 | require 'rubygems' 8 | require 'bundler' 9 | 10 | lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) 11 | spring = lockfile.specs.detect { |spec| spec.name == "spring" } 12 | if spring 13 | Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path 14 | gem 'spring', spring.version 15 | require 'spring/binstub' 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /app/models/user.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class User < ApplicationRecord 4 | # Include default devise modules. Others available are: 5 | # :confirmable, :lockable, :timeoutable and :omniauthable 6 | devise :database_authenticatable, :registerable, 7 | :recoverable, :rememberable, :trackable, :validatable 8 | 9 | # Associations 10 | has_many :access_tokens, dependent: :destroy 11 | 12 | def generate_access_token 13 | access_tokens.create 14 | end 15 | 16 | def new_access_token 17 | access_tokens.destroy_all 18 | generate_access_token 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /config/credentials.yml.enc: -------------------------------------------------------------------------------- 1 | Pjvv9q//ASONxhPjqm+4J2YjhGJeLVkKSaVyZVBLZeb88HlNtsFEHpLT5fT+Fh6YPG4bF2HmOCfq5D2x3Im+7S+WxbqL3xn7ykGwccu9kSccoB0wemt0VT0yagOAbXVPNcRStR6wA3oXCGws39gwOTID9zdtOvxJ3EefdbmR3DyPTIA3J7WGEDTKePxeG+8Ufa4Hr803j9UZgeSNcVwEC38QG3SrfxBjUvS31CWcl0a5W7m1AWd9JWrRIpd1os78SzCcQMkXTKBDKqayYuFjaP+P8yhF0u1NA+XiP/9pYP3OdtOEbiF/6KlXO805UkUjT1ImCiHhZIsuKS5YGs15IOpFuS0WI6T4GSUUA926IGP027NUOTJanTnmSYTTVV3S+FaIUo2LBx9uCHnrSyOlhoh/lU5qhS4XDyidfUxb0uEuwzfZicZdyiwIvh0e9LaiIbw3oK9u54MmgLn84I9M9mW5jer21TgjIoJVzFdIaV7v4zrxWRNE9fcxeHcXqaPFO+UVbpiu9t8Xazy7nCZy8FqH9yjWk+zRseLSZG57H5CndnWWAh78686ylaEbYuo3vmUYDEhnOY2hlw+jPaRsIh0+fc2Wz7Co--6d0mYnLji3uKPvXA--9bHhDkkK0qrqpe1st+PRIg== -------------------------------------------------------------------------------- /app/controllers/api/v2/users.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module API 4 | module V2 5 | class Users < API::V2::Base 6 | include API::Defaults 7 | 8 | resource :users do 9 | desc 'Get a user', 10 | headers: { 11 | 'Authorization' => { description: Constant::AUTH_DESCRIPTION, required: true } 12 | } 13 | params do 14 | use :authentication_params 15 | end 16 | get ':id' do 17 | authenticate! 18 | user = User.find(params[:id]) 19 | respond(200, UserSerializer.new(user).serializable_hash) 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Version of your assets, change this if you want to expire all your assets. 4 | Rails.application.config.assets.version = '1.0' 5 | 6 | # Add additional assets to the asset load path. 7 | # Rails.application.config.assets.paths << Emoji.images_path 8 | # Add Yarn node_modules folder to the asset load path. 9 | Rails.application.config.assets.paths << Rails.root.join('node_modules') 10 | 11 | # Precompile additional assets. 12 | # application.js, application.css, and all non-JS/CSS in the app/assets 13 | # folder are already added. 14 | Rails.application.config.assets.precompile += %w( admin.js admin.css ) 15 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | default: &default 2 | adapter: postgresql 3 | host: localhost 4 | encoding: utf8 5 | username: postgres # Change it to your username 6 | password: postgres # Change it to your password 7 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 8 | timeout: 5000 9 | 10 | development: 11 | <<: *default 12 | database: ror_plus_development 13 | 14 | # Warning: The database defined as "test" will be erased and 15 | # re-generated from your development database when you run "rake". 16 | # Do not set this db to the same as development or production. 17 | test: 18 | <<: *default 19 | database: ror_plus_test 20 | 21 | production: 22 | <<: *default 23 | database: ror_plus_production 24 | -------------------------------------------------------------------------------- /config/database.yml.example: -------------------------------------------------------------------------------- 1 | default: &default 2 | adapter: postgresql 3 | host: localhost 4 | encoding: utf8 5 | username: postgres # Change it to your username 6 | password: 123456 # Change it to your password 7 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 8 | timeout: 5000 9 | 10 | development: 11 | <<: *default 12 | database: ror_plus_development 13 | 14 | # Warning: The database defined as "test" will be erased and 15 | # re-generated from your development database when you run "rake". 16 | # Do not set this db to the same as development or production. 17 | test: 18 | <<: *default 19 | database: ror_plus_test 20 | 21 | production: 22 | <<: *default 23 | database: ror_plus_production 24 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /app/views/layouts/admin/_logout_modal.html.haml: -------------------------------------------------------------------------------- 1 | #logoutModal.modal.fade{'aria-hidden' => 'true', 'aria-labelledby' => 'exampleModalLabel', role: 'dialog', tabindex: '-1'} 2 | .modal-dialog{:role => 'document'} 3 | .modal-content 4 | .modal-header 5 | %h5#exampleModalLabel.modal-title 6 | = I18n.t('admin.navigation.logout_title') 7 | %button.close{'aria-label' => 'Close', 'data-dismiss' => 'modal', type: 'button'} 8 | %span{'aria-hidden' => 'true'} × 9 | .modal-body 10 | = I18n.t('admin.navigation.logout_message') 11 | .modal-footer 12 | %button.btn.btn-secondary{'data-dismiss' => 'modal', type: 'button'} Cancel 13 | = link_to 'Logout', destroy_admin_session_path ,{class: 'btn btn-primary', method: 'delete'} 14 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's 6 | * vendor/assets/stylesheets directory can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS 10 | * files in this directory. Styles in this file should be added after the last require_* statement. 11 | * It is generally better to create a new file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | @import "bootstrap"; 17 | -------------------------------------------------------------------------------- /app/views/layouts/_meta_tags.html.haml: -------------------------------------------------------------------------------- 1 | %title= meta_title 2 | 3 | %meta{name: 'description', content: "#{meta_description}"} 4 | 5 | / Facebook Open Graph data 6 | %meta{property: 'og:title', content: "#{meta_title}"} 7 | %meta{property: 'og:type', content: 'website'} 8 | %meta{property: 'og:url', content: "#{request.original_url}"} 9 | %meta{property: 'og:image', content: "#{meta_image}"} 10 | %meta{property: 'og:description', content: "#{meta_description}"} 11 | %meta{property: 'og:site_name', content: "#{meta_title}"} 12 | 13 | / Twitter Card data 14 | %meta{property: 'twitter:card', content: 'summary_large_image'} 15 | %meta{property: 'twitter:title', content: "#{meta_title}"} 16 | %meta{property: 'twitter:description', content: "#{meta_description}"} 17 | %meta{property: 'twitter:image:src', content: "#{meta_image}"} 18 | -------------------------------------------------------------------------------- /app/assets/stylesheets/admin.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's 6 | * vendor/assets/stylesheets directory can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS 10 | * files in this directory. Styles in this file should be added after the last require_* statement. 11 | * It is generally better to create a new file per style scope. 12 | * 13 | *= require_tree ./admin/ 14 | *= require_self 15 | 16 | */ 17 | @import "bootstrap"; 18 | @import "font-awesome"; 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore the default SQLite database. 11 | /db/*.sqlite3 12 | /db/*.sqlite3-journal 13 | 14 | # Ignore all logfiles and tempfiles. 15 | /log/* 16 | /tmp/* 17 | !/log/.keep 18 | !/tmp/.keep 19 | 20 | # Ignore uploaded files in development 21 | /storage/* 22 | 23 | /node_modules 24 | /yarn-error.log 25 | 26 | /public/assets 27 | .byebug_history 28 | 29 | # Ignore master key for decrypting credentials and more. 30 | /config/master.key 31 | /config/database.yml 32 | .scannerwork 33 | .rubocop.yml 34 | .vscode 35 | -------------------------------------------------------------------------------- /app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's 5 | // vendor/assets/javascripts directory can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // compiled file. JavaScript code in this file should be added after the last require_* statement. 9 | // 10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 11 | // about supported directives. 12 | // 13 | //= require rails-ujs 14 | //= require activestorage 15 | //= require turbolinks 16 | //= require jquery3 17 | //= require popper 18 | //= require bootstrap 19 | //= require_tree . 20 | -------------------------------------------------------------------------------- /app/views/admin/dashboard/index.html.haml: -------------------------------------------------------------------------------- 1 | .container-fluid 2 | / Breadcrumbs 3 | %ol.breadcrumb 4 | %li.breadcrumb-item 5 | %a{href: '#'} Admin 6 | %li.breadcrumb-item.active My Dashboard 7 | = render 'card' 8 | / Example DataTables Card 9 | .card.mb-3 10 | .card-header 11 | %i.fa.fa-table 12 | Active Users 13 | .card-body 14 | .table-responsive 15 | %table#dataTable.table.table-bordered{:cellspacing => '0', :width => '100%'} 16 | %thead 17 | %tr 18 | %th First Name 19 | %th Last Name 20 | %th Email 21 | %tbody 22 | - @users.each do |user| 23 | %tr 24 | %td 25 | = user.first_name 26 | %td 27 | = user.last_name 28 | %td 29 | = user.email 30 | -------------------------------------------------------------------------------- /app/assets/javascripts/admin.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's 5 | // vendor/assets/javascripts directory can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // compiled file. JavaScript code in this file should be added after the last require_* statement. 9 | // 10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 11 | // about supported directives. 12 | // 13 | //= require rails-ujs 14 | //= require activestorage 15 | //= require turbolinks 16 | //= require jquery3 17 | //= require popper 18 | //= require bootstrap 19 | //= require jquery_ujs 20 | //= require_tree ./admin -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative 'boot' 2 | 3 | require 'rails/all' 4 | 5 | # Require the gems listed in Gemfile, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(*Rails.groups) 8 | 9 | module RorPlus 10 | class Application < Rails::Application 11 | # Initialize configuration defaults for originally generated Rails version. 12 | config.load_defaults 5.2 13 | config.autoload_paths += %W[#{config.root}/lib] 14 | 15 | # Settings in config/environments/* take precedence over those specified here. 16 | # Application configuration can go into files in config/initializers 17 | # -- all .rb files in that directory are automatically loaded after loading 18 | # the framework and any gems in your application. 19 | config.before_initialize do 20 | $secret = eval("Rails.application.credentials.#{Rails.env}") 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /bin/update: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'fileutils' 3 | include FileUtils 4 | 5 | # path to your application root. 6 | APP_ROOT = File.expand_path('..', __dir__) 7 | 8 | def system!(*args) 9 | system(*args) || abort("\n== Command #{args} failed ==") 10 | end 11 | 12 | chdir APP_ROOT do 13 | # This script is a way to update your development environment automatically. 14 | # Add necessary update steps to this file. 15 | 16 | puts '== Installing dependencies ==' 17 | system! 'gem install bundler --conservative' 18 | system('bundle check') || system!('bundle install') 19 | 20 | # Install JavaScript dependencies if using Yarn 21 | # system('bin/yarn') 22 | 23 | puts "\n== Updating database ==" 24 | system! 'bin/rails db:migrate' 25 | 26 | puts "\n== Removing old logs and tempfiles ==" 27 | system! 'bin/rails log:clear tmp:clear' 28 | 29 | puts "\n== Restarting application server ==" 30 | system! 'bin/rails restart' 31 | end 32 | -------------------------------------------------------------------------------- /app/helpers/flash_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module FlashHelper 4 | ALERT_TYPES = %i[danger info success warning error].freeze unless const_defined?(:ALERT_TYPES) 5 | 6 | def bootstrap_flash 7 | flash_messages = [] 8 | flash.each do |type, message| 9 | # Skip empty messages, e.g. for devise messages set to nothing in a locale file. 10 | next if message.blank? 11 | 12 | type = type.to_sym 13 | type = :success if type == :notice 14 | type = :danger if %i[alert error].include?(type) 15 | next unless ALERT_TYPES.include?(type) 16 | 17 | Array(message).each do |msg| 18 | text = content_tag( 19 | :div, 20 | content_tag(:button, raw('×'), :class => 'close', 'data-dismiss' => 'alert') + 21 | msg.html_safe, class: "alert alert-#{type}" 22 | ) 23 | flash_messages << text if msg 24 | end 25 | end 26 | flash_messages.join("\n").html_safe 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /app/controllers/admin/admins_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Admin::AdminsController < Admin::BaseController 4 | before_action :set_admin 5 | 6 | def change_password; end 7 | 8 | def update_password 9 | if @admin.update_with_password(admin_params) 10 | flash[:notice] = 'Password successfully updated!' 11 | sign_in @admin, bypass: true 12 | redirect_to admin_dashboard_index_path 13 | else 14 | Rails.logger.debug("===========#{@admin.errors.full_messages.join(', ')}===========") 15 | flash[:error] = @admin.errors.full_messages.join(', ') 16 | redirect_back fallback_location: { action: 'change_password', id: @admin.id } 17 | end 18 | end 19 | 20 | private 21 | 22 | def admin_params 23 | params.require(:admin).permit(:current_password, :password, :password_confirmation) 24 | end 25 | 26 | def set_admin 27 | @admin = Admin.find_by_id(params[:admin_id]) 28 | return false if @admin.blank? 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /app/controllers/api/v1/base.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module API 4 | module V1 5 | class Base < API::Base 6 | formatter :json, Grape::Formatter::Jbuilder 7 | helpers API::V1::Helpers::AuthenticationHelpers 8 | 9 | rescue_from ActiveRecord::RecordNotFound do 10 | error!('Record not found.', 404) 11 | end 12 | 13 | rescue_from ActiveRecord::InvalidForeignKey do 14 | error!('Unprocessable entity.', 422) 15 | end 16 | 17 | rescue_from ArgumentError do |e| 18 | error!(e.message.remove("'"), 422) 19 | end 20 | 21 | before do 22 | error!('Unauthorized request.', 401) unless authorized 23 | end 24 | 25 | helpers do 26 | def authorized 27 | authorization_key = Base64.strict_decode64(request.headers['Authorization']) rescue nil 28 | authorization_key == "#{$secret[:api_client_id]}:#{$secret[:api_client_secret]}" 29 | end 30 | end 31 | 32 | version 'v1' 33 | 34 | mount API::V1::Users 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /app/controllers/api/v2/base.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module API 4 | module V2 5 | class Base < API::Base 6 | formatter :json, Grape::Formatter::Jbuilder 7 | helpers API::V1::Helpers::AuthenticationHelpers 8 | 9 | rescue_from ActiveRecord::RecordNotFound do 10 | error!('Record not found.', 404) 11 | end 12 | 13 | rescue_from ActiveRecord::InvalidForeignKey do 14 | error!('Unprocessable entity.', 422) 15 | end 16 | 17 | rescue_from ArgumentError do |e| 18 | error!(e.message.remove("'"), 422) 19 | end 20 | 21 | before do 22 | error!('Unauthorized request.', 401) unless authorized 23 | end 24 | 25 | helpers do 26 | def authorized 27 | authorization_key = Base64.strict_decode64(request.headers['Authorization']) rescue nil 28 | authorization_key == "#{$secret[:api_client_id]}:#{$secret[:api_client_secret]}" 29 | end 30 | end 31 | 32 | version 'v2' 33 | 34 | mount API::V2::Users 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /app/views/layouts/admin.html.haml: -------------------------------------------------------------------------------- 1 | !!! 2 | %html 3 | %head 4 | %meta{content: 'text/html; charset=UTF-8', 'http-equiv': 'Content-Type'} 5 | %meta{content: 'IE=edge', 'http-equiv': 'X-UA-Compatible'} 6 | %meta{content: 'width=device-width, initial-scale=1, shrink-to-fit=no', name: 'viewport'} 7 | = render 'layouts/meta_tags' 8 | = csrf_meta_tags 9 | = csp_meta_tag 10 | = stylesheet_link_tag 'admin', media: 'all', 'data-turbolinks-track': 'reload' 11 | = javascript_include_tag 'admin', 'data-turbolinks-track': 'reload' 12 | %link{href: 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css', rel: 'stylesheet'} 13 | %script{src: 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js'} 14 | %script{async: '', src: 'https://cdn.ywxi.net/js/1.js', type: 'text/javascript'} 15 | %body.fixed-nav.sticky-footer.bg-dark#page-top 16 | = render 'layouts/admin/navigation' 17 | .content-wrapper 18 | .flash_messages_div 19 | = bootstrap_flash 20 | = yield 21 | = render 'layouts/admin/footer' 22 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'fileutils' 3 | include FileUtils 4 | 5 | # path to your application root. 6 | APP_ROOT = File.expand_path('..', __dir__) 7 | 8 | def system!(*args) 9 | system(*args) || abort("\n== Command #{args} failed ==") 10 | end 11 | 12 | chdir APP_ROOT do 13 | # This script is a starting point to setup your application. 14 | # Add necessary setup steps to this file. 15 | 16 | puts '== Installing dependencies ==' 17 | system! 'gem install bundler --conservative' 18 | system('bundle check') || system!('bundle install') 19 | 20 | # Install JavaScript dependencies if using Yarn 21 | # system('bin/yarn') 22 | 23 | # puts "\n== Copying sample files ==" 24 | # unless File.exist?('config/database.yml') 25 | # cp 'config/database.yml.sample', 'config/database.yml' 26 | # end 27 | 28 | puts "\n== Preparing database ==" 29 | system! 'bin/rails db:setup' 30 | 31 | puts "\n== Removing old logs and tempfiles ==" 32 | system! 'bin/rails log:clear tmp:clear' 33 | 34 | puts "\n== Restarting application server ==" 35 | system! 'bin/rails restart' 36 | end 37 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 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 http://guides.rubyonrails.org/i18n.html. 31 | 32 | en: 33 | hello: "Hello world" 34 | admin: 35 | navigation: 36 | logout_title: "Ready to Leave?" 37 | logout_message: "Select 'Logout' below if you are ready to end your current session." 38 | -------------------------------------------------------------------------------- /app/views/admin/sessions/new.html.haml: -------------------------------------------------------------------------------- 1 | %body.bg-dark 2 | .container 3 | .card.card-login.mx-auto.mt-3 4 | .card-header Login 5 | .card-body 6 | = form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| 7 | .form-group 8 | = f.label :email, 'Email address', for: 'exampleInputEmail1' 9 | = f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control', id: 'exampleInputEmail1', 'aria-describedby': 'emailHelp', placeholder: 'Enter email' 10 | .form-group 11 | = f.label :password, for: 'exampleInputPassword1' 12 | = f.password_field :password, autocomplete: 'off', id: 'exampleInputPassword1', placeholder: 'Password', class: 'form-control' 13 | - if devise_mapping.rememberable? 14 | .form-group 15 | .form-check 16 | = f.check_box :remember_me, class: 'form-check-input' 17 | = f.label :remember_me, 'Remember Password', class: 'form-check-label' 18 | .actions 19 | = f.submit 'Log in', class: 'btn btn-primary btn-block' 20 | :javascript 21 | $(".alert" ).fadeOut(5000); 22 | -------------------------------------------------------------------------------- /config/initializers/content_security_policy.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Define an application-wide content security policy 4 | # For further information see the following documentation 5 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy 6 | 7 | # Rails.application.config.content_security_policy do |policy| 8 | # policy.default_src :self, :https 9 | # policy.font_src :self, :https, :data 10 | # policy.img_src :self, :https, :data 11 | # policy.object_src :none 12 | # policy.script_src :self, :https 13 | # policy.style_src :self, :https 14 | 15 | # # Specify URI for violation reports 16 | # # policy.report_uri "/csp-violation-report-endpoint" 17 | # end 18 | 19 | # If you are using UJS then enable automatic nonce generation 20 | # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } 21 | 22 | # Report CSP violations to a specified URI 23 | # For further information see the following documentation: 24 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only 25 | # Rails.application.config.content_security_policy_report_only = true 26 | -------------------------------------------------------------------------------- /app/views/admin/admins/change_password.html.haml: -------------------------------------------------------------------------------- 1 | = form_for @admin, url: admin_admin_update_password_path(@admin.id), html: {class: 'center reset-password-form'} do |f| 2 | .container.user_details 3 | %h3= 'Change Password' 4 | .card 5 | .card-body 6 | .row 7 | .col-md-12 8 | .form-group 9 | %label.pull-left.col-md-4 10 | Current Password 11 | = f.password_field :current_password, class: 'form-control col-md-4' 12 | .field-error.server-validation 13 | = show_error(f.object, :password) 14 | .form-group 15 | %label.pull-left.col-md-4 16 | New Password 17 | = f.password_field :password, class: 'form-control col-md-4' 18 | .field-error.server-validation 19 | = show_error(f.object, :new_password) 20 | .form-group 21 | %label.pull-left.col-md-4 22 | Password Confirmation 23 | = f.password_field :password_confirmation, class: 'form-control col-md-4' 24 | %center 25 | .form-group 26 | .actions 27 | = f.submit 'Save', class: 'btn btn-primary' 28 | -------------------------------------------------------------------------------- /config/storage.yml: -------------------------------------------------------------------------------- 1 | test: 2 | service: Disk 3 | root: <%= Rails.root.join("tmp/storage") %> 4 | 5 | local: 6 | service: Disk 7 | root: <%= Rails.root.join("storage") %> 8 | 9 | # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) 10 | # amazon: 11 | # service: S3 12 | # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> 13 | # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> 14 | # region: us-east-1 15 | # bucket: your_own_bucket 16 | 17 | # Remember not to checkin your GCS keyfile to a repository 18 | # google: 19 | # service: GCS 20 | # project: your_project 21 | # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> 22 | # bucket: your_own_bucket 23 | 24 | # Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) 25 | # microsoft: 26 | # service: AzureStorage 27 | # storage_account_name: your_account_name 28 | # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> 29 | # container: your_container_name 30 | 31 | # mirror: 32 | # service: Mirror 33 | # primary: local 34 | # mirrors: [ amazon, google, microsoft ] 35 | -------------------------------------------------------------------------------- /config/puma.rb: -------------------------------------------------------------------------------- 1 | threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 } 2 | threads threads_count, threads_count 3 | 4 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 5 | port ENV.fetch('PORT') { 3000 } 6 | 7 | # Specifies the `environment` that Puma will run in. 8 | environment ENV.fetch('RAILS_ENV') { 'development' } 9 | 10 | unless ENV.fetch('RAILS_ENV') == 'development' 11 | workers 2 12 | app_dir = File.expand_path('../..', __FILE__) 13 | 14 | daemonize true 15 | shared_dir = "#{app_dir}/shared/" 16 | 17 | # Set up socket location 18 | bind "unix://#{shared_dir}tmp/sockets/puma.sock" 19 | 20 | # Logging 21 | stdout_redirect "#{shared_dir}log/puma.stdout.log", "#{shared_dir}log/puma.stderr.log", true 22 | 23 | # Set master PID and state locations 24 | pidfile "#{shared_dir}tmp/pids/puma.pid" 25 | state_path "#{shared_dir}tmp/pids/puma.state" 26 | 27 | activate_control_app 28 | end 29 | 30 | # Allow puma to be restarted by `rails restart` command. 31 | plugin :tmp_restart 32 | 33 | unless ENV.fetch('RAILS_ENV') == 'development' 34 | on_worker_boot do 35 | require 'active_record' 36 | ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished 37 | ActiveRecord::Base.establish_connection(YAML.load_file("#{app_dir}/config/database.yml")[ENV.fetch('RAILS_ENV')]) 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /app/controllers/api/defaults.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module API 4 | module Defaults 5 | extend ActiveSupport::Concern 6 | 7 | included do 8 | helpers do 9 | def authenticate! 10 | begin 11 | JWT.decode(params[:user][:access_token], $secret[:api_hmac_secret], true, { :algorithm => 'HS256' }) 12 | @access_token = AccessToken.where(token: params[:user][:access_token]).first 13 | if @access_token.present? 14 | @current_user = @access_token.user 15 | else 16 | respond_error(401, 'Invalid session.') 17 | end 18 | rescue JWT::ExpiredSignature 19 | access_token = AccessToken.where(token: params[:user][:access_token]).first 20 | access_token.destroy if access_token.present? 21 | respond_error(401, 'Session expired.') 22 | rescue 23 | respond_error(401, 'Invalid session.') 24 | end 25 | end 26 | 27 | def error_message(object) 28 | object.errors.full_messages.uniq.join(",") 29 | end 30 | 31 | def respond(code = nil, data = nil) 32 | status code if code 33 | body data if data 34 | end 35 | 36 | def respond_error(code = nil, message = '') 37 | error!(message, code) 38 | end 39 | end 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /db/migrate/20190218131410_devise_create_admins.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class DeviseCreateAdmins < ActiveRecord::Migration[5.2] 4 | def change 5 | create_table :admins do |t| 6 | ## Database authenticatable 7 | t.string :email, null: false, default: "" 8 | t.string :encrypted_password, null: false, default: "" 9 | 10 | ## Recoverable 11 | t.string :reset_password_token 12 | t.datetime :reset_password_sent_at 13 | 14 | ## Rememberable 15 | t.datetime :remember_created_at 16 | 17 | ## Trackable 18 | t.integer :sign_in_count, default: 0, null: false 19 | t.datetime :current_sign_in_at 20 | t.datetime :last_sign_in_at 21 | t.inet :current_sign_in_ip 22 | t.inet :last_sign_in_ip 23 | 24 | ## Confirmable 25 | # t.string :confirmation_token 26 | # t.datetime :confirmed_at 27 | # t.datetime :confirmation_sent_at 28 | # t.string :unconfirmed_email # Only if using reconfirmable 29 | 30 | ## Lockable 31 | # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts 32 | # t.string :unlock_token # Only if unlock strategy is :email or :both 33 | # t.datetime :locked_at 34 | 35 | 36 | t.timestamps null: false 37 | end 38 | 39 | add_index :admins, :email, unique: true 40 | add_index :admins, :reset_password_token, unique: true 41 | # add_index :admins, :confirmation_token, unique: true 42 | # add_index :admins, :unlock_token, unique: true 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /db/migrate/20180424071905_devise_create_users.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class DeviseCreateUsers < ActiveRecord::Migration[5.2] 4 | def change 5 | create_table :users do |t| 6 | ## Database authenticatable 7 | t.string :email, null: false, default: "" 8 | t.string :encrypted_password, null: false, default: "" 9 | 10 | ## Recoverable 11 | t.string :reset_password_token 12 | t.datetime :reset_password_sent_at 13 | 14 | ## Rememberable 15 | t.datetime :remember_created_at 16 | 17 | ## Trackable 18 | t.integer :sign_in_count, default: 0, null: false 19 | t.datetime :current_sign_in_at 20 | t.datetime :last_sign_in_at 21 | t.inet :current_sign_in_ip 22 | t.inet :last_sign_in_ip 23 | 24 | ## Confirmable 25 | # t.string :confirmation_token 26 | # t.datetime :confirmed_at 27 | # t.datetime :confirmation_sent_at 28 | # t.string :unconfirmed_email # Only if using reconfirmable 29 | 30 | ## Lockable 31 | # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts 32 | # t.string :unlock_token # Only if unlock strategy is :email or :both 33 | # t.datetime :locked_at 34 | 35 | t.string :first_name 36 | t.string :last_name 37 | 38 | 39 | t.timestamps null: false 40 | end 41 | 42 | add_index :users, :email, unique: true 43 | add_index :users, :reset_password_token, unique: true 44 | # add_index :users, :confirmation_token, unique: true 45 | # add_index :users, :unlock_token, unique: true 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 54 | 55 | 56 | 57 | 58 |
59 |
60 |

We're sorry, but something went wrong.

61 |
62 |

If you are the application owner check the logs for more information.

63 |
64 | 65 | 66 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 54 | 55 | 56 | 57 | 58 |
59 |
60 |

The change you wanted was rejected.

61 |

Maybe you tried to change something you didn't have access to.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 54 | 55 | 56 | 57 | 58 |
59 |
60 |

The page you were looking for doesn't exist.

61 |

You may have mistyped the address or the page may have moved.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure public file server for tests with Cache-Control for performance. 16 | config.public_file_server.enabled = true 17 | config.public_file_server.headers = { 18 | 'Cache-Control' => "public, max-age=#{1.hour.to_i}" 19 | } 20 | 21 | # Show full error reports and disable caching. 22 | config.consider_all_requests_local = true 23 | config.action_controller.perform_caching = false 24 | 25 | # Raise exceptions instead of rendering exception templates. 26 | config.action_dispatch.show_exceptions = false 27 | 28 | # Disable request forgery protection in test environment. 29 | config.action_controller.allow_forgery_protection = false 30 | 31 | # Store uploaded files on the local file system in a temporary directory 32 | config.active_storage.service = :test 33 | 34 | config.action_mailer.perform_caching = false 35 | 36 | # Tell Action Mailer not to deliver emails to the real world. 37 | # The :test delivery method accumulates sent emails in the 38 | # ActionMailer::Base.deliveries array. 39 | config.action_mailer.delivery_method = :test 40 | 41 | # Print deprecation notices to the stderr. 42 | config.active_support.deprecation = :stderr 43 | 44 | # Raises error for missing translations 45 | # config.action_view.raise_on_missing_translations = true 46 | end 47 | -------------------------------------------------------------------------------- /app/views/layouts/admin/_navigation.html.haml: -------------------------------------------------------------------------------- 1 | %nav#mainNav.navbar.navbar-expand-lg.navbar-dark.bg-dark.fixed-top 2 | =link_to admin_dashboard_index_path, class: 'navbar-brand' do 3 | = 'ADMIN PANEL' 4 | %button.navbar-toggler.navbar-toggler-right{'aria-controls' => 'navbarResponsive', 'aria-expanded' => 'false', 'aria-label' => 'Toggle navigation', 'data-target' => '#navbarResponsive', 'data-toggle' => 'collapse', type: 'button'} 5 | %span.navbar-toggler-icon 6 | #navbarResponsive.collapse.navbar-collapse.d-flex.justify-content-end.flex-row 7 | =link_to 'Change Password', admin_admin_change_password_path(current_admin.id), class: 'btn btn-primary reset-password-nav' 8 | %ul#exampleAccordion.navbar-nav.navbar-sidenav 9 | %li.nav-item{'data-placement' => 'right', 'data-toggle' => 'tooltip', title: 'Users', class:('active' if params[:controller] == 'admin/sessions')} 10 | =link_to 'javascript:void(0)', {class: 'nav-link'} do 11 | %i.fa.fa-male 12 | %span.nav-link-text Sessions 13 | %li.nav-item{'data-placement' => 'right', 'data-toggle' => 'tooltip', title: 'User', class:('active' if params[:controller] == 'admin/users')} 14 | %a.nav-link.nav-link-collapse.collapsed{'data-parent' => '#exampleAccordion', 'data-toggle' => 'collapse', href: '#collapseComponents'} 15 | %i.fa.fa-fw.fa-user 16 | %span.nav-link-text Users 17 | %ul#collapseComponents.sidenav-second-level.collapse{class:('show' if params[:controller] == 'admin/users')} 18 | %li{class:('active' if params[:controller] == 'admin/users' && params[:type] == 'male')} 19 | =link_to 'javascript:void(0)' do 20 | %i.fa.fa-male 21 | %span.nav-link-text Male 22 | %li{class:('active' if params[:controller] == 'admin/users' && params[:type] == 'female')} 23 | =link_to 'javascript:void(0)' do 24 | %i.fa.fa-female 25 | %span.nav-link-text Female 26 | %ul.navbar-nav.sidenav-toggler 27 | %li.nav-item 28 | %a#sidenavToggler.nav-link.text-center 29 | %i.fa.fa-fw.fa-angle-left 30 | %ul.navbar-nav 31 | %li.nav-item 32 | %a.nav-link{'data-target' => '#logoutModal', 'data-toggle' => 'modal'} 33 | %i.fa.fa-fw.fa-sign-out> 34 | Logout 35 | = render 'layouts/admin/logout_modal' 36 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports. 13 | config.consider_all_requests_local = true 14 | 15 | # Enable/disable caching. By default caching is disabled. 16 | # Run rails dev:cache to toggle caching. 17 | if Rails.root.join('tmp', 'caching-dev.txt').exist? 18 | config.action_controller.perform_caching = true 19 | 20 | config.cache_store = :memory_store 21 | config.public_file_server.headers = { 22 | 'Cache-Control' => "public, max-age=#{2.days.to_i}" 23 | } 24 | else 25 | config.action_controller.perform_caching = false 26 | 27 | config.cache_store = :null_store 28 | end 29 | 30 | # Store uploaded files on the local file system (see config/storage.yml for options) 31 | config.active_storage.service = :local 32 | 33 | config.action_mailer.delivery_method = :letter_opener 34 | config.action_mailer.perform_deliveries = true 35 | 36 | # Don't care if the mailer can't send. 37 | config.action_mailer.raise_delivery_errors = false 38 | 39 | config.action_mailer.perform_caching = false 40 | 41 | # Print deprecation notices to the Rails logger. 42 | config.active_support.deprecation = :log 43 | 44 | # Raise an error on page load if there are pending migrations. 45 | config.active_record.migration_error = :page_load 46 | 47 | # Highlight code that triggered database queries in logs. 48 | config.active_record.verbose_query_logs = true 49 | 50 | # Debug mode disables concatenation and preprocessing of assets. 51 | # This option may cause significant delays in view rendering with a large 52 | # number of complex assets. 53 | config.assets.debug = true 54 | 55 | # Suppress logger output for asset requests. 56 | config.assets.quiet = true 57 | 58 | # Raises error for missing translations 59 | # config.action_view.raise_on_missing_translations = true 60 | 61 | # Use an evented file watcher to asynchronously detect changes in source code, 62 | # routes, locales, etc. This feature depends on the listen gem. 63 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker 64 | config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } 65 | end 66 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # This file is auto-generated from the current state of the database. Instead 2 | # of editing this file, please use the migrations feature of Active Record to 3 | # incrementally modify your database, and then regenerate this schema definition. 4 | # 5 | # Note that this schema.rb definition is the authoritative source for your 6 | # database schema. If you need to create the application database on another 7 | # system, you should be using db:schema:load, not running all the migrations 8 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 9 | # you'll amass, the slower it'll run and the greater likelihood for issues). 10 | # 11 | # It's strongly recommended that you check this file into your version control system. 12 | 13 | ActiveRecord::Schema.define(version: 2019_02_18_131410) do 14 | 15 | # These are extensions that must be enabled in order to support this database 16 | enable_extension "plpgsql" 17 | 18 | create_table "access_tokens", force: :cascade do |t| 19 | t.string "token", null: false 20 | t.boolean "active", default: true, null: false 21 | t.integer "user_id", null: false 22 | t.datetime "created_at", null: false 23 | t.datetime "updated_at", null: false 24 | end 25 | 26 | create_table "admins", force: :cascade do |t| 27 | t.string "email", default: "", null: false 28 | t.string "encrypted_password", default: "", null: false 29 | t.string "reset_password_token" 30 | t.datetime "reset_password_sent_at" 31 | t.datetime "remember_created_at" 32 | t.integer "sign_in_count", default: 0, null: false 33 | t.datetime "current_sign_in_at" 34 | t.datetime "last_sign_in_at" 35 | t.inet "current_sign_in_ip" 36 | t.inet "last_sign_in_ip" 37 | t.datetime "created_at", null: false 38 | t.datetime "updated_at", null: false 39 | t.index ["email"], name: "index_admins_on_email", unique: true 40 | t.index ["reset_password_token"], name: "index_admins_on_reset_password_token", unique: true 41 | end 42 | 43 | create_table "users", force: :cascade do |t| 44 | t.string "email", default: "", null: false 45 | t.string "encrypted_password", default: "", null: false 46 | t.string "reset_password_token" 47 | t.datetime "reset_password_sent_at" 48 | t.datetime "remember_created_at" 49 | t.integer "sign_in_count", default: 0, null: false 50 | t.datetime "current_sign_in_at" 51 | t.datetime "last_sign_in_at" 52 | t.inet "current_sign_in_ip" 53 | t.inet "last_sign_in_ip" 54 | t.string "first_name" 55 | t.string "last_name" 56 | t.datetime "created_at", null: false 57 | t.datetime "updated_at", null: false 58 | t.index ["email"], name: "index_users_on_email", unique: true 59 | t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true 60 | end 61 | 62 | end 63 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source 'https://rubygems.org' 4 | git_source(:github) { |repo| "https://github.com/#{repo}.git" } 5 | 6 | ruby '2.6.3' 7 | 8 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 9 | gem 'rails', '~> 5.2.3' 10 | # Use pg as the database for Active Record 11 | gem 'pg' 12 | # Use Puma as the app server 13 | gem 'puma' 14 | # Use SCSS for stylesheets 15 | gem 'sass-rails', '~> 5.0' 16 | # Use Uglifier as compressor for JavaScript assets 17 | gem 'uglifier', '>= 1.3.0' 18 | # See https://github.com/rails/execjs#readme for more supported runtimes 19 | # gem 'mini_racer', platforms: :ruby 20 | 21 | # Use CoffeeScript for .coffee assets and views 22 | gem 'coffee-rails', '~> 4.2' 23 | # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 24 | gem 'turbolinks', '~> 5' 25 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 26 | gem 'jbuilder', '~> 2.5' 27 | # Use Redis adapter to run Action Cable in production 28 | # gem 'redis', '~> 4.0' 29 | # Use ActiveModel has_secure_password 30 | # gem 'bcrypt', '~> 3.1.7' 31 | 32 | # Use ActiveStorage variant 33 | # gem 'mini_magick', '~> 4.8' 34 | 35 | # Use Capistrano for deployment 36 | # gem 'capistrano-rails', group: :development 37 | 38 | # Reduces boot times through caching; required in config/boot.rb 39 | gem 'bootsnap', '>= 1.1.0', require: false 40 | 41 | group :development, :test do 42 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console 43 | gem 'byebug', platforms: %i[mri mingw x64_mingw] 44 | gem 'pry' 45 | end 46 | 47 | group :development do 48 | gem 'letter_opener' 49 | gem 'listen', '>= 3.0.5', '< 3.2' 50 | gem 'rename' 51 | gem 'rubocop', require: false 52 | gem 'rubocop-performance' 53 | # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 54 | gem 'web-console', '>= 3.3.0' 55 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 56 | gem 'spring' 57 | gem 'spring-watcher-listen', '~> 2.0.0' 58 | end 59 | 60 | group :test do 61 | # Adds support for Capybara system testing and selenium driver 62 | gem 'capybara', '>= 2.15' 63 | gem 'selenium-webdriver' 64 | # Easy installation and use of chromedriver to run system tests with Chrome 65 | gem 'chromedriver-helper' 66 | end 67 | 68 | gem 'bootstrap' 69 | gem 'devise' 70 | gem 'fast_jsonapi' 71 | gem 'font-awesome-rails' 72 | gem 'grape' 73 | gem 'grape-jbuilder' 74 | gem 'grape-swagger' 75 | gem 'grape-swagger-rails' 76 | gem 'haml-rails' 77 | gem 'hashie-forbidden_attributes' 78 | gem 'jquery-rails' 79 | gem 'jwt' 80 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 81 | gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] 82 | -------------------------------------------------------------------------------- /app/controllers/api/v1/users.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module API 4 | module V1 5 | class Users < API::V1::Base 6 | include API::Defaults 7 | 8 | resource :users do 9 | desc 'Create user', 10 | headers: { 11 | 'Authorization' => { description: Constant::AUTH_DESCRIPTION, required: true } 12 | } 13 | params do 14 | requires :user, type: Hash, desc: 'User object' do 15 | requires :first_name, type: String, desc: 'First Name' 16 | requires :last_name, type: String, desc: 'Last Name' 17 | requires :email, type: String, desc: 'Email' 18 | requires :password, type: String, desc: 'Password' 19 | requires :password_confirmation, type: String, desc: 'Password Confirmation' 20 | end 21 | end 22 | post do 23 | user = User.new(params[:user]) 24 | if user.save 25 | access_token = user.new_access_token 26 | header 'AccessToken', access_token.token.to_s 27 | respond(201, id: user.id) 28 | else 29 | respond_error(422, error_message(user)) 30 | end 31 | end 32 | 33 | desc 'Login for user', 34 | headers: { 35 | 'Authorization' => { description: Constant::AUTH_DESCRIPTION, required: true } 36 | } 37 | params do 38 | requires :user, type: Hash, desc: 'User object' do 39 | requires :email, type: String, desc: 'Email', allow_blank: false 40 | requires :password, type: String, desc: 'Password', allow_blank: false 41 | end 42 | end 43 | post :login do 44 | user = User.find_by_email(params[:user][:email].downcase) 45 | if user&.valid_password?(params[:user][:password]) 46 | access_token = user.new_access_token 47 | header 'AccessToken', access_token.token.to_s 48 | respond(200, id: user.id) 49 | else 50 | respond_error(403, 'Invalid email or password.') 51 | end 52 | end 53 | 54 | desc 'Get a user', 55 | headers: { 56 | 'Authorization' => { description: Constant::AUTH_DESCRIPTION, required: true } 57 | } 58 | params do 59 | use :authentication_params 60 | end 61 | get ':id', jbuilder: 'users/get_user.json.jbuilder' do 62 | authenticate! 63 | @user = User.find(params[:id]) 64 | end 65 | 66 | desc 'Logout user', 67 | headers: { 68 | 'Authorization' => { description: Constant::AUTH_DESCRIPTION, required: true } 69 | } 70 | params do 71 | use :authentication_params 72 | end 73 | delete :logout do 74 | authenticate! 75 | @access_token.destroy if @access_token.present? 76 | respond(204) 77 | end 78 | end 79 | end 80 | end 81 | end 82 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Logo of RoRPlus](https://drive.google.com/uc?id=1HAGX3lPk2W46XrMcg0vpdUB5ejmpa-bC) 2 | 3 | RorPlus 4 | ===================== 5 | 6 | A Ruby on Rails boilerplate which contains web and api creation environment for quick rails app creation. 7 | 8 | # Installation Steps 9 | 10 | Step 1 - Install prerequisites 11 | -------------------- 12 | Install Ruby-2.6.3 13 | 14 | rvm install 2.6.3 15 | 16 | Step 2 - Clone the Repository 17 | -------------------- 18 | git clone https://github.com/SystangoTechnologies/RorPlus.git ror_plus 19 | 20 | Step 3 - Setup credentials master key 21 | -------------------- 22 | Open this project and create a file in config folder with name 'master.key' and put 'e892b91452fe10406eb557b3d2e663cc' in it 23 | 24 | As this master key is published here so we have to change this to another one. To do that we will create new rails application by running 25 | 26 | rails new testing_app 27 | cd testing_app 28 | EDITOR="vi" bin/rails credentials:edit 29 | 30 | Paste following credentials to it: 31 | 32 | development: 33 | base_url: 'http://localhost:3000' 34 | api_client_id: 'ror_plus' 35 | api_client_secret: 'HDFkfRorPlus645' 36 | api_hmac_secret: 'HfgisL637' 37 | 38 | Save the changes. 39 | 40 | Now you have another master.key and encrypted credentials in this testing_app repository. Copy them from this project and paste in our ror_plus project and Done. 41 | 42 | Step 4 - Rename it to your Project name 43 | -------------------- 44 | Initially your project name will be ror_plus 45 | 46 | cd ror_plus 47 | bundle install 48 | rails g rename:into your_project_name 49 | 50 | a. This will create a project with 'your_project_name'. Open newly created project in editor and check database.yml and .ruby-version for correct database and gemset name 51 | 52 | b. Change directory by cd to newly created project in terminal 53 | 54 | c. Now run 55 | 56 | gem install bundler 57 | bundle install 58 | 59 | Step 5 - Setup Api Environment 60 | -------------------- 61 | generate authorization key by running following command in rails console 62 | 63 | Base64.strict_encode64("#{$secret[:api_client_id]}:#{$secret[:api_client_secret]}") 64 | 65 | You have to pass this Authorization key in every api call. 66 | 67 | User's login, signup and logout apis are already there. You can customize the fields as per your requirements. 68 | 69 | In this Api environment we have used JWT authenication. 70 | 71 | 72 | This boilerplate consist following things configured in it 73 | -------------------- 74 | - Letter Opener: All your emails in development environment will get displayed in your browser instead of actually delivered to the email. This way you can check that all emails are getting sent properly. 75 | - HAML for html templates integration 76 | - Devise for users authentication 77 | - API environment setup with Grape and Swagger to create APIs 78 | - JWT authentication for APIs 79 | - Swagger for listing Api Doc and provides UI to call apis from there itself 80 | - Constants configuration 81 | - Bootstrap v4 82 | 83 | ## Contributors 84 | 85 | Pradeep Agrawal 86 | 87 | ## License 88 | 89 | This project is released under the [MIT License](https://opensource.org/licenses/MIT). 90 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both threaded web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] 18 | # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). 19 | config.require_master_key = true 20 | 21 | # Disable serving static files from the `/public` folder by default since 22 | # Apache or NGINX already handles this. 23 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? 24 | 25 | # Compress JavaScripts and CSS. 26 | config.assets.js_compressor = :uglifier 27 | # config.assets.css_compressor = :sass 28 | 29 | # Do not fallback to assets pipeline if a precompiled asset is missed. 30 | config.assets.compile = false 31 | 32 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 33 | 34 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 35 | # config.action_controller.asset_host = 'http://assets.example.com' 36 | 37 | # Specifies the header that your server uses for sending files. 38 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 39 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 40 | 41 | # Store uploaded files on the local file system (see config/storage.yml for options) 42 | config.active_storage.service = :local 43 | 44 | # Mount Action Cable outside main process or domain 45 | # config.action_cable.mount_path = nil 46 | # config.action_cable.url = 'wss://example.com/cable' 47 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] 48 | 49 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 50 | # config.force_ssl = true 51 | 52 | # Use the lowest log level to ensure availability of diagnostic information 53 | # when problems arise. 54 | config.log_level = :debug 55 | 56 | # Prepend all log lines with the following tags. 57 | config.log_tags = [ :request_id ] 58 | 59 | # Use a different cache store in production. 60 | # config.cache_store = :mem_cache_store 61 | 62 | # Use a real queuing backend for Active Job (and separate queues per environment) 63 | # config.active_job.queue_adapter = :resque 64 | # config.active_job.queue_name_prefix = "RorPlus_#{Rails.env}" 65 | 66 | config.action_mailer.perform_caching = false 67 | 68 | # Ignore bad email addresses and do not raise email delivery errors. 69 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 70 | # config.action_mailer.raise_delivery_errors = false 71 | 72 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 73 | # the I18n.default_locale when a translation cannot be found). 74 | config.i18n.fallbacks = true 75 | 76 | # Send deprecation notices to registered listeners. 77 | config.active_support.deprecation = :notify 78 | 79 | # Use default logging formatter so that PID and timestamp are not suppressed. 80 | config.log_formatter = ::Logger::Formatter.new 81 | 82 | # Use a different logger for distributed setups. 83 | # require 'syslog/logger' 84 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') 85 | 86 | if ENV["RAILS_LOG_TO_STDOUT"].present? 87 | logger = ActiveSupport::Logger.new(STDOUT) 88 | logger.formatter = config.log_formatter 89 | config.logger = ActiveSupport::TaggedLogging.new(logger) 90 | end 91 | 92 | # Do not dump schema after migrations. 93 | config.active_record.dump_schema_after_migration = false 94 | end 95 | -------------------------------------------------------------------------------- /config/locales/devise.en.yml: -------------------------------------------------------------------------------- 1 | # Additional translations at https://github.com/plataformatec/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 confirm link to confirm your new email address." 46 | updated: "Your account has been updated successfully." 47 | sessions: 48 | signed_in: "Signed in successfully." 49 | signed_out: "Signed out successfully." 50 | already_signed_out: "Signed out successfully." 51 | unlocks: 52 | send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes." 53 | send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes." 54 | unlocked: "Your account has been unlocked successfully. Please sign in to continue." 55 | errors: 56 | messages: 57 | already_confirmed: "was already confirmed, please try signing in" 58 | confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one" 59 | expired: "has expired, please request a new one" 60 | not_found: "not found" 61 | not_locked: "was not locked" 62 | not_saved: 63 | one: "1 error prohibited this %{resource} from being saved:" 64 | other: "%{count} errors prohibited this %{resource} from being saved:" 65 | -------------------------------------------------------------------------------- /app/assets/stylesheets/admin/sb-admin.min.css: -------------------------------------------------------------------------------- 1 | html{position:relative;min-height:100%}body{overflow-x:hidden}body.sticky-footer{margin-bottom:56px}body.sticky-footer .content-wrapper{min-height:calc(100vh - 56px - 56px)}body.fixed-nav{padding-top:56px}.content-wrapper{min-height:calc(100vh - 56px);padding-top:1rem}.scroll-to-top{position:fixed;right:15px;bottom:3px;display:none;width:50px;height:50px;text-align:center;color:#fff;background:rgba(52,58,64,.5);line-height:45px}.scroll-to-top:focus,.scroll-to-top:hover{color:#fff}.scroll-to-top:hover{background:#343a40}.scroll-to-top i{font-weight:800}.smaller{font-size:.7rem}.o-hidden{overflow:hidden!important}.z-0{z-index:0}.z-1{z-index:1}#mainNav .navbar-collapse{overflow:auto;max-height:75vh}#mainNav .navbar-collapse .navbar-nav .nav-item .nav-link{cursor:pointer}#mainNav .navbar-collapse .navbar-sidenav .nav-link-collapse:after{float:right;content:'\f107';font-family:FontAwesome}#mainNav .navbar-collapse .navbar-sidenav .nav-link-collapse.collapsed:after{content:'\f105'}#mainNav .navbar-collapse .navbar-sidenav .sidenav-second-level,#mainNav .navbar-collapse .navbar-sidenav .sidenav-third-level{padding-left:0}#mainNav .navbar-collapse .navbar-sidenav .sidenav-second-level>li>a,#mainNav .navbar-collapse .navbar-sidenav .sidenav-third-level>li>a{display:block;padding:.5em 0}#mainNav .navbar-collapse .navbar-sidenav .sidenav-second-level>li>a:focus,#mainNav .navbar-collapse .navbar-sidenav .sidenav-second-level>li>a:hover,#mainNav .navbar-collapse .navbar-sidenav .sidenav-third-level>li>a:focus,#mainNav .navbar-collapse .navbar-sidenav .sidenav-third-level>li>a:hover{text-decoration:none}#mainNav .navbar-collapse .navbar-sidenav .sidenav-second-level>li>a{padding-left:1em}#mainNav .navbar-collapse .navbar-sidenav .sidenav-third-level>li>a{padding-left:2em}#mainNav .navbar-collapse .sidenav-toggler{display:none}#mainNav .navbar-collapse .navbar-nav>.nav-item.dropdown>.nav-link{position:relative;min-width:45px}#mainNav .navbar-collapse .navbar-nav>.nav-item.dropdown>.nav-link:after{float:right;width:auto;content:'\f105';border:none;font-family:FontAwesome}#mainNav .navbar-collapse .navbar-nav>.nav-item.dropdown>.nav-link .indicator{position:absolute;top:5px;left:21px;font-size:10px}#mainNav .navbar-collapse .navbar-nav>.nav-item.dropdown.show>.nav-link:after{content:'\f107'}#mainNav .navbar-collapse .navbar-nav>.nav-item.dropdown .dropdown-menu>.dropdown-item>.dropdown-message{overflow:hidden;max-width:none;text-overflow:ellipsis}@media (min-width:992px){#mainNav .navbar-brand{width:250px}#mainNav .navbar-collapse{overflow:visible;max-height:none}#mainNav .navbar-collapse .navbar-sidenav{position:absolute;top:0;left:0;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;margin-top:56px}#mainNav .navbar-collapse .navbar-sidenav>.nav-item{width:250px;padding:0}#mainNav .navbar-collapse .navbar-sidenav>.nav-item>.nav-link{padding:1em}#mainNav .navbar-collapse .navbar-sidenav>.nav-item .sidenav-second-level,#mainNav .navbar-collapse .navbar-sidenav>.nav-item .sidenav-third-level{padding-left:0;list-style:none}#mainNav .navbar-collapse .navbar-sidenav>.nav-item .sidenav-second-level>li,#mainNav .navbar-collapse .navbar-sidenav>.nav-item .sidenav-third-level>li{width:250px}#mainNav .navbar-collapse .navbar-sidenav>.nav-item .sidenav-second-level>li>a,#mainNav .navbar-collapse .navbar-sidenav>.nav-item .sidenav-third-level>li>a{padding:1em}#mainNav .navbar-collapse .navbar-sidenav>.nav-item .sidenav-second-level>li>a{padding-left:2.75em}#mainNav .navbar-collapse .navbar-sidenav>.nav-item .sidenav-third-level>li>a{padding-left:3.75em}#mainNav .navbar-collapse .navbar-nav>.nav-item.dropdown>.nav-link{min-width:0}#mainNav .navbar-collapse .navbar-nav>.nav-item.dropdown>.nav-link:after{width:24px;text-align:center}#mainNav .navbar-collapse .navbar-nav>.nav-item.dropdown .dropdown-menu>.dropdown-item>.dropdown-message{max-width:300px}}#mainNav.fixed-top .sidenav-toggler{display:none}@media (min-width:992px){#mainNav.fixed-top .navbar-sidenav{height:calc(100vh - 112px);overflow-y: scroll;}#mainNav.fixed-top .sidenav-toggler{position:absolute;top:0;left:0;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;margin-top:calc(100vh - 56px)}#mainNav.fixed-top .sidenav-toggler>.nav-item{width:250px;padding:0}#mainNav.fixed-top .sidenav-toggler>.nav-item>.nav-link{padding:1em}}#mainNav.fixed-top.navbar-dark .sidenav-toggler{background-color:#212529}#mainNav.fixed-top.navbar-dark .sidenav-toggler a i{color:#adb5bd}#mainNav.fixed-top.navbar-light .sidenav-toggler{background-color:#dee2e6}#mainNav.fixed-top.navbar-light .sidenav-toggler a i{color:rgba(0,0,0,.5)}body.sidenav-toggled #mainNav.fixed-top .sidenav-toggler{overflow-x:hidden;width:55px}body.sidenav-toggled #mainNav.fixed-top .sidenav-toggler .nav-item,body.sidenav-toggled #mainNav.fixed-top .sidenav-toggler .nav-link{width:55px!important}body.sidenav-toggled #mainNav.fixed-top #sidenavToggler i{-webkit-transform:scaleX(-1);-moz-transform:scaleX(-1);-o-transform:scaleX(-1);transform:scaleX(-1);filter:FlipH;-ms-filter:FlipH}#mainNav.static-top .sidenav-toggler{display:none}@media (min-width:992px){#mainNav.static-top .sidenav-toggler{display:flex}}body.sidenav-toggled #mainNav.static-top #sidenavToggler i{-webkit-transform:scaleX(-1);-moz-transform:scaleX(-1);-o-transform:scaleX(-1);transform:scaleX(-1);filter:FlipH;-ms-filter:FlipH}.content-wrapper{overflow-x:hidden;background:#fff}@media (min-width:992px){.content-wrapper{margin-left:250px}}#sidenavToggler i{font-weight:800}.navbar-sidenav-tooltip.show{display:none}@media (min-width:992px){body.sidenav-toggled .content-wrapper{margin-left:55px}}body.sidenav-toggled .navbar-sidenav{width:55px}body.sidenav-toggled .navbar-sidenav .nav-link-text{display:none}body.sidenav-toggled .navbar-sidenav .nav-item,body.sidenav-toggled .navbar-sidenav .nav-link{width:55px!important}body.sidenav-toggled .navbar-sidenav .nav-item:after,body.sidenav-toggled .navbar-sidenav .nav-link:after{display:none}body.sidenav-toggled .navbar-sidenav .nav-item{white-space:nowrap}body.sidenav-toggled .navbar-sidenav-tooltip.show{display:flex}#mainNav.navbar-dark .navbar-collapse .navbar-sidenav .nav-link-collapse:after{color:#868e96}#mainNav.navbar-dark .navbar-collapse .navbar-sidenav>.nav-item>.nav-link{color:#868e96}#mainNav.navbar-dark .navbar-collapse .navbar-sidenav>.nav-item>.nav-link:hover{color:#adb5bd}#mainNav.navbar-dark .navbar-collapse .navbar-sidenav>.nav-item .sidenav-second-level>li>a,#mainNav.navbar-dark .navbar-collapse .navbar-sidenav>.nav-item .sidenav-third-level>li>a{color:#868e96}#mainNav.navbar-dark .navbar-collapse .navbar-sidenav>.nav-item .sidenav-second-level>li>a:focus,#mainNav.navbar-dark .navbar-collapse .navbar-sidenav>.nav-item .sidenav-second-level>li>a:hover,#mainNav.navbar-dark .navbar-collapse .navbar-sidenav>.nav-item .sidenav-third-level>li>a:focus,#mainNav.navbar-dark .navbar-collapse .navbar-sidenav>.nav-item .sidenav-third-level>li>a:hover{color:#adb5bd}#mainNav.navbar-dark .navbar-collapse .navbar-nav>.nav-item.dropdown>.nav-link:after{color:#adb5bd}@media (min-width:992px){#mainNav.navbar-dark .navbar-collapse .navbar-sidenav{background:#343a40}#mainNav.navbar-dark .navbar-collapse .navbar-sidenav li.active a{color:#fff!important;background-color:#495057}#mainNav.navbar-dark .navbar-collapse .navbar-sidenav li.active a:focus,#mainNav.navbar-dark .navbar-collapse .navbar-sidenav li.active a:hover{color:#fff}#mainNav.navbar-dark .navbar-collapse .navbar-sidenav>.nav-item .sidenav-second-level,#mainNav.navbar-dark .navbar-collapse .navbar-sidenav>.nav-item .sidenav-third-level{background:#343a40}}#mainNav.navbar-light .navbar-collapse .navbar-sidenav .nav-link-collapse:after{color:rgba(0,0,0,.5)}#mainNav.navbar-light .navbar-collapse .navbar-sidenav>.nav-item>.nav-link{color:rgba(0,0,0,.5)}#mainNav.navbar-light .navbar-collapse .navbar-sidenav>.nav-item>.nav-link:hover{color:rgba(0,0,0,.7)}#mainNav.navbar-light .navbar-collapse .navbar-sidenav>.nav-item .sidenav-second-level>li>a,#mainNav.navbar-light .navbar-collapse .navbar-sidenav>.nav-item .sidenav-third-level>li>a{color:rgba(0,0,0,.5)}#mainNav.navbar-light .navbar-collapse .navbar-sidenav>.nav-item .sidenav-second-level>li>a:focus,#mainNav.navbar-light .navbar-collapse .navbar-sidenav>.nav-item .sidenav-second-level>li>a:hover,#mainNav.navbar-light .navbar-collapse .navbar-sidenav>.nav-item .sidenav-third-level>li>a:focus,#mainNav.navbar-light .navbar-collapse .navbar-sidenav>.nav-item .sidenav-third-level>li>a:hover{color:rgba(0,0,0,.7)}#mainNav.navbar-light .navbar-collapse .navbar-nav>.nav-item.dropdown>.nav-link:after{color:rgba(0,0,0,.5)}@media (min-width:992px){#mainNav.navbar-light .navbar-collapse .navbar-sidenav{background:#f8f9fa}#mainNav.navbar-light .navbar-collapse .navbar-sidenav li.active a{color:#000!important;background-color:#e9ecef}#mainNav.navbar-light .navbar-collapse .navbar-sidenav li.active a:focus,#mainNav.navbar-light .navbar-collapse .navbar-sidenav li.active a:hover{color:#000}#mainNav.navbar-light .navbar-collapse .navbar-sidenav>.nav-item .sidenav-second-level,#mainNav.navbar-light .navbar-collapse .navbar-sidenav>.nav-item .sidenav-third-level{background:#f8f9fa}}.card-body-icon{position:absolute;z-index:0;top:-25px;right:-25px;font-size:5rem;-webkit-transform:rotate(15deg);-ms-transform:rotate(15deg);transform:rotate(15deg)}@media (min-width:576px){.card-columns{column-count:1}}@media (min-width:768px){.card-columns{column-count:2}}@media (min-width:1200px){.card-columns{column-count:2}}.card-login{max-width:25rem}.card-register{max-width:40rem}footer.sticky-footer{position:absolute;right:0;bottom:0;width:100%;height:56px;background-color:#e9ecef;line-height:55px}@media (min-width:992px){footer.sticky-footer{width:calc(100% - 250px)}}@media (min-width:992px){body.sidenav-toggled footer.sticky-footer{width:calc(100% - 55px)}} 2 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actioncable (5.2.4.1) 5 | actionpack (= 5.2.4.1) 6 | nio4r (~> 2.0) 7 | websocket-driver (>= 0.6.1) 8 | actionmailer (5.2.4.1) 9 | actionpack (= 5.2.4.1) 10 | actionview (= 5.2.4.1) 11 | activejob (= 5.2.4.1) 12 | mail (~> 2.5, >= 2.5.4) 13 | rails-dom-testing (~> 2.0) 14 | actionpack (5.2.4.1) 15 | actionview (= 5.2.4.1) 16 | activesupport (= 5.2.4.1) 17 | rack (~> 2.0, >= 2.0.8) 18 | rack-test (>= 0.6.3) 19 | rails-dom-testing (~> 2.0) 20 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 21 | actionview (5.2.4.1) 22 | activesupport (= 5.2.4.1) 23 | builder (~> 3.1) 24 | erubi (~> 1.4) 25 | rails-dom-testing (~> 2.0) 26 | rails-html-sanitizer (~> 1.0, >= 1.0.3) 27 | activejob (5.2.4.1) 28 | activesupport (= 5.2.4.1) 29 | globalid (>= 0.3.6) 30 | activemodel (5.2.4.1) 31 | activesupport (= 5.2.4.1) 32 | activerecord (5.2.4.1) 33 | activemodel (= 5.2.4.1) 34 | activesupport (= 5.2.4.1) 35 | arel (>= 9.0) 36 | activestorage (5.2.4.1) 37 | actionpack (= 5.2.4.1) 38 | activerecord (= 5.2.4.1) 39 | marcel (~> 0.3.1) 40 | activesupport (5.2.4.1) 41 | concurrent-ruby (~> 1.0, >= 1.0.2) 42 | i18n (>= 0.7, < 2) 43 | minitest (~> 5.1) 44 | tzinfo (~> 1.1) 45 | addressable (2.7.0) 46 | public_suffix (>= 2.0.2, < 5.0) 47 | archive-zip (0.12.0) 48 | io-like (~> 0.3.0) 49 | arel (9.0.0) 50 | ast (2.4.0) 51 | autoprefixer-rails (9.7.3) 52 | execjs 53 | axiom-types (0.1.1) 54 | descendants_tracker (~> 0.0.4) 55 | ice_nine (~> 0.11.0) 56 | thread_safe (~> 0.3, >= 0.3.1) 57 | bcrypt (3.1.13) 58 | bindex (0.8.1) 59 | bootsnap (1.4.5) 60 | msgpack (~> 1.0) 61 | bootstrap (4.4.1) 62 | autoprefixer-rails (>= 9.1.0) 63 | popper_js (>= 1.14.3, < 2) 64 | sassc-rails (>= 2.0.0) 65 | builder (3.2.4) 66 | byebug (11.0.1) 67 | capybara (3.30.0) 68 | addressable 69 | mini_mime (>= 0.1.3) 70 | nokogiri (~> 1.8) 71 | rack (>= 1.6.0) 72 | rack-test (>= 0.6.3) 73 | regexp_parser (~> 1.5) 74 | xpath (~> 3.2) 75 | childprocess (3.0.0) 76 | chromedriver-helper (2.1.1) 77 | archive-zip (~> 0.10) 78 | nokogiri (~> 1.8) 79 | coderay (1.1.2) 80 | coercible (1.0.0) 81 | descendants_tracker (~> 0.0.1) 82 | coffee-rails (4.2.2) 83 | coffee-script (>= 2.2.0) 84 | railties (>= 4.0.0) 85 | coffee-script (2.4.1) 86 | coffee-script-source 87 | execjs 88 | coffee-script-source (1.12.2) 89 | concurrent-ruby (1.1.5) 90 | crass (1.0.5) 91 | descendants_tracker (0.0.4) 92 | thread_safe (~> 0.3, >= 0.3.1) 93 | devise (4.7.1) 94 | bcrypt (~> 3.0) 95 | orm_adapter (~> 0.1) 96 | railties (>= 4.1.0) 97 | responders 98 | warden (~> 1.2.3) 99 | equalizer (0.0.11) 100 | erubi (1.9.0) 101 | erubis (2.7.0) 102 | execjs (2.7.0) 103 | fast_jsonapi (1.5) 104 | activesupport (>= 4.2) 105 | ffi (1.11.3) 106 | font-awesome-rails (4.7.0.5) 107 | railties (>= 3.2, < 6.1) 108 | globalid (0.4.2) 109 | activesupport (>= 4.2.0) 110 | grape (1.2.5) 111 | activesupport 112 | builder 113 | mustermann-grape (~> 1.0.0) 114 | rack (>= 1.3.0) 115 | rack-accept 116 | virtus (>= 1.0.0) 117 | grape-jbuilder (0.2.0) 118 | grape (>= 0.3) 119 | i18n 120 | jbuilder 121 | tilt 122 | tilt-jbuilder (>= 0.4.0) 123 | grape-swagger (0.33.0) 124 | grape (>= 0.16.2) 125 | grape-swagger-rails (0.3.1) 126 | railties (>= 3.2.12) 127 | haml (5.1.2) 128 | temple (>= 0.8.0) 129 | tilt 130 | haml-rails (2.0.1) 131 | actionpack (>= 5.1) 132 | activesupport (>= 5.1) 133 | haml (>= 4.0.6, < 6.0) 134 | html2haml (>= 1.0.1) 135 | railties (>= 5.1) 136 | hashie (4.0.0) 137 | hashie-forbidden_attributes (0.1.1) 138 | hashie (>= 3.0) 139 | html2haml (2.2.0) 140 | erubis (~> 2.7.0) 141 | haml (>= 4.0, < 6) 142 | nokogiri (>= 1.6.0) 143 | ruby_parser (~> 3.5) 144 | i18n (1.7.1) 145 | concurrent-ruby (~> 1.0) 146 | ice_nine (0.11.2) 147 | io-like (0.3.0) 148 | jaro_winkler (1.5.4) 149 | jbuilder (2.9.1) 150 | activesupport (>= 4.2.0) 151 | jquery-rails (4.3.5) 152 | rails-dom-testing (>= 1, < 3) 153 | railties (>= 4.2.0) 154 | thor (>= 0.14, < 2.0) 155 | jwt (2.2.1) 156 | launchy (2.4.3) 157 | addressable (~> 2.3) 158 | letter_opener (1.7.0) 159 | launchy (~> 2.2) 160 | listen (3.1.5) 161 | rb-fsevent (~> 0.9, >= 0.9.4) 162 | rb-inotify (~> 0.9, >= 0.9.7) 163 | ruby_dep (~> 1.2) 164 | loofah (2.4.0) 165 | crass (~> 1.0.2) 166 | nokogiri (>= 1.5.9) 167 | mail (2.7.1) 168 | mini_mime (>= 0.1.1) 169 | marcel (0.3.3) 170 | mimemagic (~> 0.3.2) 171 | method_source (0.9.2) 172 | mimemagic (0.3.3) 173 | mini_mime (1.0.2) 174 | mini_portile2 (2.4.0) 175 | minitest (5.13.0) 176 | msgpack (1.3.1) 177 | mustermann (1.0.3) 178 | mustermann-grape (1.0.0) 179 | mustermann (~> 1.0.0) 180 | nio4r (2.5.2) 181 | nokogiri (1.10.7) 182 | mini_portile2 (~> 2.4.0) 183 | orm_adapter (0.5.0) 184 | parallel (1.19.1) 185 | parser (2.7.0.1) 186 | ast (~> 2.4.0) 187 | pg (1.2.1) 188 | popper_js (1.14.5) 189 | pry (0.12.2) 190 | coderay (~> 1.1.0) 191 | method_source (~> 0.9.0) 192 | public_suffix (4.0.3) 193 | puma (4.3.1) 194 | nio4r (~> 2.0) 195 | rack (2.0.8) 196 | rack-accept (0.4.5) 197 | rack (>= 0.4) 198 | rack-test (1.1.0) 199 | rack (>= 1.0, < 3) 200 | rails (5.2.4.1) 201 | actioncable (= 5.2.4.1) 202 | actionmailer (= 5.2.4.1) 203 | actionpack (= 5.2.4.1) 204 | actionview (= 5.2.4.1) 205 | activejob (= 5.2.4.1) 206 | activemodel (= 5.2.4.1) 207 | activerecord (= 5.2.4.1) 208 | activestorage (= 5.2.4.1) 209 | activesupport (= 5.2.4.1) 210 | bundler (>= 1.3.0) 211 | railties (= 5.2.4.1) 212 | sprockets-rails (>= 2.0.0) 213 | rails-dom-testing (2.0.3) 214 | activesupport (>= 4.2.0) 215 | nokogiri (>= 1.6) 216 | rails-html-sanitizer (1.3.0) 217 | loofah (~> 2.3) 218 | railties (5.2.4.1) 219 | actionpack (= 5.2.4.1) 220 | activesupport (= 5.2.4.1) 221 | method_source 222 | rake (>= 0.8.7) 223 | thor (>= 0.19.0, < 2.0) 224 | rainbow (3.0.0) 225 | rake (13.0.1) 226 | rb-fsevent (0.10.3) 227 | rb-inotify (0.10.1) 228 | ffi (~> 1.0) 229 | regexp_parser (1.6.0) 230 | rename (1.0.6) 231 | activesupport 232 | rails (>= 3.0.0) 233 | thor (>= 0.19.1) 234 | responders (3.0.0) 235 | actionpack (>= 5.0) 236 | railties (>= 5.0) 237 | rubocop (0.79.0) 238 | jaro_winkler (~> 1.5.1) 239 | parallel (~> 1.10) 240 | parser (>= 2.7.0.1) 241 | rainbow (>= 2.2.2, < 4.0) 242 | ruby-progressbar (~> 1.7) 243 | unicode-display_width (>= 1.4.0, < 1.7) 244 | rubocop-performance (1.5.2) 245 | rubocop (>= 0.71.0) 246 | ruby-progressbar (1.10.1) 247 | ruby_dep (1.5.0) 248 | ruby_parser (3.14.1) 249 | sexp_processor (~> 4.9) 250 | rubyzip (2.0.0) 251 | sass (3.7.4) 252 | sass-listen (~> 4.0.0) 253 | sass-listen (4.0.0) 254 | rb-fsevent (~> 0.9, >= 0.9.4) 255 | rb-inotify (~> 0.9, >= 0.9.7) 256 | sass-rails (5.1.0) 257 | railties (>= 5.2.0) 258 | sass (~> 3.1) 259 | sprockets (>= 2.8, < 4.0) 260 | sprockets-rails (>= 2.0, < 4.0) 261 | tilt (>= 1.1, < 3) 262 | sassc (2.2.1) 263 | ffi (~> 1.9) 264 | sassc-rails (2.1.2) 265 | railties (>= 4.0.0) 266 | sassc (>= 2.0) 267 | sprockets (> 3.0) 268 | sprockets-rails 269 | tilt 270 | selenium-webdriver (3.142.7) 271 | childprocess (>= 0.5, < 4.0) 272 | rubyzip (>= 1.2.2) 273 | sexp_processor (4.13.0) 274 | spring (2.1.0) 275 | spring-watcher-listen (2.0.1) 276 | listen (>= 2.7, < 4.0) 277 | spring (>= 1.2, < 3.0) 278 | sprockets (3.7.2) 279 | concurrent-ruby (~> 1.0) 280 | rack (> 1, < 3) 281 | sprockets-rails (3.2.1) 282 | actionpack (>= 4.0) 283 | activesupport (>= 4.0) 284 | sprockets (>= 3.0.0) 285 | temple (0.8.2) 286 | thor (1.0.1) 287 | thread_safe (0.3.6) 288 | tilt (2.0.10) 289 | tilt-jbuilder (0.7.1) 290 | jbuilder 291 | tilt (>= 1.3.0, < 3) 292 | turbolinks (5.2.1) 293 | turbolinks-source (~> 5.2) 294 | turbolinks-source (5.2.0) 295 | tzinfo (1.2.6) 296 | thread_safe (~> 0.1) 297 | uglifier (4.2.0) 298 | execjs (>= 0.3.0, < 3) 299 | unicode-display_width (1.6.0) 300 | virtus (1.0.5) 301 | axiom-types (~> 0.1) 302 | coercible (~> 1.0) 303 | descendants_tracker (~> 0.0, >= 0.0.3) 304 | equalizer (~> 0.0, >= 0.0.9) 305 | warden (1.2.8) 306 | rack (>= 2.0.6) 307 | web-console (3.7.0) 308 | actionview (>= 5.0) 309 | activemodel (>= 5.0) 310 | bindex (>= 0.4.0) 311 | railties (>= 5.0) 312 | websocket-driver (0.7.1) 313 | websocket-extensions (>= 0.1.0) 314 | websocket-extensions (0.1.4) 315 | xpath (3.2.0) 316 | nokogiri (~> 1.8) 317 | 318 | PLATFORMS 319 | ruby 320 | 321 | DEPENDENCIES 322 | bootsnap (>= 1.1.0) 323 | bootstrap 324 | byebug 325 | capybara (>= 2.15) 326 | chromedriver-helper 327 | coffee-rails (~> 4.2) 328 | devise 329 | fast_jsonapi 330 | font-awesome-rails 331 | grape 332 | grape-jbuilder 333 | grape-swagger 334 | grape-swagger-rails 335 | haml-rails 336 | hashie-forbidden_attributes 337 | jbuilder (~> 2.5) 338 | jquery-rails 339 | jwt 340 | letter_opener 341 | listen (>= 3.0.5, < 3.2) 342 | pg 343 | pry 344 | puma 345 | rails (~> 5.2.3) 346 | rename 347 | rubocop 348 | rubocop-performance 349 | sass-rails (~> 5.0) 350 | selenium-webdriver 351 | spring 352 | spring-watcher-listen (~> 2.0.0) 353 | turbolinks (~> 5) 354 | tzinfo-data 355 | uglifier (>= 1.3.0) 356 | web-console (>= 3.3.0) 357 | 358 | RUBY VERSION 359 | ruby 2.6.3p62 360 | 361 | BUNDLED WITH 362 | 1.17.2 363 | -------------------------------------------------------------------------------- /config/initializers/devise.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Use this hook to configure devise mailer, warden hooks and so forth. 4 | # Many of these configuration options can be set straight in your model. 5 | Devise.setup do |config| 6 | # The secret key used by Devise. Devise uses this key to generate 7 | # random tokens. Changing this key will render invalid all existing 8 | # confirmation, reset password and unlock tokens in the database. 9 | # Devise will use the `secret_key_base` as its `secret_key` 10 | # by default. You can change it below and use your own secret key. 11 | config.secret_key = '6414d5d9160fe8673e6ab4c84a60509d76c1fdb6dc95770cd23308a8c333d197de21ace76c68516ed1f00a96b9c654d9afc05cc2a2b674e4ab115e4c9d9f6e40' 12 | 13 | # ==> Controller configuration 14 | # Configure the parent class to the devise controllers. 15 | # config.parent_controller = 'DeviseController' 16 | 17 | # ==> Mailer Configuration 18 | # Configure the e-mail address which will be shown in Devise::Mailer, 19 | # note that it will be overwritten if you use your own mailer class 20 | # with default "from" parameter. 21 | config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com' 22 | 23 | # Configure the class responsible to send e-mails. 24 | # config.mailer = 'Devise::Mailer' 25 | 26 | # Configure the parent class responsible to send e-mails. 27 | # config.parent_mailer = 'ActionMailer::Base' 28 | 29 | # ==> ORM configuration 30 | # Load and configure the ORM. Supports :active_record (default) and 31 | # :mongoid (bson_ext recommended) by default. Other ORMs may be 32 | # available as additional gems. 33 | require 'devise/orm/active_record' 34 | 35 | # ==> Configuration for any authentication mechanism 36 | # Configure which keys are used when authenticating a user. The default is 37 | # just :email. You can configure it to use [:username, :subdomain], so for 38 | # authenticating a user, both parameters are required. Remember that those 39 | # parameters are used only when authenticating and not when retrieving from 40 | # session. If you need permissions, you should implement that in a before filter. 41 | # You can also supply a hash where the value is a boolean determining whether 42 | # or not authentication should be aborted when the value is not present. 43 | # config.authentication_keys = [:email] 44 | 45 | # Configure parameters from the request object used for authentication. Each entry 46 | # given should be a request method and it will automatically be passed to the 47 | # find_for_authentication method and considered in your model lookup. For instance, 48 | # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. 49 | # The same considerations mentioned for authentication_keys also apply to request_keys. 50 | # config.request_keys = [] 51 | 52 | # Configure which authentication keys should be case-insensitive. 53 | # These keys will be downcased upon creating or modifying a user and when used 54 | # to authenticate or find a user. Default is :email. 55 | config.case_insensitive_keys = [:email] 56 | 57 | # Configure which authentication keys should have whitespace stripped. 58 | # These keys will have whitespace before and after removed upon creating or 59 | # modifying a user and when used to authenticate or find a user. Default is :email. 60 | config.strip_whitespace_keys = [:email] 61 | 62 | # Tell if authentication through request.params is enabled. True by default. 63 | # It can be set to an array that will enable params authentication only for the 64 | # given strategies, for example, `config.params_authenticatable = [:database]` will 65 | # enable it only for database (email + password) authentication. 66 | # config.params_authenticatable = true 67 | 68 | # Tell if authentication through HTTP Auth is enabled. False by default. 69 | # It can be set to an array that will enable http authentication only for the 70 | # given strategies, for example, `config.http_authenticatable = [:database]` will 71 | # enable it only for database authentication. The supported strategies are: 72 | # :database = Support basic authentication with authentication key + password 73 | # config.http_authenticatable = false 74 | 75 | # If 401 status code should be returned for AJAX requests. True by default. 76 | # config.http_authenticatable_on_xhr = true 77 | 78 | # The realm used in Http Basic Authentication. 'Application' by default. 79 | # config.http_authentication_realm = 'Application' 80 | 81 | # It will change confirmation, password recovery and other workflows 82 | # to behave the same regardless if the e-mail provided was right or wrong. 83 | # Does not affect registerable. 84 | # config.paranoid = true 85 | 86 | # By default Devise will store the user in session. You can skip storage for 87 | # particular strategies by setting this option. 88 | # Notice that if you are skipping storage for all authentication paths, you 89 | # may want to disable generating routes to Devise's sessions controller by 90 | # passing skip: :sessions to `devise_for` in your config/routes.rb 91 | config.skip_session_storage = [:http_auth] 92 | 93 | # By default, Devise cleans up the CSRF token on authentication to 94 | # avoid CSRF token fixation attacks. This means that, when using AJAX 95 | # requests for sign in and sign up, you need to get a new CSRF token 96 | # from the server. You can disable this option at your own risk. 97 | # config.clean_up_csrf_token_on_authentication = true 98 | 99 | # When false, Devise will not attempt to reload routes on eager load. 100 | # This can reduce the time taken to boot the app but if your application 101 | # requires the Devise mappings to be loaded during boot time the application 102 | # won't boot properly. 103 | # config.reload_routes = true 104 | 105 | # ==> Configuration for :database_authenticatable 106 | # For bcrypt, this is the cost for hashing the password and defaults to 11. If 107 | # using other algorithms, it sets how many times you want the password to be hashed. 108 | # 109 | # Limiting the stretches to just one in testing will increase the performance of 110 | # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use 111 | # a value less than 10 in other environments. Note that, for bcrypt (the default 112 | # algorithm), the cost increases exponentially with the number of stretches (e.g. 113 | # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation). 114 | config.stretches = Rails.env.test? ? 1 : 11 115 | 116 | # Set up a pepper to generate the hashed password. 117 | # config.pepper = '762e059dd22c27cc445905b86166cf6301f39cb3bd460ec8043b1305bda451f2bf123cacac88d627871a63a2add3226d71e3407de7820572aca87f707ec00b71' 118 | 119 | # Send a notification to the original email when the user's email is changed. 120 | # config.send_email_changed_notification = false 121 | 122 | # Send a notification email when the user's password is changed. 123 | # config.send_password_change_notification = false 124 | 125 | # ==> Configuration for :confirmable 126 | # A period that the user is allowed to access the website even without 127 | # confirming their account. For instance, if set to 2.days, the user will be 128 | # able to access the website for two days without confirming their account, 129 | # access will be blocked just in the third day. Default is 0.days, meaning 130 | # the user cannot access the website without confirming their account. 131 | # config.allow_unconfirmed_access_for = 2.days 132 | 133 | # A period that the user is allowed to confirm their account before their 134 | # token becomes invalid. For example, if set to 3.days, the user can confirm 135 | # their account within 3 days after the mail was sent, but on the fourth day 136 | # their account can't be confirmed with the token any more. 137 | # Default is nil, meaning there is no restriction on how long a user can take 138 | # before confirming their account. 139 | # config.confirm_within = 3.days 140 | 141 | # If true, requires any email changes to be confirmed (exactly the same way as 142 | # initial account confirmation) to be applied. Requires additional unconfirmed_email 143 | # db field (see migrations). Until confirmed, new email is stored in 144 | # unconfirmed_email column, and copied to email column on successful confirmation. 145 | config.reconfirmable = true 146 | 147 | # Defines which key will be used when confirming an account 148 | # config.confirmation_keys = [:email] 149 | 150 | # ==> Configuration for :rememberable 151 | # The time the user will be remembered without asking for credentials again. 152 | # config.remember_for = 2.weeks 153 | 154 | # Invalidates all the remember me tokens when the user signs out. 155 | config.expire_all_remember_me_on_sign_out = true 156 | 157 | # If true, extends the user's remember period when remembered via cookie. 158 | # config.extend_remember_period = false 159 | 160 | # Options to be passed to the created cookie. For instance, you can set 161 | # secure: true in order to force SSL only cookies. 162 | # config.rememberable_options = {} 163 | 164 | # ==> Configuration for :validatable 165 | # Range for password length. 166 | config.password_length = 6..128 167 | 168 | # Email regex used to validate email formats. It simply asserts that 169 | # one (and only one) @ exists in the given string. This is mainly 170 | # to give user feedback and not to assert the e-mail validity. 171 | config.email_regexp = /\A[^@\s]+@[^@\s]+\z/ 172 | 173 | # ==> Configuration for :timeoutable 174 | # The time you want to timeout the user session without activity. After this 175 | # time the user will be asked for credentials again. Default is 30 minutes. 176 | # config.timeout_in = 30.minutes 177 | 178 | # ==> Configuration for :lockable 179 | # Defines which strategy will be used to lock an account. 180 | # :failed_attempts = Locks an account after a number of failed attempts to sign in. 181 | # :none = No lock strategy. You should handle locking by yourself. 182 | # config.lock_strategy = :failed_attempts 183 | 184 | # Defines which key will be used when locking and unlocking an account 185 | # config.unlock_keys = [:email] 186 | 187 | # Defines which strategy will be used to unlock an account. 188 | # :email = Sends an unlock link to the user email 189 | # :time = Re-enables login after a certain amount of time (see :unlock_in below) 190 | # :both = Enables both strategies 191 | # :none = No unlock strategy. You should handle unlocking by yourself. 192 | # config.unlock_strategy = :both 193 | 194 | # Number of authentication tries before locking an account if lock_strategy 195 | # is failed attempts. 196 | # config.maximum_attempts = 20 197 | 198 | # Time interval to unlock the account if :time is enabled as unlock_strategy. 199 | # config.unlock_in = 1.hour 200 | 201 | # Warn on the last attempt before the account is locked. 202 | # config.last_attempt_warning = true 203 | 204 | # ==> Configuration for :recoverable 205 | # 206 | # Defines which key will be used when recovering the password for an account 207 | # config.reset_password_keys = [:email] 208 | 209 | # Time interval you can reset your password with a reset password key. 210 | # Don't put a too small interval or your users won't have the time to 211 | # change their passwords. 212 | config.reset_password_within = 6.hours 213 | 214 | # When set to false, does not sign a user in automatically after their password is 215 | # reset. Defaults to true, so a user is signed in automatically after a reset. 216 | # config.sign_in_after_reset_password = true 217 | 218 | # ==> Configuration for :encryptable 219 | # Allow you to use another hashing or encryption algorithm besides bcrypt (default). 220 | # You can use :sha1, :sha512 or algorithms from others authentication tools as 221 | # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20 222 | # for default behavior) and :restful_authentication_sha1 (then you should set 223 | # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper). 224 | # 225 | # Require the `devise-encryptable` gem when using anything other than bcrypt 226 | # config.encryptor = :sha512 227 | 228 | # ==> Scopes configuration 229 | # Turn scoped views on. Before rendering "sessions/new", it will first check for 230 | # "users/sessions/new". It's turned off by default because it's slower if you 231 | # are using only default views. 232 | config.scoped_views = true 233 | 234 | # Configure the default scope given to Warden. By default it's the first 235 | # devise role declared in your routes (usually :user). 236 | # config.default_scope = :user 237 | 238 | # Set this configuration to false if you want /users/sign_out to sign out 239 | # only the current scope. By default, Devise signs out all scopes. 240 | # config.sign_out_all_scopes = true 241 | 242 | # ==> Navigation configuration 243 | # Lists the formats that should be treated as navigational. Formats like 244 | # :html, should redirect to the sign in page when the user does not have 245 | # access, but formats like :xml or :json, should return 401. 246 | # 247 | # If you have any extra navigational formats, like :iphone or :mobile, you 248 | # should add them to the navigational formats lists. 249 | # 250 | # The "*/*" below is required to match Internet Explorer requests. 251 | # config.navigational_formats = ['*/*', :html] 252 | 253 | # The default HTTP method used to sign out a resource. Default is :delete. 254 | config.sign_out_via = :delete 255 | 256 | # ==> OmniAuth 257 | # Add a new OmniAuth provider. Check the wiki for more information on setting 258 | # up on your models and hooks. 259 | # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' 260 | 261 | # ==> Warden configuration 262 | # If you want to use other strategies, that are not supported by Devise, or 263 | # change the failure app, you can configure them inside the config.warden block. 264 | # 265 | # config.warden do |manager| 266 | # manager.intercept_401 = false 267 | # manager.default_strategies(scope: :user).unshift :some_external_strategy 268 | # end 269 | 270 | # ==> Mountable engine configurations 271 | # When using Devise inside an engine, let's call it `MyEngine`, and this engine 272 | # is mountable, there are some extra configurations to be taken into account. 273 | # The following options are available, assuming the engine is mounted as: 274 | # 275 | # mount MyEngine, at: '/my_engine' 276 | # 277 | # The router that invoked `devise_for`, in the example above, would be: 278 | # config.router_name = :my_engine 279 | # 280 | # When using OmniAuth, Devise cannot automatically set OmniAuth path, 281 | # so you need to do it manually. For the users scope, it would be: 282 | # config.omniauth_path_prefix = '/my_engine/users/auth' 283 | end 284 | --------------------------------------------------------------------------------