Class: LMC::User
- Inherits:
-
Object
- Object
- LMC::User
- Defined in:
- lib/lmc/User.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
TODO: look into hiding password.
Instance Method Summary collapse
-
#initialize(data) ⇒ User
constructor
A new instance of User.
- #request_pw_reset ⇒ Object
-
#update(old_pw) ⇒ Object
current registration process unclear and likely to have changed since this code was written.
Constructor Details
#initialize(data) ⇒ User
Returns a new instance of User.
8 9 10 11 |
# File 'lib/lmc/User.rb', line 8 def initialize(data) @email = data['email'] @password = data['password'] end |
Instance Attribute Details
#email ⇒ Object (readonly)
TODO: look into hiding password
6 7 8 |
# File 'lib/lmc/User.rb', line 6 def email @email end |
Instance Method Details
#request_pw_reset ⇒ Object
33 34 35 36 37 38 |
# File 'lib/lmc/User.rb', line 33 def request_pw_reset action = AuthAction.new Cloud.instance action.type = 'PASSWORD_RESET' action.name = @email action.post end |
#update(old_pw) ⇒ Object
current registration process unclear and likely to have changed since this code was written. def register()
# cloud instance by default authenticates.
# for registration specifically, no authentication is required
# should be possible without email and password for "admin" user
cloud = Cloud.instance
cloud.post ["cloud-service-auth", "users"], {"password" => @password, "email" => @email}
end
23 24 25 26 27 28 29 30 31 |
# File 'lib/lmc/User.rb', line 23 def update(old_pw) cloud = Cloud.instance begin cloud.post ['cloud-service-auth', 'users', 'self', 'password'], 'password' => @password, 'verification' => old_pw rescue RestClient::BadRequest => e response_body = JSON.parse(e.response) raise "#{e.} - #{response_body['message']}" end end |