diff --git a/app/controllers/spreadsheets_controller.rb b/app/controllers/spreadsheets_controller.rb index c823cdc..d421ba7 100644 --- a/app/controllers/spreadsheets_controller.rb +++ b/app/controllers/spreadsheets_controller.rb @@ -17,9 +17,7 @@ def new # Spreadsheets from google @spreadsheets = get_spreadsheets(spreadsheet) @token = spreadsheet.access_token - @msg = 'work' else - @msg = 'no work' # Handle if data does not get saved end end @@ -28,7 +26,6 @@ def edit token = spreadsheet_params['token'] spreadsheet = Spreadsheet.where(access_token: token)[0] spreadsheet.add_spreadsheet_credentials(spreadsheet_params) - #binding.pry spreadsheet.save @spreadsheets = Spreadsheet.all.to_a @@ -51,4 +48,12 @@ def destroy def spreadsheet_params params.permit(:title, :id, :token) end + + def failure + if params['message'].match('access_denied') + @msg = "Account integration Failed. User Refused to grant permissions" + end + @spreadsheets = Spreadsheet.all.to_a + render action: 'index' + end end diff --git a/app/views/spreadsheets/index.html.haml b/app/views/spreadsheets/index.html.haml index ec9f293..a62fe7e 100644 --- a/app/views/spreadsheets/index.html.haml +++ b/app/views/spreadsheets/index.html.haml @@ -1,3 +1,4 @@ += @msg if @msg %h4 =link_to 'Add New Spreadsheet', 'auth/google/' diff --git a/config/initializers/google_oauth.rb b/config/initializers/google_oauth.rb index 69265b6..4cde5db 100644 --- a/config/initializers/google_oauth.rb +++ b/config/initializers/google_oauth.rb @@ -4,7 +4,10 @@ name: 'google', scope: 'userinfo.profile,userinfo.email,drive,https://spreadsheets.google.com/feeds', prompt: 'consent', - access_type: 'offline', - #redirect_uri: 'http://localhost:8080/auth/google/spreadsheets' + access_type: 'offline' } -end \ No newline at end of file +end + +OmniAuth.config.on_failure = Proc.new { |env| + OmniAuth::FailureEndpoint.new(env).redirect_to_failure +} \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 3e337c7..f28f4ee 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,7 @@ Rails.application.routes.draw do - get '/auth/:provider/callback', to: 'spreadsheets#new' + get '/auth/:provider/callback', to: 'spreadsheets#new' + get '/auth/failure', to: 'spreadsheets#failure' resources :users, :newsletters, :home, :spreadsheets root :to => 'home#index' diff --git a/spec/controllers/google_auth_response.json b/spec/controllers/google_auth_response.json new file mode 100644 index 0000000..8473da2 --- /dev/null +++ b/spec/controllers/google_auth_response.json @@ -0,0 +1,12 @@ +HTTP/1.1 302 Found +Content-Length: 537 +Location: https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=367225507767-119uvbhdadqbft2kn4759rodoiivksn9.apps.googleusercontent.com&prompt=consent&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fauth%2Fgoogle%2Fcallback&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive+https%3A%2F%2Fspreadsheets.google.com%2Ffeeds&state=df37c7da59cf8f7a4899cd5a67a612e9d18946664bc98d4f +Cache-Control: no-cache +X-Request-Id: b511bdb4-c778-4f1a-b5d7-849f1402b1a3 +X-Runtime: 0.003534 +Server: WEBrick/1.3.1 (Ruby/2.1.2/2014-05-08) +Date: Thu, 10 Jul 2014 10:39:34 GMT +Connection: Keep-Alive +Set-Cookie: _lightair_session=Uy9SNDQ1LzZFandLd1g4S2VVTEptR3ZRa0RBcnNFWGtZbG1VZmNKMzc5Z1F6cDFuaHBCa2lScHcxL1FBQ044RTJZMU9iUWF2UitaVjQxcGVzeUZwS0Q3NkdXdzg2SHB6S0IrcU1sR2ExelhRRVZuWFF6MFpraktBMTNCcTM4UVZ5a01ReitYSzNYT2M0dXR1NWViUjhvVGVxUnYwRUtLREtoQUVjMkJPMW1PZG14MUVUQlN0Q2hkRUh5blVLMDZRLS1OZ3JGQXFWQmJKMGNCWGszQWoyMkNRPT0%3D--8345e9f7215c9ef812febd3588c505cfaef628c1; path=/; HttpOnly + +Redirecting to https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=367225507767-119uvbhdadqbft2kn4759rodoiivksn9.apps.googleusercontent.com&prompt=consent&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fauth%2Fgoogle%2Fcallback&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive+https%3A%2F%2Fspreadsheets.google.com%2Ffeeds&state=df37c7da59cf8f7a4899cd5a67a612e9d18946664bc98d4f... diff --git a/spec/controllers/host_response.json b/spec/controllers/host_response.json new file mode 100644 index 0000000..f76a7f1 --- /dev/null +++ b/spec/controllers/host_response.json @@ -0,0 +1,121 @@ +HTTP/1.1 200 OK +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 1; mode=block +X-Content-Type-Options: nosniff +Content-Type: text/html; charset=utf-8 +Etag: "b29936011c26adc86d08ede08dc03e1e" +Cache-Control: max-age=0, private, must-revalidate +X-Request-Id: cdc9c224-e586-409f-adfb-8367d40f8a41 +X-Runtime: 0.015686 +Server: WEBrick/1.3.1 (Ruby/2.1.2/2014-05-08) +Date: Thu, 10 Jul 2014 10:21:40 GMT +Content-Length: 4406 +Connection: Keep-Alive +Set-Cookie: request_method=GET; path=/ +Set-Cookie: _lightair_session=aUVDRko5L1dYOFJqN2NvNmg2NkI3b2JwN01GRXduamtJdFhmM3hoU0dkR2U3WkpLS2ZUUFlqRWppOGg1NHBPYllDaVpDM2w5d0xxVlBuRFJjaHVFa0FaRVdXOUdQWDlFSGJoaUZTYkdtQnl0N3F3OVdQd1c0YU5rZjNQZ09JcTFmck1HenpMbnhxaHFRT091SnZkdUZRPT0tLTVuczRGVTZyNHdwWXVaZmliU0VxZ0E9PQ%3D%3D--f5a6ab0bbbd0ec42bc63ca27924361e391dd36b3; path=/; HttpOnly + + + + + Lightair + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + +
+
+
+

Insight of LightAir

+

LightAir is a mass Mailer designed to send newsletters designed in html to be sent to a few hundered to a tens of thousands of subscribers. It has an inbuilt HTML editor to create a newsletter online.

+
+
+
+
+ +