cartoonist 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,37 @@
1
+ class Admin::OmniauthCallbacksController < Devise::OmniauthCallbacksController
2
+ include Devise::Controllers::Rememberable
3
+ skip_before_filter :verify_authenticity_token
4
+
5
+ def failure
6
+ if current_user
7
+ set_flash_message(:message, :failure, :kind => "GMail", :reason => "association failed") if is_navigational_format?
8
+ redirect_to "/admin/accounts/#{current_user.id}"
9
+ else
10
+ set_flash_message(:notice, :failure, :kind => "GMail", :reason => "login failed") if is_navigational_format?
11
+ redirect_to "/admin"
12
+ end
13
+ end
14
+
15
+ def google
16
+ auth = request.env["omniauth.auth"]
17
+ user = User.from_auth auth
18
+
19
+ if current_user
20
+ if !user
21
+ current_user.save_auth! auth
22
+ set_flash_message(:message, :success, :kind => "GMail") if is_navigational_format?
23
+ return redirect_to "/admin/accounts/#{current_user.id}"
24
+ end
25
+ end
26
+
27
+ if user
28
+ sign_in user, :event => :authentication
29
+ remember_me user
30
+ set_flash_message(:message, :success, :kind => "GMail") if is_navigational_format?
31
+ else
32
+ set_flash_message(:notice, :failure, :kind => "GMail", :reason => "login failed") if is_navigational_format?
33
+ end
34
+
35
+ redirect_to "/admin"
36
+ end
37
+ end
data/app/models/user.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class User < ActiveRecord::Base
2
- devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable
2
+ devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable, :omniauthable
3
3
 
4
4
  # Setup accessible (or protected) attributes for your model
5
5
  attr_accessible :email, :password, :password_confirmation, :remember_me, :name
@@ -8,6 +8,12 @@ class User < ActiveRecord::Base
8
8
  name
9
9
  end
10
10
 
11
+ def save_auth!(auth)
12
+ self.provider = auth.provider
13
+ self.uid = auth.uid
14
+ save!
15
+ end
16
+
11
17
  class << self
12
18
  def create_user(params)
13
19
  create :email => params[:email], :name => params[:name], :password => params[:password], :password_confirmation => params[:confirm_password]
@@ -30,5 +36,9 @@ class User < ActiveRecord::Base
30
36
  user.save!
31
37
  user
32
38
  end
39
+
40
+ def from_auth(auth)
41
+ where(:provider => auth.provider, :uid => auth.uid).first
42
+ end
33
43
  end
34
44
  end
@@ -1,3 +1,30 @@
1
+ <% if @user == current_user %>
2
+ <% if current_user.provider %>
3
+ <p>
4
+ <%= t "accounts.show.associated.prefix" %>
5
+ <strong><%= current_user.provider %></strong>
6
+ <%= t "accounts.show.associated.suffix" %>
7
+ </p>
8
+
9
+ <p>
10
+ <a href="/users/auth/google">
11
+ <%= t "accounts.show.reassociate", :provider => "GMail" %>
12
+ </a>
13
+
14
+ <br />
15
+ <small>
16
+ <%= t "accounts.show.reassociation_warning", :provider => "GMail" %>
17
+ </small>
18
+ </p>
19
+ <% else %>
20
+ <p>
21
+ <a href="/users/auth/google">
22
+ <%= t "accounts.show.associate", :provider => "GMail" %>
23
+ </a>
24
+ </p>
25
+ <% end %>
26
+ <% end %>
27
+
1
28
  <p>
2
29
  <a href="/admin/accounts/<%= @user.id %>/edit"><%= t "accounts.show.edit" %></a>
3
30
  </p>
data/cartoonist.gemspec CHANGED
@@ -11,9 +11,10 @@ Gem::Specification.new do |s|
11
11
  s.require_paths = ["lib"]
12
12
  s.homepage = "http://reasonnumber.com/cartoonist"
13
13
  s.add_dependency "devise", "~> 2.1.2"
14
- s.add_dependency "jquery-rails", "~> 2.1.3"
15
- s.add_dependency "railties", "~> 3.2.8"
14
+ s.add_dependency "jquery-rails", "~> 2.1.4"
15
+ s.add_dependency "omniauth-openid", "~> 1.0.1"
16
+ s.add_dependency "railties", "~> 3.2.9"
16
17
  s.add_dependency "redcarpet", "~> 2.2.2"
17
18
  s.add_dependency "rubyzip", "~> 0.9.9"
18
- s.add_dependency "minitar", "~> 0.5.3"
19
+ s.add_dependency "minitar", "~> 0.5.4"
19
20
  end
@@ -23,9 +23,15 @@ en:
23
23
  save: Save
24
24
  subtitle: New Account
25
25
  show:
26
+ associate: Associate with %{provider}
27
+ associated:
28
+ prefix: This user associated with
29
+ suffix: ""
26
30
  edit: edit
27
31
  email: "Email:"
28
32
  name: "Name:"
33
+ reassociate: Change %{provider} association
34
+ reassociation_warning: (Only a GMail account not yet associated will work)
29
35
  admin:
30
36
  accounts:
31
37
  layout:
@@ -0,0 +1,10 @@
1
+ class AddOmniautableToUsers < ActiveRecord::Migration
2
+ def change
3
+ change_table :users do |t|
4
+ t.string :provider
5
+ t.string :uid
6
+ end
7
+
8
+ add_index :users, [:provider, :uid], :unique => true
9
+ end
10
+ end
data/lib/cartoonist.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require "devise"
2
+ require "omniauth-openid"
3
+ require "openid/store/filesystem"
2
4
  require "jquery-rails"
3
5
  require "redcarpet"
4
6
  require "zlib"
@@ -217,6 +217,8 @@ module Cartoonist
217
217
  # manager.intercept_401 = false
218
218
  # manager.default_strategies(:scope => :user).unshift :some_external_strategy
219
219
  # end
220
+
221
+ devise_config.omniauth :openid, :name => "google", :identifier => "https://www.google.com/accounts/o8/id", :store => OpenID::Store::Filesystem.new("/tmp")
220
222
  end
221
223
 
222
224
  config.before_initialize do
@@ -231,6 +233,9 @@ module Cartoonist
231
233
  else
232
234
  Rails.application.config.exceptions_app = ActionDispatch::PublicExceptions.new(File.join File.dirname(__FILE__), "../../public/errors")
233
235
  end
236
+
237
+ # Public expire headers causes our action to not be called until cache expires
238
+ Rails.application.config.action_dispatch.rack_cache = nil
234
239
  end
235
240
 
236
241
  config.to_prepare do
@@ -328,7 +333,7 @@ module Cartoonist
328
333
  end
329
334
  end
330
335
 
331
- devise_for :users
336
+ devise_for :users, :controllers => { :omniauth_callbacks => "admin/omniauth_callbacks" }
332
337
 
333
338
  namespace :admin do
334
339
  resources :accounts, :only => [:create, :destroy, :edit, :index, :show, :update]
@@ -2,7 +2,7 @@ module Cartoonist
2
2
  class Version
3
3
  class << self
4
4
  def to_s
5
- "0.0.15"
5
+ "0.0.16"
6
6
  end
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,92 +1,108 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: cartoonist
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.15
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
5
+ version: 0.0.16
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Mike Virata-Stone
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-15 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
12
+
13
+ date: 2012-12-15 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
15
16
  name: devise
16
- requirement: &7553340 !ruby/object:Gem::Requirement
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
17
19
  none: false
18
- requirements:
20
+ requirements:
19
21
  - - ~>
20
- - !ruby/object:Gem::Version
22
+ - !ruby/object:Gem::Version
21
23
  version: 2.1.2
22
24
  type: :runtime
23
- prerelease: false
24
- version_requirements: *7553340
25
- - !ruby/object:Gem::Dependency
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
26
27
  name: jquery-rails
27
- requirement: &7552780 !ruby/object:Gem::Requirement
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
28
30
  none: false
29
- requirements:
31
+ requirements:
30
32
  - - ~>
31
- - !ruby/object:Gem::Version
32
- version: 2.1.3
33
+ - !ruby/object:Gem::Version
34
+ version: 2.1.4
33
35
  type: :runtime
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: omniauth-openid
34
39
  prerelease: false
35
- version_requirements: *7552780
36
- - !ruby/object:Gem::Dependency
37
- name: railties
38
- requirement: &7552140 !ruby/object:Gem::Requirement
40
+ requirement: &id003 !ruby/object:Gem::Requirement
39
41
  none: false
40
- requirements:
42
+ requirements:
41
43
  - - ~>
42
- - !ruby/object:Gem::Version
43
- version: 3.2.8
44
+ - !ruby/object:Gem::Version
45
+ version: 1.0.1
44
46
  type: :runtime
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: railties
45
50
  prerelease: false
46
- version_requirements: *7552140
47
- - !ruby/object:Gem::Dependency
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: 3.2.9
57
+ type: :runtime
58
+ version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
48
60
  name: redcarpet
49
- requirement: &7551060 !ruby/object:Gem::Requirement
61
+ prerelease: false
62
+ requirement: &id005 !ruby/object:Gem::Requirement
50
63
  none: false
51
- requirements:
64
+ requirements:
52
65
  - - ~>
53
- - !ruby/object:Gem::Version
66
+ - !ruby/object:Gem::Version
54
67
  version: 2.2.2
55
68
  type: :runtime
56
- prerelease: false
57
- version_requirements: *7551060
58
- - !ruby/object:Gem::Dependency
69
+ version_requirements: *id005
70
+ - !ruby/object:Gem::Dependency
59
71
  name: rubyzip
60
- requirement: &7550120 !ruby/object:Gem::Requirement
72
+ prerelease: false
73
+ requirement: &id006 !ruby/object:Gem::Requirement
61
74
  none: false
62
- requirements:
75
+ requirements:
63
76
  - - ~>
64
- - !ruby/object:Gem::Version
77
+ - !ruby/object:Gem::Version
65
78
  version: 0.9.9
66
79
  type: :runtime
67
- prerelease: false
68
- version_requirements: *7550120
69
- - !ruby/object:Gem::Dependency
80
+ version_requirements: *id006
81
+ - !ruby/object:Gem::Dependency
70
82
  name: minitar
71
- requirement: &7549260 !ruby/object:Gem::Requirement
83
+ prerelease: false
84
+ requirement: &id007 !ruby/object:Gem::Requirement
72
85
  none: false
73
- requirements:
86
+ requirements:
74
87
  - - ~>
75
- - !ruby/object:Gem::Version
76
- version: 0.5.3
88
+ - !ruby/object:Gem::Version
89
+ version: 0.5.4
77
90
  type: :runtime
78
- prerelease: false
79
- version_requirements: *7549260
91
+ version_requirements: *id007
80
92
  description: This provides the main functionality and plugin api for Cartoonist.
81
93
  email: reasonnumber@gmail.com
82
94
  executables: []
95
+
83
96
  extensions: []
97
+
84
98
  extra_rdoc_files: []
85
- files:
99
+
100
+ files:
86
101
  - app/assets/javascripts/cartoonist.js.erb
87
102
  - app/assets/stylesheets/admin.css.scss
88
103
  - app/controllers/admin/accounts_controller.rb
89
104
  - app/controllers/admin/cache_controller.rb
105
+ - app/controllers/admin/omniauth_callbacks_controller.rb
90
106
  - app/controllers/admin/search_controller.rb
91
107
  - app/controllers/admin/settings_controller.rb
92
108
  - app/controllers/admin/static_cache_controller.rb
@@ -137,6 +153,7 @@ files:
137
153
  - db/migrate/20120401014029_create_settings.rb
138
154
  - db/migrate/20120417075756_devise_create_users.rb
139
155
  - db/migrate/20120524032959_add_extension_to_database_files.rb
156
+ - db/migrate/20121205091909_add_omniautable_to_users.rb
140
157
  - lib/cartoonist.rb
141
158
  - lib/cartoonist/engine.rb
142
159
  - lib/cartoonist/version.rb
@@ -145,26 +162,30 @@ files:
145
162
  - public/errors/500.html
146
163
  homepage: http://reasonnumber.com/cartoonist
147
164
  licenses: []
165
+
148
166
  post_install_message:
149
167
  rdoc_options: []
150
- require_paths:
168
+
169
+ require_paths:
151
170
  - lib
152
- required_ruby_version: !ruby/object:Gem::Requirement
171
+ required_ruby_version: !ruby/object:Gem::Requirement
153
172
  none: false
154
- requirements:
155
- - - ! '>='
156
- - !ruby/object:Gem::Version
157
- version: '0'
158
- required_rubygems_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: "0"
177
+ required_rubygems_version: !ruby/object:Gem::Requirement
159
178
  none: false
160
- requirements:
161
- - - ! '>='
162
- - !ruby/object:Gem::Version
163
- version: '0'
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: "0"
164
183
  requirements: []
184
+
165
185
  rubyforge_project:
166
- rubygems_version: 1.8.17
186
+ rubygems_version: 1.8.24
167
187
  signing_key:
168
188
  specification_version: 3
169
189
  summary: Cartoonist Core
170
190
  test_files: []
191
+