3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/gitpic/auth.rb', line 3
def self.login(email, password)
token = RestClient.post( "#{Gitpic::HOST}/api/tokens", {
:email => email,
:password => password
})
return false if token.strip == ''
config_dir = File.expand_path('~/.gitpic')
Dir.mkdir config_dir unless Dir.exists?(config_dir)
token_path = config_dir + "/token"
File.delete token_path if File.exists? token_path
token_file = File.new(token_path, "w+")
token_file.write(token)
token_file.write("\n")
token_file.close
true
end
|