Top Level Namespace

Defined Under Namespace

Modules: Rise

Constant Summary collapse

RISE_DATA_DIR =
File.join(Dir.home, '.rise')
DOMAIN =
'rise.sh'.freeze
AUTH_PORT =
4567.freeze
UPLOAD_PORT =
8080.freeze

Instance Method Summary collapse

Instance Method Details

#login ⇒ Object

DO NOT USE



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/core/util.rb', line 79

def 

  print '\nEmail: '
  email = gets.chomp!
  print '\nPassword: '
  password = STDIN.noecho(&:gets)
  hash = Digest::SHA256.hexdigest(password)
  res = HTTP.post("http://#{DOMAIN}:#{AUTH_PORT}/login?email=#{email}&hash=#{hash}")
  if res.code == 200
    puts Paint['\nLogin successful!', :green, :bold]
  else
    puts Paint['\nLogin failed!', :red, :bold]
    puts "Printing error: #{res.code}: #{res.body}"
  end
end

#signup ⇒ Object

DO NOT USE



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/core/util.rb', line 96

def 
  print '\nEmail: '
  email = gets.chomp!
  print '\nPassword: '
  password = STDIN.noecho(&:gets)
  hash = Digest::SHA256.hexdigest(password)
  res = HTTP.post("http://#{DOMAIN}:#{AUTH_PORT}/signup?email=#{email}&hash=#{hash}")
  if res.code == 200
    puts Paint['\nSignup successful!', :green, :bold]
    File.open(File.join(RISE_DATA_DIR, 'auth', 'creds.json'), 'a') do |f|
      creds_hash = {
        'email' => email,
        'hash'  => hash
      }
      f.puts(creds_hash.to_json)
    end
  elsif res.code == 409  # user already exists

    puts Paint['\nSignup failed!', :red, :bold]
    puts "Printing error: #{res.body}"
  end
end