Browse Source
Add generators to make it easier to install and fix deprecation warningsfor_activeadmin
8 changed files with 100 additions and 36 deletions
@ -0,0 +1,8 @@
|
||||
class TwoFactorAuthenticationAddTo<%= table_name.camelize %> < ActiveRecord::Migration |
||||
def change |
||||
change_table :<%= table_name %> do |t| |
||||
t.string :second_factor_pass_code , :limit => 32 |
||||
t.integer :second_factor_attempts_count, :default => 0 |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,14 @@
|
||||
require 'rails/generators/active_record' |
||||
|
||||
module ActiveRecord |
||||
module Generators |
||||
class TwoFactorAuthenticationGenerator < ActiveRecord::Generators::Base |
||||
source_root File.expand_path("../templates", __FILE__) |
||||
|
||||
def copy_two_factor_authentication_migration |
||||
migration_template "migration.rb", "db/migrate/two_factor_authentication_add_to_#{table_name}" |
||||
end |
||||
|
||||
end |
||||
end |
||||
end |
@ -0,0 +1,17 @@
|
||||
module TwoFactorAuthenticatable |
||||
module Generators |
||||
class TwoFactorAuthenticationGenerator < Rails::Generators::NamedBase |
||||
namespace "two_factor_authentication" |
||||
|
||||
desc "Adds :two_factor_authenticable directive in the given model. It also generates an active record migration." |
||||
|
||||
def inject_two_factor_authentication_content |
||||
path = File.join("app", "models", "#{file_path}.rb") |
||||
inject_into_file(path, "two_factor_authenticatable, :", :after => "devise :") if File.exists?(path) |
||||
end |
||||
|
||||
hook_for :orm |
||||
|
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue