{"action":"created","comment":{"url":"https://api.github.com/repos/railsblocks/railsblocks-auth/pulls/comments/27393419","id":27393419,"diff_hunk":"@@ -1,13 +1,35 @@\n module Railsblocks\n   module Auth\n     class User < ActiveRecord::Base\n-      \n+      before_save :verify_if_use_token  \n       rolify role_cname: \"Railsblocks::Auth::Role\"\n \n       # Include default devise modules. Others available are:\n       # :confirmable, :lockable, :timeoutable and :omniauthable\n       devise :database_authenticatable, :registerable,\n              :recoverable, :rememberable, :trackable, :validatable\n+\n+      def verify_if_use_token\n+        if self.class.use_token?\n+          if authentication_token.blank?\n+            self.authentication_token = generate_authentication_token\n+          end\n+        end\n+      end\n+\n+      private\n+      \n+      def generate_authentication_token\n+        loop do\n+          token = Devise.friendly_token\n+          break token unless Railsblocks::Auth::User.where(authentication_token: token).first","path":"app/models/railsblocks/auth/user.rb","position":26,"original_position":26,"commit_id":"2fd6cdad3e16533b8306763d20126fad64237d59","original_commit_id":"2fd6cdad3e16533b8306763d20126fad64237d59","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Line is too long. [93/80]","created_at":"2015-03-30T14:18:12Z","updated_at":"2015-03-30T14:18:12Z","html_url":"https://github.com/railsblocks/railsblocks-auth/pull/2#discussion_r27393419","pull_request_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/railsblocks/railsblocks-auth/pulls/comments/27393419"},"html":{"href":"https://github.com/railsblocks/railsblocks-auth/pull/2#discussion_r27393419"},"pull_request":{"href":"https://api.github.com/repos/railsblocks/railsblocks-auth/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/railsblocks/railsblocks-auth/pulls/2","id":32227677,"html_url":"https://github.com/railsblocks/railsblocks-auth/pull/2","diff_url":"https://github.com/railsblocks/railsblocks-auth/pull/2.diff","patch_url":"https://github.com/railsblocks/railsblocks-auth/pull/2.patch","issue_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/issues/2","number":2,"state":"open","locked":false,"title":"Feature/add ember support","user":{"login":"silviolrjunior","id":2863903,"avatar_url":"https://avatars.githubusercontent.com/u/2863903?v=3","gravatar_id":"","url":"https://api.github.com/users/silviolrjunior","html_url":"https://github.com/silviolrjunior","followers_url":"https://api.github.com/users/silviolrjunior/followers","following_url":"https://api.github.com/users/silviolrjunior/following{/other_user}","gists_url":"https://api.github.com/users/silviolrjunior/gists{/gist_id}","starred_url":"https://api.github.com/users/silviolrjunior/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/silviolrjunior/subscriptions","organizations_url":"https://api.github.com/users/silviolrjunior/orgs","repos_url":"https://api.github.com/users/silviolrjunior/repos","events_url":"https://api.github.com/users/silviolrjunior/events{/privacy}","received_events_url":"https://api.github.com/users/silviolrjunior/received_events","type":"User","site_admin":false},"body":"**Add support to ember.**\r\n**Add support to authentication token.**\r\n\r\n**For use with ember** \r\n\r\n* modify your application_controller.rb\r\n```ruby\r\nclass ApplicationController < Railsblocks::Auth::EmberController\r\n  helper_method :current_user_json\r\nend\r\n```\r\ncurrent_user_json is helper method for send to view of Ember the current_user\r\n\r\n**For use with authentication token** \r\n\r\n* modify your application_controller.rb\r\n```ruby\r\nclass ApplicationController < Railsblocks::Auth::ApplicationController\r\n  before_filter :authenticate_user_from_token!\r\n  protect_from_forgery with: :exception\r\nend\r\n```\r\nor for ember with authentication token\r\n```ruby\r\nclass ApplicationController < Railsblocks::Auth::EmberController\r\n  before_filter :authenticate_user_from_token!\r\n  protect_from_forgery with: :exception\r\nend\r\n```\r\n\r\n* create the file \"user.rb\" in path \"app/models/railsblocks/auth/\" this way:\r\n```ruby\r\nmodule Railsblocks\r\n  module Auth\r\n    class User < ActiveRecord::Base\r\n      devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable\r\n\r\n      private \r\n\r\n      def self.use_token?\r\n        true\r\n      end\r\n    end\r\n  end\r\nend\r\n```\r\n\r\n\r\n","created_at":"2015-03-30T13:47:48Z","updated_at":"2015-03-30T14:18:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ce6f44cf638b159bc87ec856eeead2320fc931cb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/pulls/2/commits","review_comments_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/pulls/2/comments","review_comment_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/pulls/comments{/number}","comments_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/issues/2/comments","statuses_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/statuses/2fd6cdad3e16533b8306763d20126fad64237d59","head":{"label":"silviolrjunior:feature/add_ember_support","ref":"feature/add_ember_support","sha":"2fd6cdad3e16533b8306763d20126fad64237d59","user":{"login":"silviolrjunior","id":2863903,"avatar_url":"https://avatars.githubusercontent.com/u/2863903?v=3","gravatar_id":"","url":"https://api.github.com/users/silviolrjunior","html_url":"https://github.com/silviolrjunior","followers_url":"https://api.github.com/users/silviolrjunior/followers","following_url":"https://api.github.com/users/silviolrjunior/following{/other_user}","gists_url":"https://api.github.com/users/silviolrjunior/gists{/gist_id}","starred_url":"https://api.github.com/users/silviolrjunior/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/silviolrjunior/subscriptions","organizations_url":"https://api.github.com/users/silviolrjunior/orgs","repos_url":"https://api.github.com/users/silviolrjunior/repos","events_url":"https://api.github.com/users/silviolrjunior/events{/privacy}","received_events_url":"https://api.github.com/users/silviolrjunior/received_events","type":"User","site_admin":false},"repo":{"id":33124282,"name":"railsblocks-auth","full_name":"silviolrjunior/railsblocks-auth","owner":{"login":"silviolrjunior","id":2863903,"avatar_url":"https://avatars.githubusercontent.com/u/2863903?v=3","gravatar_id":"","url":"https://api.github.com/users/silviolrjunior","html_url":"https://github.com/silviolrjunior","followers_url":"https://api.github.com/users/silviolrjunior/followers","following_url":"https://api.github.com/users/silviolrjunior/following{/other_user}","gists_url":"https://api.github.com/users/silviolrjunior/gists{/gist_id}","starred_url":"https://api.github.com/users/silviolrjunior/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/silviolrjunior/subscriptions","organizations_url":"https://api.github.com/users/silviolrjunior/orgs","repos_url":"https://api.github.com/users/silviolrjunior/repos","events_url":"https://api.github.com/users/silviolrjunior/events{/privacy}","received_events_url":"https://api.github.com/users/silviolrjunior/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/silviolrjunior/railsblocks-auth","description":"Authentication System For Rails Blocks","fork":true,"url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth","forks_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/forks","keys_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/keys{/key_id}","collaborators_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/teams","hooks_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/hooks","issue_events_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/issues/events{/number}","events_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/events","assignees_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/assignees{/user}","branches_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/branches{/branch}","tags_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/tags","blobs_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/git/refs{/sha}","trees_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/git/trees{/sha}","statuses_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/statuses/{sha}","languages_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/languages","stargazers_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/stargazers","contributors_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/contributors","subscribers_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/subscribers","subscription_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/subscription","commits_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/commits{/sha}","git_commits_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/git/commits{/sha}","comments_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/comments{/number}","issue_comment_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/issues/comments{/number}","contents_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/contents/{+path}","compare_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/compare/{base}...{head}","merges_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/merges","archive_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/downloads","issues_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/issues{/number}","pulls_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/pulls{/number}","milestones_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/milestones{/number}","notifications_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/labels{/name}","releases_url":"https://api.github.com/repos/silviolrjunior/railsblocks-auth/releases{/id}","created_at":"2015-03-30T13:21:29Z","updated_at":"2015-03-30T13:21:30Z","pushed_at":"2015-03-30T14:17:58Z","git_url":"git://github.com/silviolrjunior/railsblocks-auth.git","ssh_url":"git@github.com:silviolrjunior/railsblocks-auth.git","clone_url":"https://github.com/silviolrjunior/railsblocks-auth.git","svn_url":"https://github.com/silviolrjunior/railsblocks-auth","homepage":null,"size":240,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"railsblocks:master","ref":"master","sha":"55e7678299613f1395a07df7248170e1ce3a889c","user":{"login":"railsblocks","id":10852986,"avatar_url":"https://avatars.githubusercontent.com/u/10852986?v=3","gravatar_id":"","url":"https://api.github.com/users/railsblocks","html_url":"https://github.com/railsblocks","followers_url":"https://api.github.com/users/railsblocks/followers","following_url":"https://api.github.com/users/railsblocks/following{/other_user}","gists_url":"https://api.github.com/users/railsblocks/gists{/gist_id}","starred_url":"https://api.github.com/users/railsblocks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/railsblocks/subscriptions","organizations_url":"https://api.github.com/users/railsblocks/orgs","repos_url":"https://api.github.com/users/railsblocks/repos","events_url":"https://api.github.com/users/railsblocks/events{/privacy}","received_events_url":"https://api.github.com/users/railsblocks/received_events","type":"Organization","site_admin":false},"repo":{"id":31223500,"name":"railsblocks-auth","full_name":"railsblocks/railsblocks-auth","owner":{"login":"railsblocks","id":10852986,"avatar_url":"https://avatars.githubusercontent.com/u/10852986?v=3","gravatar_id":"","url":"https://api.github.com/users/railsblocks","html_url":"https://github.com/railsblocks","followers_url":"https://api.github.com/users/railsblocks/followers","following_url":"https://api.github.com/users/railsblocks/following{/other_user}","gists_url":"https://api.github.com/users/railsblocks/gists{/gist_id}","starred_url":"https://api.github.com/users/railsblocks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/railsblocks/subscriptions","organizations_url":"https://api.github.com/users/railsblocks/orgs","repos_url":"https://api.github.com/users/railsblocks/repos","events_url":"https://api.github.com/users/railsblocks/events{/privacy}","received_events_url":"https://api.github.com/users/railsblocks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/railsblocks/railsblocks-auth","description":"Authentication System For Rails Blocks","fork":false,"url":"https://api.github.com/repos/railsblocks/railsblocks-auth","forks_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/forks","keys_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/keys{/key_id}","collaborators_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/teams","hooks_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/hooks","issue_events_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/issues/events{/number}","events_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/events","assignees_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/assignees{/user}","branches_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/branches{/branch}","tags_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/tags","blobs_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/git/refs{/sha}","trees_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/git/trees{/sha}","statuses_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/statuses/{sha}","languages_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/languages","stargazers_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/stargazers","contributors_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/contributors","subscribers_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/subscribers","subscription_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/subscription","commits_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/commits{/sha}","git_commits_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/git/commits{/sha}","comments_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/comments{/number}","issue_comment_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/issues/comments{/number}","contents_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/contents/{+path}","compare_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/compare/{base}...{head}","merges_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/merges","archive_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/downloads","issues_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/issues{/number}","pulls_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/pulls{/number}","milestones_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/milestones{/number}","notifications_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/labels{/name}","releases_url":"https://api.github.com/repos/railsblocks/railsblocks-auth/releases{/id}","created_at":"2015-02-23T18:50:42Z","updated_at":"2015-03-29T22:14:56Z","pushed_at":"2015-03-30T14:17:58Z","git_url":"git://github.com/railsblocks/railsblocks-auth.git","ssh_url":"git@github.com:railsblocks/railsblocks-auth.git","clone_url":"https://github.com/railsblocks/railsblocks-auth.git","svn_url":"https://github.com/railsblocks/railsblocks-auth","homepage":null,"size":240,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/railsblocks/railsblocks-auth/pulls/2"},"html":{"href":"https://github.com/railsblocks/railsblocks-auth/pull/2"},"issue":{"href":"https://api.github.com/repos/railsblocks/railsblocks-auth/issues/2"},"comments":{"href":"https://api.github.com/repos/railsblocks/railsblocks-auth/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/railsblocks/railsblocks-auth/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/railsblocks/railsblocks-auth/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/railsblocks/railsblocks-auth/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/railsblocks/railsblocks-auth/statuses/2fd6cdad3e16533b8306763d20126fad64237d59"}}}}