fbdoorman 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/CHANGELOG.md +3 -0
  2. data/LICENSE +21 -0
  3. data/README.md +142 -0
  4. data/Rakefile +27 -0
  5. data/VERSION +1 -0
  6. data/app/controllers/clearance/confirmations_controller.rb +76 -0
  7. data/app/controllers/clearance/facebook_controller.rb +66 -0
  8. data/app/controllers/clearance/passwords_controller.rb +85 -0
  9. data/app/controllers/clearance/sessions_controller.rb +67 -0
  10. data/app/controllers/clearance/users_controller.rb +36 -0
  11. data/app/models/clearance_mailer.rb +21 -0
  12. data/app/views/clearance_mailer/change_password.html.erb +9 -0
  13. data/app/views/clearance_mailer/confirmation.html.erb +5 -0
  14. data/app/views/facebook/_fbjs.html.erb +14 -0
  15. data/app/views/facebook/closed.html.erb +1 -0
  16. data/app/views/passwords/edit.html.erb +23 -0
  17. data/app/views/passwords/new.html.erb +15 -0
  18. data/app/views/sessions/new.html.erb +25 -0
  19. data/app/views/users/_form.html.erb +13 -0
  20. data/app/views/users/new.html.erb +6 -0
  21. data/generators/fbdoorman/USAGE +1 -0
  22. data/generators/fbdoorman/fbdoorman_generator.rb +68 -0
  23. data/generators/fbdoorman/lib/insert_commands.rb +33 -0
  24. data/generators/fbdoorman/lib/rake_commands.rb +22 -0
  25. data/generators/fbdoorman/templates/README +43 -0
  26. data/generators/fbdoorman/templates/clearance.rb +3 -0
  27. data/generators/fbdoorman/templates/facebook.yml +7 -0
  28. data/generators/fbdoorman/templates/factories.rb +13 -0
  29. data/generators/fbdoorman/templates/migrations/create_users.rb +24 -0
  30. data/generators/fbdoorman/templates/migrations/update_users.rb +44 -0
  31. data/generators/fbdoorman/templates/user.rb +3 -0
  32. data/lib/clearance/authentication.rb +143 -0
  33. data/lib/clearance/configuration.rb +25 -0
  34. data/lib/clearance/extensions/errors.rb +6 -0
  35. data/lib/clearance/extensions/rescue.rb +5 -0
  36. data/lib/clearance/routes.rb +55 -0
  37. data/lib/clearance/user.rb +207 -0
  38. data/lib/facebook_helpers.rb +48 -0
  39. data/lib/fbdoorman.rb +27 -0
  40. data/lib/mini_fb.rb +673 -0
  41. data/rails/init.rb +1 -0
  42. metadata +110 -0
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ 0.2 (07/17/2010)
2
+ ------------------
3
+ * Updated some minor details in the Rakefile
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2008 thoughtbot, inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,142 @@
1
+ Fbdoorman
2
+ =========
3
+
4
+ Rails authentication with facebook single sign-on...or email & password.
5
+ Based on the gems Clearance by Thoughtbot and MiniFB by Appoxy
6
+
7
+ Help Request
8
+ ----
9
+
10
+ I'm very new to rails, made the best I could! However, I'm sure it can be done better and cleaner, since I edited the clearance
11
+ gem manually to create this. I'm sure this gem can be very useful and I'm just trying to contribute something to OpenSource!
12
+
13
+ If you can Help drop me a line if you can help: pelaez89 {at} gmail {.} com
14
+
15
+ About
16
+ ----
17
+ This gem has been created using Clearance and MiniFB gems, for more information referr to their source code, here:
18
+
19
+ * http://github.com/appoxy/mini_fb
20
+ * http://github.com/thoughtbot/clearance
21
+
22
+ I'm a Colombian design Student and pretty much a newbie in rails, this code works great and I'm using it in a soon to launch project.
23
+
24
+ I was concerned about security issues using only facebook JS single sign-on and wanted to use MiniFB (thanks guys
25
+ for such a great job) so that it could be use easily to authenticate users using their FB account, reducin sign-on/in times.
26
+
27
+ However regular email & password still works fine, so the clearance url's sign-on/in still work for those users not using FB.
28
+
29
+ Managing Login and Authentication
30
+ ----
31
+
32
+ Authentication is managed through checking the cookie's token validity with Facebook API using an OAuth 2.0 connection, that
33
+ means that even if the cookie with the user information hasn't been cleared from the browser, acces will be denied when
34
+ such token is no longer valid (aka the user sign-out of Facebook)
35
+
36
+ The gem doesn't use MiniFB oauth_url to login, instead it provides two helpers, facebook_js and facebook_login that
37
+ print inside your layout and inside your views the Fb login button and the JS required to point the users to the
38
+ Facebook controller inside the gem upon sign_in or session close. The facebook_js is required for the login button to work.
39
+
40
+ Installation
41
+ ------------
42
+ Same as clearance 0.8.8 this works with versions of Rails greater than 2.3.
43
+
44
+ gem install fbdoorman
45
+
46
+ Make sure the development database exists and run the generator.
47
+
48
+ script/generate fbdoorman
49
+
50
+ This:
51
+
52
+ * inserts Clearance::User into your User model
53
+ * inserts Clearance::Authentication into your ApplicationController
54
+ * inserts Clearance::Routes.draw(map) into your config.routes.rb
55
+ * created a migration that either creates a users table or adds only missing columns
56
+ * prints further instructions
57
+
58
+
59
+ Create your aplication in Facebook and set-up the information in config/facebook.yml (You'll have to create that file)
60
+
61
+ Facebook.yml
62
+ -----
63
+
64
+ You should create facebook.yml inside config folder, this is what it should look like.
65
+
66
+ :app_id: #Get this from http://www.facebook.com/developers/createapp.php
67
+ :secret: #from FB
68
+ :api_key: #from FB
69
+ :base_url: http://localhost:3000 #This is the url where you app's in, this is used to define where Fb should go after login
70
+ :after_login_path: /welcome/logged #Where to take your users when they login with FB
71
+ :after_register_path: /welcome/new #Where to go when a new user registers, use this to ask with a form for info specific to your app
72
+ :url_after_create: /welcome/logged Where to go when a session is created
73
+
74
+ Usage
75
+ -----
76
+
77
+ If you want to authenticate users for a controller action, use the authenticate
78
+ method in a before_filter.
79
+
80
+ before_filter :authenticate
81
+
82
+ Known-issue with "Missing host to link to"
83
+ ---------
84
+
85
+ Since Clearance tries to send confirmation mails and maybe Mailer settings are not defined in your app, you might run with and error. I'm not really sure why it happens but there's a solution if you just want to try clearance without the email confirmation.
86
+
87
+ Check this link for how I solved it. If this is some mistake of mine please tell me how to solve it and I'll just edit de code right away!
88
+
89
+ http://www.cherpec.com/2009/06/missing-host-to-link-to-please-provide-host-parameter-or-set-default_url_optionshost/
90
+
91
+ Other helpers
92
+ -----------
93
+ Note: I didn't have that much time to create some fancy and useful helper's, hopefully in a next version!
94
+
95
+ The user Facebook pic url in square format is returned by the helper facebook_pic_url
96
+
97
+ Also the user name is added in a column inside user, so you can get that anytime with current_user.name
98
+
99
+ Using MiniFB
100
+ -----------
101
+ You might be interested in using Facebook API with your user, you can do that using MiniFB.
102
+ Facebook will create a cookie with the required information naming it fb_#{FB_APP_ID}_
103
+ you can retrieve that cookie and it's values a Hash using this helper
104
+
105
+ parse_fb_cookie
106
+
107
+ Customizing
108
+ -----------
109
+
110
+ I strongly suggest copying the views inside the gem to your views to customize them.
111
+ Just copy the folder inside views, paste them in your app/views and customize it,
112
+ Rails will load those views first before those specifies by the gem.
113
+
114
+ To change any of provided actions, subclass a Clearance controller. (See clearance doc for more details)
115
+
116
+ Thanks to
117
+ -------
118
+
119
+ * The Clearance team, seeeing the source code you have created I truly realize how professionally done and reliable this gem is. I'm sorry I had to cut some of your code but my knowledge until now in rails was not enough to keep it all, it just was over my current skills. It would be great if you take this into your code and begin to promote single-on cause that reduced a lot of friction to create conversions to a given web service and clearance is probably the most simple and complete authentication gem out there.
120
+ * Appoxy and all the MiniFB team, you really made a very simple solution to use Facebook, there's not so much documentation right now but the google group proves that there's a supporting community behind no matter the size. I'm working on some documentation and examples for not so experienced users to use MiniFB, I'll send them soon, maybe you could publish this somewhere to promote the gem plus the graph support is damn simple and clean!
121
+ * Ryan Bates from Railcasts, his tutorials have helped me a lot through my rails learning and he's banner "Give back to open source" is one of my biggest motivations to work in this project.
122
+
123
+
124
+ MiniFb Authors
125
+ -------
126
+
127
+ Appoxy: http://www.appoxy.com/
128
+
129
+ Clerance Authors
130
+ -------
131
+
132
+ Clearance was extracted out of [Hoptoad](http://hoptoadapp.com). We merged the
133
+ authentication code from two of thoughtbot client Rails apps and have since
134
+ used it each time we need authentication.
135
+
136
+ The following people have improved the library. Thank you!
137
+
138
+ Dan Croak, Mike Burns, Jason Morrison, Joe Ferris, Eugene Bolshakov,
139
+ Nick Quaranto, Josh Nichols, Mike Breen, Marcel Görner, Bence Nagy, Ben Mabey,
140
+ Eloy Duran, Tim Pope, Mihai Anca, Mark Cornick, Shay Arnett, Joshua Clayton,
141
+ Mustafa Ekim, Jon Yurek, Anuj Dutta, Chad Pytel, Ben Orenstein, Bobby Wilson,
142
+ Matthew Ford, Ryan McGeary, Claudio Poli, Joseph Holsten, and Peter Haza.
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+ require 'rake'
3
+ generators = %w(fbdoorman)
4
+
5
+ namespace :generator do
6
+ desc "Run the fbdoorman generator"
7
+ task :minifbclearance do
8
+ system "cd test/rails_root && ./script/generate fbdoorman -f && rake db:migrate db:test:prepare"
9
+ end
10
+ end
11
+
12
+ task :default => []
13
+
14
+ require 'jeweler'
15
+
16
+ Jeweler::Tasks.new do |gem|
17
+ gem.name = "fbdoorman"
18
+ gem.summary = "Rails authentication with facebook single sign-on OR email & password."
19
+ gem.description = "Painless user registration and sign-in using Facebook single sign-on with JS. Typical email login still works too."
20
+ gem.email = "pelaez89@gmail.com"
21
+ gem.version = "0.0.1"
22
+ gem.homepage = "http://github.com/davidpelaez/minifb-clearance"
23
+ gem.authors = ["Fbdoorman: David Pelaez","MiniFB: Appoxy","Clearance: Thoughtbot"]
24
+ gem.files = FileList["[A-Z]*", "{app,config,generators,lib,shoulda_macros,rails}/**/*"]
25
+ end
26
+
27
+ Jeweler::GemcutterTasks.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,76 @@
1
+ class Clearance::ConfirmationsController < ApplicationController
2
+ unloadable
3
+
4
+ skip_before_filter :authenticate, :only => [:new, :create]
5
+ before_filter :redirect_signed_in_confirmed_user, :only => [:new, :create]
6
+ before_filter :redirect_signed_out_confirmed_user, :only => [:new, :create]
7
+ before_filter :forbid_missing_token, :only => [:new, :create]
8
+ before_filter :forbid_non_existent_user, :only => [:new, :create]
9
+
10
+ filter_parameter_logging :token
11
+
12
+ def new
13
+ create
14
+ end
15
+
16
+ def create
17
+ @user = ::User.find_by_id_and_confirmation_token(
18
+ params[:user_id], params[:token])
19
+ @user.confirm_email!
20
+
21
+ sign_in(@user)
22
+ flash_success_after_create
23
+ redirect_to(url_after_create)
24
+ end
25
+
26
+ private
27
+
28
+ def redirect_signed_in_confirmed_user
29
+ user = ::User.find_by_id(params[:user_id])
30
+ if user && user.email_confirmed? && current_user == user
31
+ flash_success_after_create
32
+ redirect_to(url_after_create)
33
+ end
34
+ end
35
+
36
+ def redirect_signed_out_confirmed_user
37
+ user = ::User.find_by_id(params[:user_id])
38
+ if user && user.email_confirmed? && signed_out?
39
+ flash_already_confirmed
40
+ redirect_to(url_already_confirmed)
41
+ end
42
+ end
43
+
44
+ def forbid_missing_token
45
+ if params[:token].blank?
46
+ raise ActionController::Forbidden, "missing token"
47
+ end
48
+ end
49
+
50
+ def forbid_non_existent_user
51
+ unless ::User.find_by_id_and_confirmation_token(
52
+ params[:user_id], params[:token])
53
+ raise ActionController::Forbidden, "non-existent user"
54
+ end
55
+ end
56
+
57
+ def flash_success_after_create
58
+ flash[:success] = translate(:confirmed_email,
59
+ :scope => [:clearance, :controllers, :confirmations],
60
+ :default => "Confirmed email and signed in.")
61
+ end
62
+
63
+ def flash_already_confirmed
64
+ flash[:success] = translate(:already_confirmed_email,
65
+ :scope => [:clearance, :controllers, :confirmations],
66
+ :default => "Already confirmed email. Please sign in.")
67
+ end
68
+
69
+ def url_after_create
70
+ '/'
71
+ end
72
+
73
+ def url_already_confirmed
74
+ sign_in_url
75
+ end
76
+ end
@@ -0,0 +1,66 @@
1
+ class Clearance::FacebookController < ApplicationController
2
+
3
+ #Js is informing that the cookie was created
4
+ def index
5
+ if signed_in? then
6
+ redirect_to FB_LOGGED_PATH #Evita multiples logins y hace que solo tenga sentido llamar el metodo con un nuevo cookie
7
+ else #If there's no signed in user
8
+ #The code arrives here
9
+ @fbcookie = parse_fb_cookie
10
+ ##Works sometimes, others sends: JSON::ParserError Exception: source did not contain any JSON!
11
+ #Bucle posiblemente infinito y chambon para lidiar con la excepcion mientras se soluciona
12
+ incomplete = true
13
+ while incomplete do
14
+ begin
15
+ incomplete = false #Intento salir del bucle
16
+ fbu = MiniFB::OAuthSession.new(@fbcookie["access_token"], 'es_ES').get "me"
17
+ rescue JSON::ParserError
18
+ incomplete = true #Reingreso en el bucle
19
+ end
20
+ end
21
+ @user = find_fbuser(fbu.id) #The one from the DB
22
+ #If the user exists
23
+ if @user then
24
+ sign_in_fbu(@user)
25
+ else #If theres no user with that id
26
+ #Register this user
27
+ register_fbu(fbu)
28
+ end
29
+ end
30
+ end
31
+
32
+ #Js is informing that the query as cleared
33
+ def closed
34
+ sign_out
35
+ render :template => "facebook/closed"
36
+ end
37
+
38
+ def sign_in_fbu(myuser)
39
+ sign_in(myuser)
40
+ redirect_to FB_LOGGED_PATH and return
41
+ end
42
+
43
+ #Here I reply the create the new user, I changed te verifications so that fbid is unique and password is optional
44
+ # when fbid isn't blank
45
+ def register_fbu(new_user)
46
+ @user = ::User.new
47
+ @user.fbid = new_user.id
48
+ @user.name = new_user.name
49
+ if @user.save
50
+ sign_in_fbu(@user)
51
+ else
52
+ render :text => "No se pudo registrar su usuario de FB"
53
+ end
54
+ end
55
+
56
+ #This method return nil if theres no such user and the user if there is
57
+ def find_fbuser(myfbuid)
58
+ return ::User.find_by_fbid(myfbuid)
59
+ end
60
+
61
+ def fbtoken(mycode)
62
+ access_token_hash = MiniFB.oauth_access_token(FB_APP_ID, FB_CALLBACK_URL, FB_SECRET, mycode)
63
+ return access_token = access_token_hash["access_token"]
64
+ end
65
+
66
+ end
@@ -0,0 +1,85 @@
1
+ class Clearance::PasswordsController < ApplicationController
2
+ unloadable
3
+
4
+ skip_before_filter :authenticate, :only => [:new, :create, :edit, :update]
5
+ before_filter :forbid_missing_token, :only => [:edit, :update]
6
+ before_filter :forbid_non_existent_user, :only => [:edit, :update]
7
+ filter_parameter_logging :password, :password_confirmation
8
+
9
+ def new
10
+ render :template => 'passwords/new'
11
+ end
12
+
13
+ def create
14
+ if user = ::User.find_by_email(params[:password][:email])
15
+ user.forgot_password!
16
+ ::ClearanceMailer.deliver_change_password user
17
+ flash_notice_after_create
18
+ redirect_to(url_after_create)
19
+ else
20
+ flash_failure_after_create
21
+ render :template => 'passwords/new'
22
+ end
23
+ end
24
+
25
+ def edit
26
+ @user = ::User.find_by_id_and_confirmation_token(
27
+ params[:user_id], params[:token])
28
+ render :template => 'passwords/edit'
29
+ end
30
+
31
+ def update
32
+ @user = ::User.find_by_id_and_confirmation_token(
33
+ params[:user_id], params[:token])
34
+
35
+ if @user.update_password(params[:user][:password],
36
+ params[:user][:password_confirmation])
37
+ @user.confirm_email!
38
+ sign_in(@user)
39
+ flash_success_after_update
40
+ redirect_to(url_after_update)
41
+ else
42
+ render :template => 'passwords/edit'
43
+ end
44
+ end
45
+
46
+ private
47
+
48
+ def forbid_missing_token
49
+ if params[:token].blank?
50
+ raise ActionController::Forbidden, "missing token"
51
+ end
52
+ end
53
+
54
+ def forbid_non_existent_user
55
+ unless ::User.find_by_id_and_confirmation_token(
56
+ params[:user_id], params[:token])
57
+ raise ActionController::Forbidden, "non-existent user"
58
+ end
59
+ end
60
+
61
+ def flash_notice_after_create
62
+ flash[:notice] = translate(:deliver_change_password,
63
+ :scope => [:clearance, :controllers, :passwords],
64
+ :default => "You will receive an email within the next few minutes. " <<
65
+ "It contains instructions for changing your password.")
66
+ end
67
+
68
+ def flash_failure_after_create
69
+ flash.now[:failure] = translate(:unknown_email,
70
+ :scope => [:clearance, :controllers, :passwords],
71
+ :default => "Unknown email.")
72
+ end
73
+
74
+ def url_after_create
75
+ sign_in_url
76
+ end
77
+
78
+ def flash_success_after_update
79
+ flash[:success] = translate(:signed_in, :default => "Signed in.")
80
+ end
81
+
82
+ def url_after_update
83
+ '/'
84
+ end
85
+ end
@@ -0,0 +1,67 @@
1
+ class Clearance::SessionsController < ApplicationController
2
+ unloadable
3
+
4
+ skip_before_filter :authenticate, :only => [:new, :create, :destroy]
5
+ protect_from_forgery :except => :create
6
+ filter_parameter_logging :password
7
+
8
+ def new
9
+ if !signed_in? then render :template => 'sessions/new'
10
+ else redirect_back_or(url_after_create) end
11
+ end
12
+
13
+ def create
14
+ @user = ::User.authenticate(params[:session][:email], params[:session][:password])
15
+ if @user.nil?
16
+ flash_failure_after_create
17
+ render :template => 'sessions/new', :status => :unauthorized
18
+ else
19
+ if @user.email_confirmed?
20
+ sign_in(@user)
21
+ flash_success_after_create
22
+ redirect_back_or(url_after_create)
23
+ else
24
+ ::ClearanceMailer.deliver_confirmation(@user)
25
+ flash_notice_after_create
26
+ redirect_to(sign_in_url)
27
+ end
28
+ end
29
+ end
30
+
31
+ def destroy
32
+ sign_out
33
+ flash_success_after_destroy
34
+ redirect_to(url_after_destroy)
35
+ end
36
+
37
+ private
38
+
39
+ def flash_failure_after_create
40
+ flash.now[:failure] = translate(:bad_email_or_password,
41
+ :scope => [:clearance, :controllers, :sessions],
42
+ :default => "Bad email or password.")
43
+ end
44
+
45
+ def flash_success_after_create
46
+ flash[:success] = translate(:signed_in, :default => "Signed in.")
47
+ end
48
+
49
+ def flash_notice_after_create
50
+ flash[:notice] = translate(:unconfirmed_email,
51
+ :scope => [:clearance, :controllers, :sessions],
52
+ :default => "User has not confirmed email. " <<
53
+ "Confirmation email will be resent.")
54
+ end
55
+
56
+ def url_after_create
57
+ URL_AFTER_CREATE
58
+ end
59
+
60
+ def flash_success_after_destroy
61
+ flash[:success] = translate(:signed_out, :default => "Signed out.")
62
+ end
63
+
64
+ def url_after_destroy
65
+ sign_in_url
66
+ end
67
+ end
@@ -0,0 +1,36 @@
1
+ class Clearance::UsersController < ApplicationController
2
+ unloadable
3
+
4
+ skip_before_filter :authenticate, :only => [:new, :create]
5
+ before_filter :redirect_to_root, :only => [:new, :create], :if => :signed_in?
6
+ filter_parameter_logging :password
7
+
8
+ def new
9
+ @user = ::User.new(params[:user])
10
+ render :template => 'users/new'
11
+ end
12
+
13
+ #Here the email login users are created, FB user creation is managed in the fb controller
14
+ def create
15
+ @user = ::User.new params[:user]
16
+ if @user.save
17
+ flash_notice_after_create
18
+ redirect_to(url_after_create)
19
+ else
20
+ render :template => 'users/new'
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def flash_notice_after_create
27
+ flash[:notice] = translate(:deliver_confirmation,
28
+ :scope => [:clearance, :controllers, :users],
29
+ :default => "You will receive an email within the next few minutes. " <<
30
+ "It contains instructions for confirming your account.")
31
+ end
32
+
33
+ def url_after_create
34
+ sign_in_url
35
+ end
36
+ end
@@ -0,0 +1,21 @@
1
+ class ClearanceMailer < ActionMailer::Base
2
+
3
+ def change_password(user)
4
+ from Clearance.configuration.mailer_sender
5
+ recipients user.email
6
+ subject I18n.t(:change_password,
7
+ :scope => [:clearance, :models, :clearance_mailer],
8
+ :default => "Change your password")
9
+ body :user => user
10
+ end
11
+
12
+ def confirmation(user)
13
+ from Clearance.configuration.mailer_sender
14
+ recipients user.email
15
+ subject I18n.t(:confirmation,
16
+ :scope => [:clearance, :models, :clearance_mailer],
17
+ :default => "Account confirmation")
18
+ body :user => user
19
+ end
20
+
21
+ end
@@ -0,0 +1,9 @@
1
+ Someone, hopefully you, has requested that we send you a link to change your password.
2
+
3
+ Here's the link:
4
+
5
+ <%= edit_user_password_url(@user,
6
+ :token => @user.confirmation_token,
7
+ :escape => false) %>
8
+
9
+ If you didn't request this, ignore this email. Don't worry. Your password hasn't been changed.
@@ -0,0 +1,5 @@
1
+
2
+ <%= new_user_confirmation_url(
3
+ :user_id => @user,
4
+ :token => @user.confirmation_token,
5
+ :encode => false) %>
@@ -0,0 +1,14 @@
1
+ <div id="fb-root"></div>
2
+ <script src="http://connect.facebook.net/en_US/all.js"></script>
3
+ <script>
4
+ FB.init({appId: '<%=FB_APP_ID%>', status: true, cookie: true, xfbml: true});
5
+ FB.Event.subscribe('auth.sessionChange', function(response) {
6
+ if (response.session) {
7
+ // A user has logged in, and a new cookie has been saved
8
+ window.location="<%=FB_CALLBACK_URL%>";
9
+ } else {
10
+ // The user has logged out, and the cookie has been cleared
11
+ window.location="<%=FB_CLOSED_URL%>";
12
+ }
13
+ });
14
+ </script>
@@ -0,0 +1 @@
1
+ Seems like you closed your facebook session, you need to log in to continue <%=facebook_login%>
@@ -0,0 +1,23 @@
1
+ <h2>Change your password</h2>
2
+
3
+ <p>
4
+ Your password has been reset. Choose a new password below.
5
+ </p>
6
+
7
+ <%= error_messages_for :user %>
8
+
9
+ <% form_for(:user,
10
+ :url => user_password_path(@user, :token => @user.confirmation_token),
11
+ :html => { :method => :put }) do |form| %>
12
+ <div class="password_field">
13
+ <%= form.label :password, "Choose password" %>
14
+ <%= form.password_field :password %>
15
+ </div>
16
+ <div class="password_field">
17
+ <%= form.label :password_confirmation, "Confirm password" %>
18
+ <%= form.password_field :password_confirmation %>
19
+ </div>
20
+ <div class="submit_field">
21
+ <%= form.submit "Save this password", :disable_with => "Please wait..." %>
22
+ </div>
23
+ <% end %>
@@ -0,0 +1,15 @@
1
+ <h2>Change your password</h2>
2
+
3
+ <p>
4
+ We will email you a link to change your password.
5
+ </p>
6
+
7
+ <% form_for :password, :url => passwords_path do |form| %>
8
+ <div class="text_field">
9
+ <%= form.label :email, "Email address" %>
10
+ <%= form.text_field :email %>
11
+ </div>
12
+ <div class="submit_field">
13
+ <%= form.submit "Reset password", :disable_with => "Please wait..." %>
14
+ </div>
15
+ <% end %>
@@ -0,0 +1,25 @@
1
+ <h2>Sign in</h2>
2
+
3
+ <% form_for :session, :url => session_path do |form| %>
4
+ <div class="text_field">
5
+ <%= form.label :email %>
6
+ <%= form.text_field :email %>
7
+ </div>
8
+ <div class="text_field">
9
+ <%= form.label :password %>
10
+ <%= form.password_field :password %>
11
+ </div>
12
+ <div class="submit_field">
13
+ <%= form.submit "Sign in", :disable_with => "Please wait..." %>
14
+ </div>
15
+ <% end %>
16
+
17
+ Or sign-in or create your account using Facebook <%= facebook_login %>
18
+ <ul>
19
+ <li>
20
+ <%= link_to "Sign up", sign_up_path %>
21
+ </li>
22
+ <li>
23
+ <%= link_to "Forgot password?", new_password_path %>
24
+ </li>
25
+ </ul>
@@ -0,0 +1,13 @@
1
+ <%= form.error_messages %>
2
+ <div class="text_field">
3
+ <%= form.label :email %>
4
+ <%= form.text_field :email %>
5
+ </div>
6
+ <div class="password_field">
7
+ <%= form.label :password %>
8
+ <%= form.password_field :password %>
9
+ </div>
10
+ <div class="password_field">
11
+ <%= form.label :password_confirmation, "Confirm password" %>
12
+ <%= form.password_field :password_confirmation %>
13
+ </div>
@@ -0,0 +1,6 @@
1
+ <h2>Sign up</h2>
2
+
3
+ <% form_for @user do |form| %>
4
+ <%= render :partial => '/users/form', :object => form %>
5
+ <%= form.submit 'Sign up', :disable_with => 'Please wait...' %>
6
+ <% end %>