gunnertechnology 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/acts_as_authenticatable.rb +28 -0
- data/lib/gunnertechnology.rb +2 -0
- data/lib/gunnertechnology/version.rb +1 -1
- metadata +4 -3
@@ -0,0 +1,28 @@
|
|
1
|
+
module ActsAsAuthenticatable
|
2
|
+
# Default way to setup ActsAsConnectable. Run rails generate acts_as_connectable:install
|
3
|
+
# to create a fresh initializer with all configuration values.
|
4
|
+
def self.setup
|
5
|
+
yield self
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.included(base)
|
9
|
+
base.extend ClassMethods
|
10
|
+
def apply_omniauth(omniauth,user_attributes=nil)
|
11
|
+
self.attributes = user_attributes || {
|
12
|
+
:login => omniauth['user_info']['nickname'].gsub(/\./,'-'),
|
13
|
+
:first_name => (omniauth['user_info']['first_name'] || omniauth['user_info']['name'].split(" ").first),
|
14
|
+
:last_name => (omniauth['user_info']['last_name'] || omniauth['user_info']['name'].split(" ").last)
|
15
|
+
}
|
16
|
+
authentications.build(:nickname => omniauth['user_info']['nickname'], :provider => omniauth['provider'], :uid => omniauth['uid'], :token => omniauth['credentials']['token'], :secret => omniauth['credentials']['secret'])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module ClassMethods
|
21
|
+
def acts_as_authenticatable(*args)
|
22
|
+
has_many :authentications, {:as => :authenticationable, :dependent => :destroy, :class_name => "Authentication"}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
ActiveRecord::Base.send(:include, ActsAsAuthenticatable)
|
data/lib/gunnertechnology.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gunnertechnology
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 6
|
10
|
+
version: 0.0.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Cody Swann
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- README
|
129
129
|
- Rakefile
|
130
130
|
- gunnertechnology.gemspec
|
131
|
+
- lib/acts_as_authenticatable.rb
|
131
132
|
- lib/generators/project/USAGE
|
132
133
|
- lib/generators/project/project_generator.rb
|
133
134
|
- lib/generators/project/templates/app/controllers/authentications_controller.rb
|