Merge pull request #27 from excid3/master
Added force_login option
Arun Agrawal
11 years ago
26 | 26 |
To use this, just add a querystring for screen_name.
|
27 | 27 |
|
28 | 28 |
/auth/twitter?screen_name=scottw
|
|
29 |
|
|
30 |
You can also specify ```force_login``` without specifying the screen_name to prompt the user to choose the twitter account they wish to use.
|
|
31 |
|
|
32 |
/auth/twitter?force_login=true
|
29 | 33 |
|
30 | 34 |
Twitter also optionally supports specifying a x_auth_access_type when authenticating. This is handy when you need to specify special permission in some cases.
|
31 | 35 |
|
36 | 36 |
alias :old_request_phase :request_phase
|
37 | 37 |
|
38 | 38 |
def request_phase
|
|
39 |
force_login = session['omniauth.params'] ? session['omniauth.params']['force_login'] : nil
|
39 | 40 |
screen_name = session['omniauth.params'] ? session['omniauth.params']['screen_name'] : nil
|
40 | 41 |
x_auth_access_type = session['omniauth.params'] ? session['omniauth.params']['x_auth_access_type'] : nil
|
|
42 |
if force_login && !force_login.empty?
|
|
43 |
options[:authorize_params] ||= {}
|
|
44 |
options[:authorize_params].merge!(:force_login => 'true')
|
|
45 |
end
|
41 | 46 |
if screen_name && !screen_name.empty?
|
42 | 47 |
options[:authorize_params] ||= {}
|
43 | 48 |
options[:authorize_params].merge!(:force_login => 'true', :screen_name => screen_name)
|