ninsho 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  #Ninsho
2
2
 
3
- Ninsho is easy flexible authentication solution when using providers
3
+ Ninsho is an easy flexible authentication solution when using providers
4
4
 
5
5
  * Is a complete MVC solution based on Rails Engines;
6
6
  * Works with most providers out there, Github, Facebook, Twitter, Linkedin
@@ -109,6 +109,34 @@ And after that if you want ninsho to respond to that, you just need to add the p
109
109
  config.omniauth :facebook, "APP_ID", "APP_SECRET", :scope => 'email'
110
110
  ```
111
111
 
112
+ ###Custom fields
113
+
114
+ Now you have access to the hash provided by any of the omniauth providers gem, as an instance method under:
115
+
116
+ ```ruby
117
+ self.auth_hash
118
+ ```
119
+
120
+ So if you need to add an extra field to your ninsho model (commonly 'Authentication'), it's as easy as adding a ```before_save``` callback and handle the extra stuff by yourself. Don't get it?, here ir a quick example:
121
+
122
+ Let's say we want to save the nickname from the hash into our ninsho model:
123
+
124
+ 1. Add the migration to the ninsho model
125
+ ```console
126
+ rails g migration add_nickname_to_MODEL nickname:string
127
+ ```
128
+ 2. Run the migration and add the callback which should look like:
129
+ ```ruby
130
+ before_save :set_nickname
131
+ ```
132
+ ```ruby
133
+ def set_nickname
134
+ self.nickname = self.auth_hash.info.nickname
135
+ end
136
+ ```
137
+ 3. You are good to go, and any time the user changes the nickname yours will too!
138
+
139
+
112
140
  ### I18n
113
141
 
114
142
  You can overwrite the ninsho locale and customize the flash messages:
@@ -126,6 +154,7 @@ en:
126
154
  * Current gem version 0.0.3
127
155
  * Add more documentation on code
128
156
  * Add aouth token for Facebook friends
157
+ * Add more flexibility to handle authentications and save to multiple fields
129
158
  * Add handy helpers
130
159
  * Released gem version 0.0.2
131
160
  * Released gem version 0.0.1
@@ -136,9 +165,10 @@ en:
136
165
 
137
166
  ### Future
138
167
 
139
- * Add more flexibility to handle authentications and save multiple to fields
140
168
  * Add tests
141
169
  * Support for Mongoid
170
+ * Add wiki
171
+ * Add rails live example
142
172
 
143
173
 
144
174
  ## Credits
@@ -46,7 +46,7 @@ class NinshoController < Ninsho.parent_controller.constantize
46
46
 
47
47
  # Build a ninsho resource, from the omniauth hash
48
48
  def build_resource_from_omniauth
49
- self.resource = resource_class.from_omniauth(resource_params)
49
+ self.resource = resource_class.from_omniauth(resource_params)
50
50
  end
51
51
 
52
52
  end
@@ -23,7 +23,7 @@ module ActiveRecord
23
23
 
24
24
  def inject_ninsho_content
25
25
  content = <<CONTENT
26
- attr_accessible :provider, :uid
26
+ attr_accessible :provider, :uid, :oauth_token
27
27
  # belongs_to_ninsho :user
28
28
  CONTENT
29
29
 
@@ -6,8 +6,14 @@ module Ninsho
6
6
  base.extend(ClassMethods)
7
7
  end
8
8
 
9
+ def auth_hash
10
+ Ninsho.resource_class.auth_hash
11
+ end
12
+
9
13
  module ClassMethods
10
-
14
+
15
+ attr_accessor :auth_hash
16
+
11
17
  def belongs_to_ninsho(*args)
12
18
  options = args.extract_options!
13
19
 
@@ -20,10 +26,11 @@ module Ninsho
20
26
  Ninsho.parent_resource_name = Ninsho.ref(associated_model.to_s.classify).get
21
27
  end
22
28
  end
23
-
29
+
24
30
  # Responsible for creating or find the record with the
25
31
  # omniauth hash
26
32
  def from_omniauth(omniauth = nil)
33
+ self.auth_hash = omniauth
27
34
  Ninsho::Authentication.new(omniauth)
28
35
  end
29
36
  end
@@ -1,3 +1,3 @@
1
1
  module Ninsho
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ninsho
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-25 00:00:00.000000000 Z
12
+ date: 2013-03-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: orm_adapter