Class: Strobe::CLI::Actions::SignupAction

Inherits:
Strobe::CLI::Action show all
Defined in:
lib/strobe/cli/actions.rb

Instance Attribute Summary

Attributes inherited from Strobe::CLI::Action

#actions, #options, #restart, #settings

Instance Method Summary collapse

Methods inherited from Strobe::CLI::Action

#agree, #ask, #choose, #group, #initialize, #password, #resource, run, #run, #save, #say

Constructor Details

This class inherits a constructor from Strobe::CLI::Action

Instance Method Details

#stepsObject



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
# File 'lib/strobe/cli/actions.rb', line 4

def steps
  resource Signup.new :account => { :name => 'default' }

  if settings[:token]
    say "This computer is already registered with a Strobe account."
    unless agree "Signup anyway? [Yn] "
      say "exiting..."
      exit
    end
  end

  say "Please fill out the following information."

  ask :invitation
  ask :email, :into => "user.email"

  group :validate => "user.password" do
    password :password,              :into => "user.password"
    password :password_confirmation, :into => "password_confirmation"
  end

  save :on_error => :restart do
    settings[:token] = resource['user.authentication_token']
    settings.authenticate!
    say "Your account was created successfully."
  end
end