auto login encryption done…

This commit is contained in:
Harry Bomrah committed 2012-04-30 14:29:42 +08:00
1 parent c158375d02
commit aacd9da9fb
9 files changed
+28 -36

No files matched your search

+8 -2
View File
@@ -9,13 +9,19 @@ class OtheraccountsController< ApplicationController
@email = params['email']
@password = params['password']
@account = params['account']
OtherAccount.new(email: @email, encrypted_password: @password, type: @account)
OtherAccount.create(user_id: current_user.id, email: @email, encrypted_password: @password, type: @account)
a = Array.new
a << {"success"=>"true"}
render :json=>a.to_json
end
def gmail
@gmailaccount = OtherAccount.where(:type.all => ["gmail"],:user_id.all => [current_user.id])
@decrypted_password = @gmailaccount.first.encrypted_password.decrypt
@email = @gmailaccount.first.email
url = URI.parse("https://mail.google.com/mail/feed/atom")
req = Net::HTTP::Get.new(url.path)
req.basic_auth params['username'], params['password']
req.basic_auth @email, @decrypted_password
req.content_type = 'text/xml'
http = Net::HTTP.new(url.host, url.port)