Class: Tane::Helpers::Cloudfuji
- Inherits:
-
Object
- Object
- Tane::Helpers::Cloudfuji
- Includes:
- Tane::Helpers
- Defined in:
- lib/tane/helpers/cloudfuji_helper.rb
Class Method Summary collapse
- .authenticate_user(email, password) ⇒ Object
- .cloudfuji_url ⇒ Object
- .signup(email, password) ⇒ Object
-
.verify_credentials(email, password) ⇒ Object
Returns nil if credentials are invalid Returns the authentication_token if credentials are valid.
Methods included from Tane::Helpers
Class Method Details
.authenticate_user(email, password) ⇒ Object
45 46 47 |
# File 'lib/tane/helpers/cloudfuji_helper.rb', line 45 def authenticate_user(email, password) warn_if_credentials end |
.cloudfuji_url ⇒ Object
5 6 7 |
# File 'lib/tane/helpers/cloudfuji_helper.rb', line 5 def cloudfuji_url ENV['CLOUDFUJI_URL'] || "http://cloudfuji.com" end |
.signup(email, password) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/tane/helpers/cloudfuji_helper.rb', line 24 def signup(email, password) term.say "Contacting cloudfuji..." term.say "(using #{cloudfuji_url}/users/create.json)" begin result = JSON(RestClient.get("#{cloudfuji_url}/users/create.json", { :params => {:email => email, :password => password }})) if result['errors'].nil? return result['authentication_token'], nil else return nil, result['errors'] end rescue => e if e.respond_to?(:http_body) return nil, [["", [JSON(e.http_body)['error']]]] end return nil end end |
.verify_credentials(email, password) ⇒ Object
Returns nil if credentials are invalid Returns the authentication_token if credentials are valid
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/tane/helpers/cloudfuji_helper.rb', line 11 def verify_credentials(email, password) begin result = JSON(RestClient.get("#{cloudfuji_url}/users/verify.json", { :params => {:email => email, :password => password }})) if result['errors'].nil? return result['authentication_token'], nil else return nil, result['errors'] end rescue => e return nil, ["Couldn't login with those credentials!"] end end |