Class: MainTerminal
- Inherits:
-
ApplicationTerminal
- Object
- ApplicationTerminal
- MainTerminal
- Defined in:
- lib/generators/terminalwire/install/templates/main_terminal.rb
Instance Method Summary collapse
Instance Method Details
#hello(name) ⇒ Object
3 4 5 |
# File 'lib/generators/terminalwire/install/templates/main_terminal.rb', line 3 def hello(name) puts "Hello #{name}" end |
#login ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/generators/terminalwire/install/templates/main_terminal.rb', line 8 def login print "Email: " email = gets.chomp print "Password: " password = getpass # Replace this with your own authentication logic; this is an example # of how you might do this with Devise. user = User.find_for_authentication(email: email) if user && user.valid_password?(password) self.current_user = user puts "Successfully logged in as #{current_user.email}." else fail "Could not find a user with that email and password." end end |
#logout ⇒ Object
36 37 38 39 |
# File 'lib/generators/terminalwire/install/templates/main_terminal.rb', line 36 def logout session.reset puts "Successfully logged out." end |
#whoami ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/generators/terminalwire/install/templates/main_terminal.rb', line 27 def whoami if self.current_user puts "Logged in as #{current_user.email}." else fail "Not logged in. Run `#{self.class.basename} login` to login." end end |