README.md in dailycred-0.1.36 vs README.md in dailycred-0.1.41
- old
+ new
@@ -26,16 +26,89 @@
While this is enough to get off the ground running with user authentication, this setup is meant to be lightweight and flexible, so feel free to tinker with
any of the generated code to better match your needs.
## Authenticating
+#### login_path
+
+A helper for linking to the authentication url.
+
+ <%= link_to 'sign up', login_path %>
+ # => <a href="/auth/dailycred">sign up</a>
+
+#### logout_path
+
+To logout a user, simply send them to `/auth/logout`.
+
+ <%= link_to 'logout', logout_path %>
+ # => <a href="/auth/logout">logout</a>
+
+#### authenticate
+
To protect a controller method from unauthorized users, use the 'authorize' helper method as a `before_filter`.
#before_filter :authenticate, :except => [:index] #don't authenticate some
#before_filter :authenticate, :only => [:create, :new] #only authenticate some
before_filter :authenticate #all methods
+## Social Connect
+
+To use a social sign-in service instead of email, and password, use `connect_path.`
+
+ <%= link_to 'sign in with facebook', connect_path(:identity_provider => :facebook) %>
+
+The `identity_provider` can be one of `facebook`, `google`, or `twitter.`
+
+After a user has social connected, their social data is serialized into individual fields in the user model. The serialized object is the exact same as what the social provider's graph response returns. For example:
+
+ p current_user.facebook
+ # =>
+ {
+ "video_upload_limits" => {
+ "length" => 1200.0,
+ "size" => 1073741824.0
+ },
+ "locale" => "en_US",
+ "link" => "http://www.facebook.com/joe.smith",
+ "updated_time" => "2012-09-27T19:04:38+0000",
+ "currency" => {
+ "user_currency" => "USD",
+ "currency_exchange" => 10.0,
+ "currency_exchange_inverse" => 0.1,
+ "currency_offset" => 100.0
+ },
+ "picture" => {
+ "data" => {
+ "url" => "http://profile.ak.fbcdn.net/hprofile-ak-ash4/370570_1039690812_2022945351_q.jpg",
+ "is_silhouette" => false
+ }
+ },
+ "id" => "1092609812",
+ "third_party_id" => "cBLDKnqlfYlReV7Jo4yRAFB1a4I",
+ "first_name" => "Joe",
+ "username" => "jsmitty",
+ "bio" => "shred the gnar.",
+ "email" => "jsmitty@dailycred.com",
+ "verified" => true,
+ "name" => "Joe Smith",
+ "last_name" => "Stoever",
+ "gender" => "male",
+ "access_token" =>"AAAFHsZAi9ddUBAKPMOKPDrmJlclwCoVHCfwflF5ZCyLZC70SOo0MPvj62lhHZAnV6jk8DEfBSjLtfcyC7Bx25a9CLphzoayv3EtvbE2tAQZDZD"
+ }
+
+You can also connect additional social accounts to an existing user:
+
+ <%= link_to 'connect with facebook', connect_user(:facebook) %>
+
+`connect_user` defaults to connecting the `current_user`, but you can explicitly connect any user:
+
+ <%= link_to 'connect with google', connect_user(:google, @user) %>
+
+---
+
+##Helpers
+
There are a few other helper methods available:
#### current_user
Returns the current logged in user or nil. Example usage:
@@ -60,24 +133,10 @@
def index
dailycred.event(current_user.uid, "New Task", @task.name)
end
-#### login_path
-
-A helper for linking to the authentication url. Usage:
-
- <%= link_to 'sign up', login_path %>
- # => <a href="/auth/dailycred">sign up</a>
-
-#### Logging out
-
-To logout a user, simply send them to `/auth/logout`.
-
- <%= link_to 'logout', logout_path %>
- # => <a href="/auth/logout">logout</a>
-
#### Tagging a User
Dailycred provides the ability to 'tag' users, whether for reference in analytics or any other reason. Note that this is a very simple 'tagging' system, and not something you should use for dynamic tagging situations in your application.
@user.tag 'awesome'
@@ -87,9 +146,15 @@
You can also fire events tied to a specific user - this is helpful for goal tracking and tying actions to a specific user in analytics. We already fire many events for when a user signs up, resets a password, and much more, but you can also use the event system for something more specific for your application.
# user#fire_event(key, value)
@user.fire_event 'task added', @task.name
+
+#### Building Referral URLs
+
+To easily build referral URLs to track sharing amongst your users, use `referral_link(my_site)`, where *my_site* is the url that you wish referred users to be sent to.
+
+ current_user.referral_link("http://www.mysite.com")
#### Testing Controllers
Testing controllers that have the `authenticate` before filter is easy: