muck-auth 3.3.3 → 3.4.0
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/README.rdoc +7 -0
- data/VERSION +1 -1
- data/app/controllers/muck/authentications_controller.rb +3 -2
- data/app/helpers/muck_auth_helper.rb +7 -0
- data/app/views/authentications/signup.html.erb +2 -35
- data/lib/muck-auth/models/user.rb +41 -2
- data/muck-auth.gemspec +2 -2
- metadata +5 -5
data/README.rdoc
CHANGED
@@ -22,6 +22,7 @@ Add services by including the proper credentials in secrets.yml:
|
|
22
22
|
twitter: # Twitter api access: http://www.twitter.com/apps
|
23
23
|
key: '{get a key}'
|
24
24
|
secret: '{it comes with a secret}'
|
25
|
+
valid_signin: true # include if you want to use this service to let your users signin/register for your site
|
25
26
|
|
26
27
|
=== OAuth Services
|
27
28
|
Here's a list of common oauth services. For a complete list of all available services please consult the omniauth documentation as the available services are constantly changing:
|
@@ -41,4 +42,10 @@ Render a full list of all services with links to authorize the service and icons
|
|
41
42
|
Render a list of all services that the current_user has authorized:
|
42
43
|
<%= render :partial => 'authentications/current_services', :locals => { :include_icons => true, :authentications => current_user.authentications } %>
|
43
44
|
|
45
|
+
Let users sign in and/or register on your site via oauth. Just remember to set valid_signin to true in your secrets.yml file:
|
46
|
+
<%= render :partial => 'users/signup_services' %>
|
47
|
+
|
48
|
+
There is a default template ('authentications/signup') that will be rendered if the sign up fails. Override that template if you want to provide the user with a custom experience:
|
49
|
+
|
50
|
+
|
44
51
|
Copyright (c) 2009-2011 Tatemae.com. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.4.0
|
@@ -19,8 +19,8 @@ class Muck::AuthenticationsController < ApplicationController
|
|
19
19
|
status = :logged_in_success
|
20
20
|
elsif authentication = Authentication.find_by_provider_and_uid(@omniauth['provider'], @omniauth['uid']) # Try to log the user in via the service
|
21
21
|
flash[:notice] = t('muck.users.login_success')
|
22
|
-
|
23
|
-
@user
|
22
|
+
@user = authentication.authenticatable
|
23
|
+
UserSession.create(@user)
|
24
24
|
status = :log_via_oauth_in_success
|
25
25
|
else
|
26
26
|
# Could not find any information. Create a new account.
|
@@ -35,6 +35,7 @@ class Muck::AuthenticationsController < ApplicationController
|
|
35
35
|
# Have to build a new user to get rid of the password
|
36
36
|
@user = User.new
|
37
37
|
@user.apply_omniauth(@omniauth)
|
38
|
+
@user.valid?
|
38
39
|
status = :new_signup_failure
|
39
40
|
end
|
40
41
|
end
|
@@ -14,6 +14,13 @@ module MuckAuthHelper
|
|
14
14
|
services
|
15
15
|
end
|
16
16
|
|
17
|
+
def signin_services(services_to_exclude = nil)
|
18
|
+
services = Secrets.auth_credentials
|
19
|
+
services = services.keys.find_all{|key| services[key]['valid_signin']}
|
20
|
+
services = services - services_to_exclude.map(&:provider) if services_to_exclude
|
21
|
+
services
|
22
|
+
end
|
23
|
+
|
17
24
|
def auth_icon_back(auth, include_icons = true)
|
18
25
|
if include_icons
|
19
26
|
icon = service_icon_background(auth)
|
@@ -1,41 +1,8 @@
|
|
1
|
-
<%=
|
2
|
-
|
3
|
-
<%= t('muck.auth.sign_up_prompt') %>
|
4
|
-
|
5
|
-
<% if MuckUsers.configuration.require_access_code -%>
|
6
|
-
<%= f.text_field :access_code_code, { :label => translate('muck.users.access_code'),
|
7
|
-
:extra_html => translate('muck.users.access_code_help',
|
8
|
-
:access_request_anchor => %Q{<a class="fancy-pop iframe" href="#{new_access_code_request_path}">},
|
9
|
-
:access_request_anchor_end => "</a>").html_safe } -%>
|
10
|
-
<% end -%>
|
11
|
-
|
12
|
-
<%= f.text_field :login, { :label => t('muck.users.choose_member_name'),
|
13
|
-
:extra_html => '',
|
14
|
-
:tip => t('muck.users.username_help'),
|
15
|
-
:required_label => t('muck.users.username') } -%>
|
16
|
-
<%= f.text_field :email, { :label => t('muck.users.email_address'),
|
17
|
-
:tip => t('muck.users.email_help'),
|
18
|
-
:extra_html => '' } -%>
|
19
|
-
<%= f.password_field :password, { :label => t('muck.users.password'),
|
20
|
-
:tip => t('muck.users.password_help')} -%>
|
21
|
-
<%= f.password_field :password_confirmation, { :label => t('muck.users.confirm_password'),
|
22
|
-
:tip => t('muck.users.password_confirmation_help') } -%>
|
23
|
-
|
24
|
-
<% if MuckUsers.configuration.validate_terms_of_service -%>
|
25
|
-
<div class="checklist">
|
26
|
-
<%= f.check_box :terms_of_service, { :label => t('muck.users.terms_and_service', :tos_link_anchor => '<a href="/terms_of_service">', :link_end => '</a>').html_safe,
|
27
|
-
:tip => t('muck.users.terms_and_service_tip') } -%>
|
28
|
-
</div>
|
29
|
-
<% end -%>
|
30
|
-
|
1
|
+
<%= signup_form(@user) do |f| -%>
|
2
|
+
<%# can add form fields as desired here -%>
|
31
3
|
<%= f.fields_for :authentications do |af| -%>
|
32
4
|
<%= af.hidden_field :provider %>
|
33
5
|
<%= af.hidden_field :uid %>
|
34
6
|
<%= af.hidden_field :raw_auth %>
|
35
7
|
<% end %>
|
36
|
-
|
37
|
-
<div class="button form-row">
|
38
|
-
<%= f.submit t('muck.users.sign_up_now') %>
|
39
|
-
</div>
|
40
|
-
|
41
8
|
<% end -%>
|
@@ -10,8 +10,47 @@ module MuckAuth
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def apply_omniauth(omniauth)
|
13
|
-
self.email = omniauth['user_info']['email'] if email.blank?
|
14
|
-
|
13
|
+
self.email = omniauth['user_info']['email'] if self.email.blank?
|
14
|
+
|
15
|
+
self.first_name = omniauth['user_info']['first_name'] if self.first_name.blank?
|
16
|
+
self.last_name = omniauth['user_info']['last_name'] if self.last_name.blank?
|
17
|
+
|
18
|
+
# In case first and last name weren't provided:
|
19
|
+
names = User.parse_name(omniauth['user_info']['name'])
|
20
|
+
self.first_name = names[0] if self.first_name.blank?
|
21
|
+
self.last_name = names[1] if self.last_name.blank?
|
22
|
+
|
23
|
+
self.login = omniauth['user_info']['nickname'] if self.login.blank?
|
24
|
+
# Some providers don't provide a valid nickname so try the first name
|
25
|
+
self.login = self.first_name if !self.valid? && self.errors[:login].any?
|
26
|
+
|
27
|
+
self.authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'], :raw_auth => omniauth.to_json,
|
28
|
+
:token => omniauth['credentials']['token'], :secret => omniauth['credentials']['secret'] )
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
def profile_from_omniauth(omniauth)
|
33
|
+
if self.respond_to?(:profile)
|
34
|
+
self.profile.location = omniauth['user_info']['location'] if self.profile.location.blank?
|
35
|
+
self.profile.about = omniauth['user_info']['description'] if self.profile.about.blank?
|
36
|
+
|
37
|
+
# TODO figure out how to get their profile image
|
38
|
+
# self.profile.image = omniauth['user_info']['image'] if self.profile.image.blank?
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def feeds_from_omniauth(omniauth)
|
43
|
+
uris = omniauth['user_info']['urls']
|
44
|
+
return unless uris && defined?(Service)
|
45
|
+
uris.each_pair do |name, uri|
|
46
|
+
feeds = Feed.make_feeds_or_website(uri, self, name)
|
47
|
+
feeds.compact!
|
48
|
+
if !feeds.blank?
|
49
|
+
feeds.each do |feed|
|
50
|
+
self.own_feeds << feed
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
15
54
|
end
|
16
55
|
|
17
56
|
def password_required?
|
data/muck-auth.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{muck-auth}
|
8
|
-
s.version = "3.
|
8
|
+
s.version = "3.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Justin Ball"]
|
12
|
-
s.date = %q{2011-03-
|
12
|
+
s.date = %q{2011-03-02}
|
13
13
|
s.description = %q{A simple wrapper for the omniauth gem so that it is faster to include oauth in muck based applications.}
|
14
14
|
s.email = %q{justin@tatemae.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muck-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 3.
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 3.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin Ball
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-02 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|