Module: Nova::Starbound::DefaultBehavior::Passwordable
- Included in:
- Nova::Starbound::DefaultBehavior
- Defined in:
- lib/nova/starbound/default_behavior/passwordable.rb
Overview
Handles passwords with the default behavior.
Instance Attribute Summary collapse
-
#password ⇒ nil, String
writeonly
The current password.
Class Method Summary collapse
-
.included(reciever) ⇒ void
When this is included by Nova::Starbound::DefaultBehavior, define the packets nessicary for password management.
Instance Method Summary collapse
-
#authenticated? ⇒ Boolean
Whether or not it was authenticated.
-
#check_password(pass) ⇒ Boolean
Checks to see if the given password is valid.
-
#valid_password?(pass) ⇒ Boolean
Checks to see if the given password is valid.
Instance Attribute Details
#password=(value) ⇒ nil, String (writeonly)
The current password. If it’s nil, any password works; if it’s an empty string, no password works; and if it’s a string, only passwords matching that string works.
13 14 15 |
# File 'lib/nova/starbound/default_behavior/passwordable.rb', line 13 def password=(value) @password = value end |
Class Method Details
.included(reciever) ⇒ void
This method returns an undefined value.
When this is included by Nova::Starbound::DefaultBehavior, define the packets nessicary for password management.
68 69 70 |
# File 'lib/nova/starbound/default_behavior/passwordable.rb', line 68 def self.included(reciever) reciever.handle :packet => :password end |
Instance Method Details
#authenticated? ⇒ Boolean
Whether or not it was authenticated.
40 41 42 |
# File 'lib/nova/starbound/default_behavior/passwordable.rb', line 40 def authenticated? @authenticated end |
#check_password(pass) ⇒ Boolean
Checks to see if the given password is valid. If it is, it sets authenticated to true. Otherwise, sets it to false.
33 34 35 |
# File 'lib/nova/starbound/default_behavior/passwordable.rb', line 33 def check_password(pass) @authenticated = valid_password? pass end |
#valid_password?(pass) ⇒ Boolean
Checks to see if the given password is valid. Returns false if it isn’t, true if it is.
20 21 22 23 24 25 26 |
# File 'lib/nova/starbound/default_behavior/passwordable.rb', line 20 def valid_password?(pass) if password.nil? || (pass == password && password != "") true else false end end |