gdrivestrg 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/assets/javascripts/gdrivestrg/google_login.js +14 -0
- data/app/assets/javascripts/gdrivestrg/google_login.js~ +6 -0
- data/app/assets/javascripts/gdrivestrg.js +1 -0
- data/app/assets/javascripts/gdrivestrg.js~ +0 -0
- data/app/controllers/gdrivestrg/omniauth_callbacks_controller.rb +29 -0
- data/app/controllers/gdrivestrg/omniauth_callbacks_controller.rb~ +29 -0
- data/app/views/gdrivestrg/_login.html.erb +3 -0
- data/app/views/gdrivestrg/_login.html.erb~ +3 -0
- data/lib/gdrivestrg/version.rb +1 -1
- metadata +10 -2
@@ -0,0 +1,14 @@
|
|
1
|
+
function google_login(login_url, test_url, redirect_url) {
|
2
|
+
var left = (screen.width/2)-(640/2);
|
3
|
+
var top = (screen.height/2)-(480/2);
|
4
|
+
var win = window.open(login_url, "googlelogin", 'width=700, height=480, left='+left+', top='+top);
|
5
|
+
var pollTimer = window.setInterval(function() {
|
6
|
+
if (win.document.URL.indexOf(test_url) != -1) {
|
7
|
+
window.clearInterval(pollTimer);
|
8
|
+
win.close();
|
9
|
+
|
10
|
+
window.location = redirect_url;
|
11
|
+
}
|
12
|
+
}, 500);
|
13
|
+
}
|
14
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require_tree .
|
File without changes
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'cloudstrg/cloudstrg'
|
2
|
+
|
3
|
+
class Gdrivestrg::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
4
|
+
def google_oauth2
|
5
|
+
# You need to implement the method below in your model (e.g. app/models/user.rb)
|
6
|
+
@user = Kernel.const_get(Gdrivestrg.user_class).find_for_google_oauth2(request.env["omniauth.auth"], current_user)
|
7
|
+
|
8
|
+
if @user.persisted?
|
9
|
+
|
10
|
+
_params = {:user => @user,
|
11
|
+
:plugin_id => Cloudstrg::Cloudstrgplugin.find_by_plugin_name("gdrive"),
|
12
|
+
:redirect => "#{request.protocol}#{request.host_with_port}/users/auth/google_oauth2/callback",
|
13
|
+
:refresh_token => request.env["omniauth.auth"].credentials["refresh_token"],
|
14
|
+
:access_token => request.env["omniauth.auth"].credentials["token"],
|
15
|
+
:expires_in => request.env["omniauth.auth"].credentials["expires_at"],
|
16
|
+
:session => session}
|
17
|
+
|
18
|
+
driver = CloudStrg.new_driver _params
|
19
|
+
_session, url = driver.config _params
|
20
|
+
session.merge!(_session)
|
21
|
+
|
22
|
+
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Google"
|
23
|
+
sign_in_and_redirect @user, :event => :authentication
|
24
|
+
else
|
25
|
+
session["devise.google_data"] = request.env["omniauth.auth"]
|
26
|
+
redirect_to new_user_registration_url
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'cloudstrg/cloudstrg'
|
2
|
+
|
3
|
+
class Gdrivestrg::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
4
|
+
def google_oauth2
|
5
|
+
# You need to implement the method below in your model (e.g. app/models/user.rb)
|
6
|
+
@user = Kernel.const_get(Gdrivestrg.user_class).find_for_google_oauth2(request.env["omniauth.auth"], current_user)
|
7
|
+
|
8
|
+
if @user.persisted?
|
9
|
+
|
10
|
+
_params = {:user => @user,
|
11
|
+
:plugin_id => Cloudstrg::Cloudstrgplugin.find_by_plugin_name("gdrive"),
|
12
|
+
:redirect => "#{request.protocol}#{request.host_with_port}/users/auth/google_oauth2/callback",
|
13
|
+
:refresh_token => request.env["omniauth.auth"].credentials["refresh_token"],
|
14
|
+
:access_token => request.env["omniauth.auth"].credentials["token"],
|
15
|
+
:expires_in => request.env["omniauth.auth"].credentials["expires_at"],
|
16
|
+
:session => session}
|
17
|
+
|
18
|
+
driver = CloudStrg.new_driver _params
|
19
|
+
_session, url = driver.config _params
|
20
|
+
session.merge!(_session)
|
21
|
+
|
22
|
+
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Google"
|
23
|
+
sign_in_and_redirect @user, :event => :authentication
|
24
|
+
else
|
25
|
+
session["devise.google_data"] = request.env["omniauth.auth"]
|
26
|
+
redirect_to new_user_registration_url
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,3 @@
|
|
1
|
+
<%- if devise_mapping.omniauthable? %>
|
2
|
+
<a href='#' onclick="js:google_login('<%= omniauth_authorize_path(resource_name, :google_oauth2) %>', '<%= "#{request.protocol}#{request.host_with_port}" %>', '<%= "#{request.protocol}#{request.host_with_port}" %>');" class="btn-large btn-info" id="btn-sign_in"><%= "Sign in with Google" %></a>
|
3
|
+
<% end -%>
|
@@ -0,0 +1,3 @@
|
|
1
|
+
<%- if devise_mapping.omniauthable? %>
|
2
|
+
<a href='#' onclick="js:login('<%= omniauth_authorize_path(resource_name, :google_oauth2) %>', '<%= "#{request.protocol}#{request.host_with_port}" %>', '<%= "#{request.protocol}#{request.host_with_port}" %>');" class="btn-large btn-info" id="btn-sign_in"><%= "Sign in with Google" %></a>
|
3
|
+
<% end -%>
|
data/lib/gdrivestrg/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gdrivestrg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -93,14 +93,22 @@ files:
|
|
93
93
|
- app/assets/stylesheets/scaffold.css
|
94
94
|
- app/assets/stylesheets/gdrivestrg/params.css
|
95
95
|
- app/assets/stylesheets/gdrivestrg/application.css
|
96
|
+
- app/assets/javascripts/gdrivestrg.js~
|
97
|
+
- app/assets/javascripts/gdrivestrg.js
|
98
|
+
- app/assets/javascripts/gdrivestrg/google_login.js~
|
96
99
|
- app/assets/javascripts/gdrivestrg/params.js
|
97
100
|
- app/assets/javascripts/gdrivestrg/application.js
|
101
|
+
- app/assets/javascripts/gdrivestrg/google_login.js
|
102
|
+
- app/views/gdrivestrg/_login.html.erb
|
103
|
+
- app/views/gdrivestrg/_login.html.erb~
|
98
104
|
- app/views/gdrivestrg/params/new.html.erb
|
99
105
|
- app/views/gdrivestrg/params/show.html.erb
|
100
106
|
- app/views/gdrivestrg/params/edit.html.erb
|
101
107
|
- app/views/gdrivestrg/params/_form.html.erb
|
102
108
|
- app/views/gdrivestrg/params/index.html.erb
|
103
109
|
- app/views/layouts/gdrivestrg/application.html.erb
|
110
|
+
- app/controllers/gdrivestrg/omniauth_callbacks_controller.rb
|
111
|
+
- app/controllers/gdrivestrg/omniauth_callbacks_controller.rb~
|
104
112
|
- app/controllers/gdrivestrg/application_controller.rb
|
105
113
|
- app/controllers/gdrivestrg/params_controller.rb
|
106
114
|
- config/routes.rb
|