headstart 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/app/controllers/headstart/sessions_controller.rb +4 -3
- data/app/models/generic_mailer.rb +3 -9
- data/app/views/sessions/new.html.erb +5 -9
- data/app/views/users/_form.html.erb +6 -0
- data/app/views/users/edit.html.erb +1 -1
- data/app/views/users/new.html.erb +1 -1
- data/app/views/users/show.html.erb +3 -1
- data/generators/headstart/headstart_generator.rb +2 -0
- data/generators/headstart/templates/_woopra.html.erb +1 -1
- data/generators/headstart/templates/app/helpers/users_helper.rb +10 -0
- data/generators/headstart/templates/application.html.erb +2 -2
- data/generators/headstart/templates/headstart.rb +1 -0
- data/generators/headstart/templates/headstart.yml +26 -12
- data/generators/headstart/templates/migrations/create_users.rb +7 -0
- data/generators/headstart/templates/user.rb +4 -0
- data/lib/headstart/authentication.rb +10 -3
- data/lib/headstart/configuration.rb +1 -0
- data/lib/headstart/user.rb +14 -14
- metadata +10 -9
data/Rakefile
CHANGED
@@ -13,7 +13,7 @@ begin
|
|
13
13
|
gem.authors = ["Bran Burridge"]
|
14
14
|
gem.files = FileList["[A-Z]*", "{app,config,generators,lib,shoulda_macros,rails}/**/*"]
|
15
15
|
|
16
|
-
gem.add_dependency "mini_fb", '=
|
16
|
+
gem.add_dependency "mini_fb", '=1.1.3'
|
17
17
|
gem.add_dependency "delayed_job", '=1.8.4'
|
18
18
|
gem.add_dependency "mad_mimi_mailer", '=0.0.7'
|
19
19
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.8.0
|
@@ -6,6 +6,7 @@ class Headstart::SessionsController < ApplicationController
|
|
6
6
|
filter_parameter_logging :password
|
7
7
|
|
8
8
|
def new
|
9
|
+
@oauth_url = MiniFB.oauth_url(Headstart.configuration.facebook_app_id, get_full_app_path + "/sessions/create", :scope=>MiniFB.scopes.join(","))
|
9
10
|
render :template => 'sessions/new'
|
10
11
|
end
|
11
12
|
|
@@ -13,8 +14,7 @@ class Headstart::SessionsController < ApplicationController
|
|
13
14
|
@user = if params[:session]
|
14
15
|
::User.authenticate(params[:session][:email], params[:session][:password])
|
15
16
|
else
|
16
|
-
::User.find_facebook_user(
|
17
|
-
cookies[Headstart.configuration.facebook_api_key + "_user"])
|
17
|
+
::User.find_facebook_user(params['code'], get_full_app_path)
|
18
18
|
end
|
19
19
|
|
20
20
|
if @user.nil?
|
@@ -23,8 +23,9 @@ class Headstart::SessionsController < ApplicationController
|
|
23
23
|
else
|
24
24
|
if @user.email_confirmed?
|
25
25
|
flash_success_after_create
|
26
|
-
|
26
|
+
elsif @user.email_confirmation_sent_at.blank?
|
27
27
|
::HeadstartMailer.deliver_welcome(@user)
|
28
|
+
@user.update_attribute(:email_confirmation_sent_at, Time.now)
|
28
29
|
flash_notice_after_create
|
29
30
|
end
|
30
31
|
sign_in(@user)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class GenericMailer < ActionMailer::Base
|
2
|
-
|
2
|
+
|
3
3
|
def change_password(user)
|
4
4
|
from Headstart.configuration.mailer_sender
|
5
5
|
recipients user.email
|
@@ -9,6 +9,7 @@ class GenericMailer < ActionMailer::Base
|
|
9
9
|
body :url => edit_user_password_url(user,
|
10
10
|
:token => user.password_reset_token,
|
11
11
|
:escape => false)
|
12
|
+
content_type "text/html"
|
12
13
|
end
|
13
14
|
|
14
15
|
def welcome(user)
|
@@ -18,14 +19,7 @@ class GenericMailer < ActionMailer::Base
|
|
18
19
|
:scope => [:headstart, :models, :headstart_mailer],
|
19
20
|
:default => "Welcome")
|
20
21
|
body :user => user
|
22
|
+
content_type "text/html"
|
21
23
|
end
|
22
24
|
|
23
|
-
def confirmation(user)
|
24
|
-
from Headstart.configuration.mailer_sender
|
25
|
-
recipients user.email
|
26
|
-
subject I18n.t(:confirmation,
|
27
|
-
:scope => [:headstart, :models, :headstart_mailer],
|
28
|
-
:default => "Account confirmation")
|
29
|
-
body :user => user
|
30
|
-
end
|
31
25
|
end
|
@@ -27,18 +27,14 @@
|
|
27
27
|
<%= link_to "Forgot password?", new_password_path %>
|
28
28
|
|
29
29
|
<%= form.submit "Sign in", :disable_with => "Please wait..." %>
|
30
|
-
|
31
|
-
or <fb:login-button onlogin="facebook_onlogin();" length="long" v="2" size="large"></fb:login-button>
|
32
|
-
<%- end -%>
|
30
|
+
|
33
31
|
</div>
|
34
32
|
<% end %>
|
35
33
|
|
36
34
|
|
37
|
-
|
38
35
|
<%- if Headstart.configuration.use_facebook_connect -%>
|
39
|
-
<
|
40
|
-
|
41
|
-
|
42
|
-
});
|
43
|
-
</script>
|
36
|
+
<div style="margin-top:20px">
|
37
|
+
<%= link_to image_tag("facebook_login.png"), @oauth_url %>
|
38
|
+
</div>
|
44
39
|
<%- end -%>
|
40
|
+
|
@@ -11,6 +11,7 @@
|
|
11
11
|
<%= form.label :last_name %>
|
12
12
|
<%= form.text_field :last_name %>
|
13
13
|
</p>
|
14
|
+
<%- if current_user.blank? || current_user.facebook_uid.blank? -%>
|
14
15
|
<p class="password_field">
|
15
16
|
<%= form.label :password %>
|
16
17
|
<%= form.password_field :password %>
|
@@ -19,3 +20,8 @@
|
|
19
20
|
<%= form.label :password_confirmation, "Confirm password" %>
|
20
21
|
<%= form.password_field :password_confirmation %>
|
21
22
|
</p>
|
23
|
+
<% end %>
|
24
|
+
<p class="text_field">
|
25
|
+
<%= form.label :avatar %>
|
26
|
+
<input id="photo" name="user[avatar]" type="file"/>
|
27
|
+
</p>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<% content_for :title do %>Edit My Profile<% end %>
|
2
2
|
<h2>Edit My Profile</h2>
|
3
3
|
|
4
|
-
<% form_for @user do |form| %>
|
4
|
+
<% form_for @user, :html => { :enctype => "multipart/form-data"} do |form| %>
|
5
5
|
<%= render :partial => '/users/form', :object => form %>
|
6
6
|
<%= form.submit 'Save', :disable_with => 'Please wait...' %>
|
7
7
|
<% end %>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<% content_for :title do %>Sign up<% end %>
|
2
2
|
<h2>Sign up</h2>
|
3
3
|
|
4
|
-
<% form_for @user do |form| %>
|
4
|
+
<% form_for @user, :html => { :enctype => "multipart/form-data"} do |form| %>
|
5
5
|
<%= render :partial => '/users/form', :object => form %>
|
6
6
|
<%= form.submit 'Sign up', :disable_with => 'Please wait...' %>
|
7
7
|
<% end %>
|
@@ -1,8 +1,10 @@
|
|
1
1
|
<h2>My Profile</h2>
|
2
2
|
|
3
|
+
<%= image_tag avatar_url(@user) %>
|
4
|
+
|
3
5
|
<div id="user_profile">
|
4
6
|
<b>First Name:</b> <%=h @user.first_name %><br/>
|
5
7
|
<b>Last Name:</b> <%=h @user.last_name %><br/>
|
6
8
|
<b>Email:</b> <%=h @user.email %><br/>
|
7
|
-
|
9
|
+
<% if signed_in? && current_user.id == @user.id %><%= link_to 'Edit', edit_user_path(current_user) %><% end %>
|
8
10
|
</div>
|
@@ -40,6 +40,8 @@ class HeadstartGenerator < Rails::Generator::Base
|
|
40
40
|
return content
|
41
41
|
end'
|
42
42
|
|
43
|
+
m.file "app/helpers/users_helper.rb", "app/helpers/users_helper.rb"
|
44
|
+
|
43
45
|
m.directory File.join("public", "stylesheets")
|
44
46
|
m.file "style.css", "public/stylesheets/style.css"
|
45
47
|
m.file "report.css", "public/stylesheets/report.css"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<!-- Woopra Code Start -->
|
2
2
|
<script type="text/javascript" src="//static.woopra.com/js/woopra.v2.js"></script>
|
3
3
|
<script type="text/javascript">
|
4
|
-
<% if
|
4
|
+
<% if signed_in? %>
|
5
5
|
woopraTracker.addVisitorProperty("name", '<%= current_user.name %>');
|
6
6
|
woopraTracker.addVisitorProperty("email", '<%= current_user.email %>');
|
7
7
|
<% end %>
|
@@ -76,8 +76,8 @@
|
|
76
76
|
|
77
77
|
<% if ENV["RAILS_ENV"] == "production" %>
|
78
78
|
<% if Settings.woopra.present? %><%= render :partial => 'layouts/woopra' %><% end %>
|
79
|
-
<% if Settings.google_analytics.present? %><%= render :partial => 'layouts/google_analytics' %>
|
79
|
+
<% if Settings.google_analytics.present? %><%= render :partial => 'layouts/google_analytics' %><% end %>
|
80
80
|
<% end %>
|
81
|
-
|
81
|
+
<!-- $zendesk -->
|
82
82
|
</body>
|
83
83
|
</html>
|
@@ -11,6 +11,7 @@ begin
|
|
11
11
|
config.use_delayed_job = configuration[:use_delayed_job]
|
12
12
|
config.facebook_api_key = configuration[:facebook_api_key]
|
13
13
|
config.facebook_secret_key = configuration[:facebook_secret_key]
|
14
|
+
config.facebook_app_id = configuration[:facebook_app_id]
|
14
15
|
end
|
15
16
|
|
16
17
|
if configuration[:madmimi_username].present? && configuration[:madmimi_api_key].present?
|
@@ -15,31 +15,45 @@
|
|
15
15
|
#
|
16
16
|
|
17
17
|
development:
|
18
|
-
mailer_sender:
|
18
|
+
mailer_sender: $mailer_sender
|
19
19
|
madmimi_username:
|
20
20
|
madmimi_api_key:
|
21
21
|
impersonation_hash:
|
22
|
-
use_facebook_connect:
|
22
|
+
use_facebook_connect: $use_facebook_connect
|
23
23
|
use_delayed_job: $delayed_job
|
24
|
-
facebook_api_key:
|
25
|
-
facebook_secret_key:
|
24
|
+
facebook_api_key: $facebook_api_key
|
25
|
+
facebook_secret_key: $facebook_secret_key
|
26
|
+
facebook_app_id: $facebook_app_id
|
26
27
|
|
28
|
+
staging:
|
29
|
+
mailer_sender: $mailer_sender
|
30
|
+
madmimi_username:
|
31
|
+
madmimi_api_key:
|
32
|
+
impersonation_hash:
|
33
|
+
use_facebook_connect: $use_facebook_connect
|
34
|
+
use_delayed_job: $delayed_job
|
35
|
+
facebook_api_key: $facebook_api_key
|
36
|
+
facebook_secret_key: $facebook_secret_key
|
37
|
+
facebook_app_id: $facebook_app_id
|
38
|
+
|
27
39
|
test:
|
28
|
-
mailer_sender:
|
40
|
+
mailer_sender: $mailer_sender
|
29
41
|
madmimi_username:
|
30
42
|
madmimi_api_key:
|
31
43
|
impersonation_hash:
|
32
|
-
use_facebook_connect:
|
44
|
+
use_facebook_connect: $use_facebook_connect
|
33
45
|
use_delayed_job: $delayed_job
|
34
|
-
facebook_api_key:
|
35
|
-
facebook_secret_key:
|
46
|
+
facebook_api_key: $facebook_api_key
|
47
|
+
facebook_secret_key: $facebook_secret_key
|
48
|
+
facebook_app_id: $facebook_app_id
|
36
49
|
|
37
50
|
production:
|
38
|
-
mailer_sender:
|
51
|
+
mailer_sender: $mailer_sender
|
39
52
|
madmimi_username:
|
40
53
|
madmimi_api_key:
|
41
54
|
impersonation_hash:
|
42
|
-
use_facebook_connect:
|
55
|
+
use_facebook_connect: $use_facebook_connect
|
43
56
|
use_delayed_job: $delayed_job
|
44
|
-
facebook_api_key:
|
45
|
-
facebook_secret_key:
|
57
|
+
facebook_api_key: $facebook_api_key
|
58
|
+
facebook_secret_key: $facebook_secret_key
|
59
|
+
facebook_app_id: $facebook_app_id
|
@@ -12,6 +12,13 @@ class HeadstartCreateUsers < ActiveRecord::Migration
|
|
12
12
|
t.string :password_reset_token, :limit => 128
|
13
13
|
t.string :confirmation_token, :limit => 128
|
14
14
|
t.boolean :email_confirmed, :default => false, :null => false
|
15
|
+
t.boolean :email_confirmation_sent_at, :datetime
|
16
|
+
|
17
|
+
t.string :avatar_file_name
|
18
|
+
t.string :avatar_content_type
|
19
|
+
t.integer :avatar_file_size
|
20
|
+
t.datetime :avatar_updated_at
|
21
|
+
|
15
22
|
t.timestamps
|
16
23
|
end
|
17
24
|
|
@@ -1,3 +1,7 @@
|
|
1
1
|
class User < ActiveRecord::Base
|
2
2
|
include Headstart::User
|
3
|
+
|
4
|
+
# If we don't want the originals, add , :original => "1x1"
|
5
|
+
has_attached_file :avatar, :styles => { :thumb => "50x50#", :mid => "200x300" }, :storage => :s3, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
|
6
|
+
:path => ":class/:id/:style.:extension", :default_url => "/images/missing.jpg"
|
3
7
|
end
|
@@ -9,16 +9,23 @@ module Headstart
|
|
9
9
|
module ClassMethods
|
10
10
|
def self.extended(controller)
|
11
11
|
controller.helper_method :current_user, :signed_in?,
|
12
|
-
:signed_out?, :impersonating
|
12
|
+
:signed_out?, :impersonating?,
|
13
|
+
:get_full_app_path
|
13
14
|
controller.hide_action :current_user, :current_user=,
|
14
15
|
:signed_in?, :signed_out?,
|
15
16
|
:sign_in, :sign_out,
|
16
17
|
:authenticate, :deny_access,
|
17
|
-
:impersonating
|
18
|
+
:impersonating?, :get_full_app_path
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
22
|
module InstanceMethods
|
23
|
+
|
24
|
+
|
25
|
+
def get_full_app_path
|
26
|
+
return "http://" + APP_CONFIG[:domain]
|
27
|
+
end
|
28
|
+
|
22
29
|
# User in the current cookie
|
23
30
|
#
|
24
31
|
# @return [User, nil]
|
@@ -97,7 +104,7 @@ module Headstart
|
|
97
104
|
|
98
105
|
|
99
106
|
protected
|
100
|
-
|
107
|
+
|
101
108
|
def user_from_cookie
|
102
109
|
if token = cookies[:remember_token]
|
103
110
|
::User.find_by_remember_token(token)
|
data/lib/headstart/user.rb
CHANGED
@@ -250,24 +250,24 @@ module Headstart
|
|
250
250
|
return user if user.authenticated?(password)
|
251
251
|
end
|
252
252
|
|
253
|
-
def find_facebook_user(
|
254
|
-
return nil unless Headstart.configuration.use_facebook_connect &&
|
255
|
-
|
253
|
+
def find_facebook_user(facebook_code, full_app_path)
|
254
|
+
return nil unless Headstart.configuration.use_facebook_connect && facebook_code
|
255
|
+
|
256
256
|
begin
|
257
|
-
|
258
|
-
|
259
|
-
|
257
|
+
access_token_hash = MiniFB.oauth_access_token(Headstart.configuration.facebook_app_id, full_app_path + "/sessions/create", Headstart.configuration.facebook_secret_key, facebook_code)
|
258
|
+
@response_hash = MiniFB.get(access_token_hash['access_token'], 'me', :type=> nil, :metadata=>true)
|
259
|
+
@response_hash["user"] == @response_hash.user
|
260
260
|
rescue MiniFB::FaceBookError
|
261
|
-
|
261
|
+
@response_hash = nil
|
262
262
|
end
|
263
|
-
return nil unless
|
264
|
-
|
265
|
-
user = ::User.find_by_facebook_uid(
|
263
|
+
return nil unless @response_hash
|
264
|
+
|
265
|
+
user = ::User.find_by_facebook_uid(@response_hash['id']) || ::User.find_by_email(@response_hash['email']) || ::User.new
|
266
266
|
user.tap do |user|
|
267
|
-
user.facebook_uid =
|
268
|
-
user.email =
|
269
|
-
user.first_name =
|
270
|
-
user.last_name =
|
267
|
+
user.facebook_uid = @response_hash['id']
|
268
|
+
user.email = @response_hash['email']
|
269
|
+
user.first_name = @response_hash['first_name']
|
270
|
+
user.last_name = @response_hash['last_name']
|
271
271
|
user.save
|
272
272
|
end
|
273
273
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: headstart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 63
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 8
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.8.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Bran Burridge
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-10-11 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -26,12 +26,12 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - "="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 21
|
30
30
|
segments:
|
31
|
-
-
|
32
|
-
-
|
33
|
-
-
|
34
|
-
version:
|
31
|
+
- 1
|
32
|
+
- 1
|
33
|
+
- 3
|
34
|
+
version: 1.1.3
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- generators/headstart/templates/add.png
|
126
126
|
- generators/headstart/templates/app/controllers/sessions_controller.rb
|
127
127
|
- generators/headstart/templates/app/helpers/application_helper.rb
|
128
|
+
- generators/headstart/templates/app/helpers/users_helper.rb
|
128
129
|
- generators/headstart/templates/app/views/sessions/index.html.erb
|
129
130
|
- generators/headstart/templates/application.html.erb
|
130
131
|
- generators/headstart/templates/application_edit.png
|