ditty 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -7
- data/.travis.yml +5 -5
- data/Gemfile.ci +2 -0
- data/Rakefile +4 -3
- data/Readme.md +24 -2
- data/ditty.gemspec +4 -3
- data/lib/ditty.rb +24 -0
- data/lib/ditty/cli.rb +6 -2
- data/lib/ditty/components/app.rb +10 -1
- data/lib/ditty/controllers/application.rb +72 -10
- data/lib/ditty/controllers/audit_logs.rb +1 -5
- data/lib/ditty/controllers/auth.rb +37 -17
- data/lib/ditty/controllers/component.rb +15 -5
- data/lib/ditty/controllers/main.rb +1 -5
- data/lib/ditty/controllers/roles.rb +2 -5
- data/lib/ditty/controllers/user_login_traits.rb +18 -0
- data/lib/ditty/controllers/users.rb +4 -9
- data/lib/ditty/db.rb +3 -1
- data/lib/ditty/emails/base.rb +13 -4
- data/lib/ditty/helpers/authentication.rb +6 -5
- data/lib/ditty/helpers/component.rb +9 -1
- data/lib/ditty/helpers/response.rb +24 -3
- data/lib/ditty/helpers/views.rb +20 -0
- data/lib/ditty/listener.rb +38 -10
- data/lib/ditty/middleware/accept_extension.rb +2 -0
- data/lib/ditty/middleware/error_catchall.rb +2 -0
- data/lib/ditty/models/audit_log.rb +1 -0
- data/lib/ditty/models/base.rb +4 -0
- data/lib/ditty/models/identity.rb +3 -0
- data/lib/ditty/models/role.rb +1 -0
- data/lib/ditty/models/user.rb +9 -1
- data/lib/ditty/models/user_login_trait.rb +17 -0
- data/lib/ditty/policies/audit_log_policy.rb +6 -6
- data/lib/ditty/policies/role_policy.rb +2 -2
- data/lib/ditty/policies/user_login_trait_policy.rb +45 -0
- data/lib/ditty/policies/user_policy.rb +2 -2
- data/lib/ditty/rubocop.rb +3 -0
- data/lib/ditty/seed.rb +2 -0
- data/lib/ditty/services/authentication.rb +7 -2
- data/lib/ditty/services/email.rb +8 -2
- data/lib/ditty/services/logger.rb +11 -0
- data/lib/ditty/services/pagination_wrapper.rb +2 -0
- data/lib/ditty/services/settings.rb +14 -3
- data/lib/ditty/tasks/ditty.rake +109 -0
- data/lib/ditty/tasks/omniauth-ldap.rake +43 -0
- data/lib/ditty/version.rb +1 -1
- data/lib/rubocop/cop/ditty/call_services_directly.rb +42 -0
- data/migrate/20181209_add_user_login_traits.rb +16 -0
- data/migrate/20181209_extend_audit_log.rb +12 -0
- data/views/403.haml +2 -0
- data/views/audit_logs/index.haml +11 -6
- data/views/auth/ldap.haml +17 -0
- data/views/emails/forgot_password.haml +1 -1
- data/views/emails/layouts/action.haml +10 -6
- data/views/emails/layouts/alert.haml +2 -1
- data/views/emails/layouts/billing.haml +2 -1
- data/views/error.haml +8 -3
- data/views/partials/form_control.haml +24 -20
- data/views/partials/navbar.haml +11 -12
- data/views/partials/sidebar.haml +1 -1
- data/views/roles/index.haml +2 -0
- data/views/user_login_traits/display.haml +32 -0
- data/views/user_login_traits/edit.haml +10 -0
- data/views/user_login_traits/form.haml +5 -0
- data/views/user_login_traits/index.haml +30 -0
- data/views/user_login_traits/new.haml +10 -0
- data/views/users/display.haml +1 -1
- data/views/users/login_traits.haml +27 -0
- data/views/users/profile.haml +2 -0
- metadata +50 -21
- data/lib/ditty/rake_tasks.rb +0 -102
data/lib/ditty/rake_tasks.rb
DELETED
@@ -1,102 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rake'
|
4
|
-
require 'rake/tasklib'
|
5
|
-
require 'ditty/db' unless defined? DB
|
6
|
-
|
7
|
-
module Ditty
|
8
|
-
class Tasks < ::Rake::TaskLib
|
9
|
-
include ::Rake::DSL if defined?(::Rake::DSL)
|
10
|
-
|
11
|
-
def install_tasks
|
12
|
-
namespace :ditty do
|
13
|
-
desc 'Generate the needed tokens'
|
14
|
-
task :generate_tokens do
|
15
|
-
puts 'Generating the Ditty tokens'
|
16
|
-
require 'securerandom'
|
17
|
-
File.write('.session_secret', SecureRandom.random_bytes(40)) unless File.file?('.session_secret')
|
18
|
-
File.write('.token_secret', SecureRandom.random_bytes(40)) unless File.file?('.token_secret')
|
19
|
-
end
|
20
|
-
|
21
|
-
desc 'Seed the Ditty database'
|
22
|
-
task :seed do
|
23
|
-
puts 'Seeding the Ditty database'
|
24
|
-
require 'ditty/seed'
|
25
|
-
end
|
26
|
-
|
27
|
-
desc 'Prepare Ditty'
|
28
|
-
task :prep do
|
29
|
-
puts 'Prepare the Ditty folders'
|
30
|
-
Dir.mkdir 'pids' unless File.exist?('pids')
|
31
|
-
|
32
|
-
puts 'Preparing the Ditty public folder'
|
33
|
-
Dir.mkdir 'public' unless File.exist?('public')
|
34
|
-
::Ditty::Components.public_folder.each do |path|
|
35
|
-
puts "Checking #{path}"
|
36
|
-
FileUtils.cp_r "#{path}/.", 'public' unless File.expand_path("#{path}/.").eql? File.expand_path('public')
|
37
|
-
end
|
38
|
-
|
39
|
-
puts 'Preparing the Ditty migrations folder'
|
40
|
-
Dir.mkdir 'migrations' unless File.exist?('migrations')
|
41
|
-
::Ditty::Components.migrations.each do |path|
|
42
|
-
FileUtils.cp_r "#{path}/.", 'migrations' unless File.expand_path("#{path}/.").eql? File.expand_path('migrations')
|
43
|
-
end
|
44
|
-
puts 'Migrations added:'
|
45
|
-
Dir.foreach('migrations').sort.each { |x| puts x if File.file?("migrations/#{x}") && x[-3..-1] == '.rb' }
|
46
|
-
end
|
47
|
-
|
48
|
-
desc 'Migrate Ditty database to latest version'
|
49
|
-
task :migrate do
|
50
|
-
puts 'Running the Ditty migrations'
|
51
|
-
Rake::Task['ditty:migrate:up'].invoke
|
52
|
-
end
|
53
|
-
|
54
|
-
namespace :migrate do
|
55
|
-
require 'logger'
|
56
|
-
|
57
|
-
folder = 'migrations'
|
58
|
-
|
59
|
-
desc 'Check if the migration is current'
|
60
|
-
task :check do
|
61
|
-
::DB.loggers << Logger.new($stdout) if ::DB.loggers.count.zero?
|
62
|
-
puts 'Running Ditty Migrations check'
|
63
|
-
::Sequel.extension :migration
|
64
|
-
begin
|
65
|
-
::Sequel::Migrator.check_current(::DB, folder)
|
66
|
-
puts 'Migrations up to date'
|
67
|
-
rescue Sequel::Migrator::Error => _e
|
68
|
-
puts 'Migrations NOT up to date'
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
desc 'Migrate Ditty database to latest version'
|
73
|
-
task :up do
|
74
|
-
::DB.loggers << Logger.new($stdout) if ::DB.loggers.count.zero?
|
75
|
-
puts 'Running Ditty Migrations up'
|
76
|
-
::Sequel.extension :migration
|
77
|
-
::Sequel::Migrator.apply(::DB, folder)
|
78
|
-
end
|
79
|
-
|
80
|
-
desc 'Remove the whole Ditty database. You WILL lose data'
|
81
|
-
task :down do
|
82
|
-
::DB.loggers << Logger.new($stdout) if ::DB.loggers.count.zero?
|
83
|
-
puts 'Running Ditty Migrations down'
|
84
|
-
::Sequel.extension :migration
|
85
|
-
::Sequel::Migrator.apply(::DB, folder, 0)
|
86
|
-
end
|
87
|
-
|
88
|
-
desc 'Reset the Ditty database. You WILL lose data'
|
89
|
-
task :bounce do
|
90
|
-
::DB.loggers << Logger.new($stdout) if ::DB.loggers.count.zero?
|
91
|
-
puts 'Running Ditty Migrations bounce'
|
92
|
-
::Sequel.extension :migration
|
93
|
-
::Sequel::Migrator.apply(::DB, folder, 0)
|
94
|
-
::Sequel::Migrator.apply(::DB, folder)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
Ditty::Tasks.new.install_tasks
|