Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add roswell_key and make setup task to generate it

  • Loading branch information...
commit 5ceccc44585fd176ea080492c44f81e5b2751f2a 1 parent 7404dc9
Travis Dunn authored
1  .gitignore
@@ -8,6 +8,7 @@
8 8 /.bundle
9 9
10 10 /config/mongoid.yml
  11 +/config/initializers/roswell_key.rb
11 12
12 13 # Ignore all logfiles and tempfiles.
13 14 /log/*.log
2  app/models/generic_account.rb
@@ -3,7 +3,7 @@ class GenericAccount < BaseItem
3 3 field :username, :type => String
4 4 field :comments, :type => String
5 5
6   - encrypted_field :password, :key => Roswell::Application.config.secret_token
  6 + encrypted_field :password, :key => Roswell::Application.config.roswell_key
7 7
8 8 validates_presence_of :username
9 9
2  app/models/note.rb
@@ -2,6 +2,6 @@ class Note < BaseItem
2 2
3 3 field :body, :type => String
4 4
5   - encrypted_field :body, :key => Roswell::Application.config.secret_token
  5 + encrypted_field :body, :key => Roswell::Application.config.roswell_key
6 6
7 7 end
2  app/models/software_license.rb
@@ -3,6 +3,6 @@ class SoftwareLicense < BaseItem
3 3 field :licensed_to, :type => String
4 4 field :comments, :type => String
5 5
6   - encrypted_field :license_key, :key => Roswell::Application.config.secret_token
  6 + encrypted_field :license_key, :key => Roswell::Application.config.roswell_key
7 7
8 8 end
2  app/models/web_account.rb
@@ -4,7 +4,7 @@ class WebAccount < BaseItem
4 4 field :username, :type => String
5 5 field :comments, :type => String
6 6
7   - encrypted_field :password, :key => Roswell::Application.config.secret_token
  7 + encrypted_field :password, :key => Roswell::Application.config.roswell_key
8 8
9 9 validates_presence_of :username
10 10
27 lib/tasks/setup.rake
... ... @@ -1,7 +1,22 @@
1 1 namespace :roswell do
2 2
  3 + task :create_roswell_key do
  4 + create_roswell_key
  5 + end
  6 +
3 7 desc 'Do initial setup to get roswell up and running'
4   - task :setup => :environment do
  8 + task :setup => [:create_roswell_key, :environment] do
  9 + create_admin_user
  10 + end
  11 +
  12 +end
  13 +
  14 +def create_admin_user
  15 + admin_user = User.where(:admin => true).first
  16 +
  17 + if admin_user
  18 + puts "You already have an admin user, looks like roswell is already setup..."
  19 + else
5 20 puts "You'll need to make an admin user to get started..."
6 21 print "Username: "
7 22 username = STDIN.gets.chomp
@@ -12,5 +27,15 @@ namespace :roswell do
12 27
13 28 puts "Admin user was created, you may now login and add users & groups"
14 29 end
  30 +end
15 31
  32 +def create_roswell_key
  33 + key_path = File.join(Rails.root, 'config/initializers/roswell_key.rb')
  34 +
  35 + if File.exist? key_path
  36 + puts "config/roswell_key.rb already exists"
  37 + else
  38 + puts "Creating config/roswell_key.rb"
  39 + File.open(key_path, 'w') { |file| file.write("Roswell::Application.config.roswell_key = '#{SecureRandom.hex(64)}'") }
  40 + end
16 41 end

0 comments on commit 5ceccc4

Please sign in to comment.
Something went wrong with that request. Please try again.