Sha256: 786e626aa738bfeda6a7d93bf6d51d78f9a2d9243c2240c99b107dc374e807de
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
module Fourteeninch class Auth def self.auth(re_auth = false) Fourteeninch.load_settings if !re_auth if re_auth || !(Fourteeninch.api_key && Fourteeninch.api_secret) print 'Enter your fourteeninch e-mail: ' email = $stdin.gets.chomp print 'Enter your fourteeninch password: ' system 'stty -echo' password = $stdin.gets.chomp system 'stty echo' puts "\nAuthorizing..." if (auth = Fourteeninch::Client.auth(email, password)) && (auth.is_a?(Hash)) && (auth.has_key?('api_key')) && (auth.has_key?('api_secret')) File.open(Fourteeninch.settings_file,'w') do|file| Marshal.dump({:api_key => auth['api_key'], :api_secret => auth['api_secret']}, file) end puts "=> You have been authorized. Make sure you log out after finished" if re_auth return true else puts auth['error'] || "Could not authorize, check your e-mail or password." return false end else return true end end def self.logout File.delete(Fourteeninch.settings_file) if File.exist?(Fourteeninch.settings_file) puts "" puts "You have been logged out." end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fourteeninch-0.1.0 | lib/fourteeninch/auth.rb |