-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_generator.rb
More file actions
39 lines (29 loc) · 1.2 KB
/
install_generator.rb
File metadata and controls
39 lines (29 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# frozen_string_literal: true
require "rails/generators"
module Devise
module Webauthn
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path("templates", __dir__)
desc "Install Devise::Webauthn configuration into your application"
class_option :resource_name, type: :string, default: "user", desc: "The resource name for Devise (default: user)"
def install
say "Installing DeviseWebauthn configuration...", :green
template "webauthn.rb", "config/initializers/webauthn.rb"
say "Created initializer: config/initializers/webauthn.rb", :green
end
def generate_webauthn_credential_model
invoke "devise:webauthn:webauthn_credential_model", [], resource_name: options[:resource_name]
end
def generate_webauthn_id_column
invoke "devise:webauthn:webauthn_id", [], resource_name: options[:resource_name]
end
def generate_javascript_configuration
invoke "devise:webauthn:javascript_configuration"
end
def final_message
say "\nAlmost done! Now edit `config/initializers/webauthn.rb` and set the `allowed_origins` for your app.",
:yellow
end
end
end
end