connection page working now..
This commit is contained in:
1 parent
6b8c79a9a8
commit
d6cbbff9de
5 files changed
+137
-59
No files matched your search
@@ -14,8 +14,11 @@ class OtheraccountsController< ApplicationController
|
||||
when "new"
|
||||
OtherAccount.create(user_id: current_user.id, email: @email, encrypted_password: @password, type: @account)
|
||||
when "edit"
|
||||
@otheraccount = OtherAccount.where(:type.all => [@account],:user_id.all => [current_user.id])
|
||||
@otheraccount = OtherAccount.where(:type.all => [@account],:user_id.all => [current_user.id]) rescue nil
|
||||
@otheraccount.first.update_attributes(:email => @email, :encrypted_password => @password)
|
||||
when "delete"
|
||||
@otheraccount = OtherAccount.where(:type.all => [@account], :user_id.all => [current_user.id]) rescue nil
|
||||
@otheraccount.destroy_all
|
||||
end
|
||||
a = Array.new
|
||||
a << {"success"=>"true"}
|
||||
@@ -23,19 +26,31 @@ class OtheraccountsController< ApplicationController
|
||||
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 @email, @decrypted_password
|
||||
req.content_type = 'text/xml'
|
||||
@gmailaccount = OtherAccount.where(:type.all => ["gmail"],:user_id.all => [current_user.id]) rescue nil
|
||||
if @gmailaccount.first != nil
|
||||
@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 @email, @decrypted_password
|
||||
req.content_type = 'text/xml'
|
||||
|
||||
http = Net::HTTP.new(url.host, url.port)
|
||||
http.use_ssl = true
|
||||
response = http.start { |http| http.request(req) }
|
||||
http = Net::HTTP.new(url.host, url.port)
|
||||
http.use_ssl = true
|
||||
response = http.start { |http| http.request(req) }
|
||||
|
||||
root = Document.new(response.read_body).root
|
||||
render :text=>root
|
||||
root = Document.new(response.read_body).root
|
||||
render :text=>root
|
||||
else
|
||||
msg = "<HEAD><ERROR>true</ERROR><ERRORMSG>Account setting problem.</ERRORMSG></HEAD>"
|
||||
respond_to do |m|
|
||||
m.xml {render :xml=>msg}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def getaccounts
|
||||
@accounts = OtherAccount.where(:user_id.all => [current_user.id])
|
||||
render :json => @accounts.to_json
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user