dailycred 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +14 -2
  3. data/Guardfile +15 -0
  4. data/README.md +159 -33
  5. data/Rakefile +30 -0
  6. data/app/controllers/sessions_controller.rb +31 -0
  7. data/app/views/sessions/info.html.erb +13 -0
  8. data/config/routes.rb +7 -0
  9. data/dailycred.gemspec +4 -3
  10. data/docs/lib/dailycred/acts_as_dailycred.html +42 -0
  11. data/docs/lib/dailycred/client.html +214 -0
  12. data/docs/lib/dailycred/engine.html +112 -0
  13. data/docs/lib/dailycred/helper.html +125 -0
  14. data/docs/lib/dailycred/middleware.html +42 -0
  15. data/docs/lib/dailycred/tests_helper.html +42 -0
  16. data/docs/lib/dailycred/user.html +133 -0
  17. data/docs/lib/dailycred.html +42 -0
  18. data/docs/lib/generators/dailycred_generator.html +42 -0
  19. data/docs/lib/generators/templates/migration_create_user.html +39 -0
  20. data/docs/lib/generators/templates/omniauth.html +71 -0
  21. data/docs/lib/generators/templates/sessions_controller.html +96 -0
  22. data/docs/lib/generators/templates/user.html +42 -0
  23. data/docs/lib/middleware/middleware.html +38 -0
  24. data/docs/lib/omniauth/strategies/dailycred.html +199 -0
  25. data/docs/lib/omniauth-dailycred/version.html +38 -0
  26. data/docs/lib/user/user.html +129 -0
  27. data/dummy/.gitignore +15 -0
  28. data/dummy/Gemfile +55 -0
  29. data/dummy/Guardfile +31 -0
  30. data/dummy/README.rdoc +261 -0
  31. data/dummy/Rakefile +7 -0
  32. data/dummy/app/assets/images/rails.png +0 -0
  33. data/dummy/app/assets/javascripts/application.js +15 -0
  34. data/dummy/app/assets/javascripts/posts.js.coffee +3 -0
  35. data/dummy/app/assets/stylesheets/application.css +13 -0
  36. data/dummy/app/assets/stylesheets/posts.css.scss +3 -0
  37. data/dummy/app/assets/stylesheets/scaffolds.css.scss +69 -0
  38. data/dummy/app/controllers/application_controller.rb +16 -0
  39. data/dummy/app/controllers/posts_controller.rb +85 -0
  40. data/dummy/app/helpers/application_helper.rb +2 -0
  41. data/dummy/app/helpers/posts_helper.rb +2 -0
  42. data/dummy/app/mailers/.gitkeep +0 -0
  43. data/dummy/app/models/.gitkeep +0 -0
  44. data/dummy/app/models/post.rb +3 -0
  45. data/dummy/app/models/user.rb +3 -0
  46. data/dummy/app/views/layouts/application.html.erb +14 -0
  47. data/dummy/app/views/posts/_form.html.erb +21 -0
  48. data/dummy/app/views/posts/edit.html.erb +6 -0
  49. data/dummy/app/views/posts/index.html.erb +23 -0
  50. data/dummy/app/views/posts/new.html.erb +5 -0
  51. data/dummy/app/views/posts/show.html.erb +10 -0
  52. data/dummy/config/application.rb +62 -0
  53. data/dummy/config/boot.rb +6 -0
  54. data/dummy/config/database.yml +25 -0
  55. data/dummy/config/environment.rb +5 -0
  56. data/dummy/config/environments/development.rb +37 -0
  57. data/dummy/config/environments/production.rb +67 -0
  58. data/dummy/config/environments/test.rb +37 -0
  59. data/dummy/config/initializers/backtrace_silencers.rb +7 -0
  60. data/dummy/config/initializers/inflections.rb +15 -0
  61. data/dummy/config/initializers/mime_types.rb +5 -0
  62. data/dummy/config/initializers/omniauth.rb +13 -0
  63. data/dummy/config/initializers/secret_token.rb +7 -0
  64. data/dummy/config/initializers/session_store.rb +8 -0
  65. data/dummy/config/initializers/wrap_parameters.rb +14 -0
  66. data/dummy/config/locales/en.yml +5 -0
  67. data/dummy/config/routes.rb +61 -0
  68. data/dummy/config.ru +4 -0
  69. data/dummy/db/migrate/20120925172903_create_users.rb +68 -0
  70. data/dummy/db/migrate/20120926012555_create_posts.rb +9 -0
  71. data/dummy/db/migrate/20121002192037_update_users_2.rb +70 -0
  72. data/dummy/db/schema.rb +45 -0
  73. data/dummy/db/seeds.rb +7 -0
  74. data/dummy/lib/assets/.gitkeep +0 -0
  75. data/dummy/lib/tasks/.gitkeep +0 -0
  76. data/dummy/log/.gitkeep +0 -0
  77. data/dummy/public/404.html +26 -0
  78. data/dummy/public/422.html +26 -0
  79. data/dummy/public/500.html +25 -0
  80. data/dummy/public/favicon.ico +0 -0
  81. data/dummy/public/index.html +241 -0
  82. data/dummy/public/robots.txt +5 -0
  83. data/dummy/script/rails +6 -0
  84. data/dummy/test/fixtures/.gitkeep +0 -0
  85. data/dummy/test/fixtures/posts.yml +7 -0
  86. data/dummy/test/fixtures/users.yml +3 -0
  87. data/dummy/test/functional/.gitkeep +0 -0
  88. data/dummy/test/functional/posts_controller_test.rb +51 -0
  89. data/dummy/test/integration/.gitkeep +0 -0
  90. data/dummy/test/performance/browsing_test.rb +12 -0
  91. data/dummy/test/test_helper.rb +62 -0
  92. data/dummy/test/unit/.gitkeep +0 -0
  93. data/dummy/test/unit/helpers/posts_helper_test.rb +4 -0
  94. data/dummy/test/unit/post_test.rb +7 -0
  95. data/dummy/test/unit/user_test.rb +77 -0
  96. data/dummy/vendor/assets/javascripts/.gitkeep +0 -0
  97. data/dummy/vendor/assets/stylesheets/.gitkeep +0 -0
  98. data/dummy/vendor/plugins/.gitkeep +0 -0
  99. data/lib/dailycred/acts_as_dailycred.rb +87 -0
  100. data/lib/dailycred/client.rb +105 -0
  101. data/lib/dailycred/engine.rb +52 -0
  102. data/lib/dailycred/helper.rb +60 -0
  103. data/lib/{middleware → dailycred}/middleware.rb +25 -15
  104. data/lib/dailycred/tests_helper.rb +5 -0
  105. data/lib/dailycred/user.rb +63 -0
  106. data/lib/dailycred.rb +1 -79
  107. data/lib/generators/dailycred_generator.rb +94 -44
  108. data/lib/generators/templates/info.html.erb +1 -1
  109. data/lib/generators/templates/login.html.erb +13 -0
  110. data/lib/generators/templates/migration_create_user.rb +60 -10
  111. data/lib/generators/templates/omniauth.rb +6 -17
  112. data/lib/generators/templates/sessions_controller.rb +8 -2
  113. data/lib/generators/templates/user.rb +1 -23
  114. data/lib/omniauth/strategies/dailycred.rb +37 -20
  115. data/script/download_info.rb +11 -0
  116. data/spec/{spec_helper.rb → helper_spec.rb} +4 -2
  117. data/spec/omniauth/strategies/dailycred_spec.rb +52 -10
  118. data/spec/support/dailycred_spec.rb +72 -0
  119. data/spec/support/shared_examples.rb +40 -0
  120. data/test/generator_test.rb +85 -0
  121. data/test/test_helper.rb +6 -0
  122. metadata +116 -8
  123. data/lib/omniauth-dailycred/version.rb +0 -5
@@ -0,0 +1,133 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
+ <title>user.rb</title>
6
+ <link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
7
+ </head>
8
+ <body>
9
+ <div id='container'>
10
+ <div id="background"></div>
11
+ <div id="jump_to">
12
+ Jump To &hellip;
13
+ <div id="jump_wrapper">
14
+ <div id="jump_page">
15
+ <a class="source" href="../dailycred.html">dailycred.rb</a>
16
+ <a class="source" href="acts_as_dailycred.html">acts_as_dailycred.rb</a>
17
+ <a class="source" href="client.html">client.rb</a>
18
+ <a class="source" href="engine.html">engine.rb</a>
19
+ <a class="source" href="helper.html">helper.rb</a>
20
+ <a class="source" href="middleware.html">middleware.rb</a>
21
+ <a class="source" href="tests_helper.html">tests_helper.rb</a>
22
+ <a class="source" href="user.html">user.rb</a>
23
+ <a class="source" href="../generators/dailycred_generator.html">dailycred_generator.rb</a>
24
+ <a class="source" href="../generators/templates/migration_create_user.html">migration_create_user.rb</a>
25
+ <a class="source" href="../generators/templates/omniauth.html">omniauth.rb</a>
26
+ <a class="source" href="../generators/templates/sessions_controller.html">sessions_controller.rb</a>
27
+ <a class="source" href="../generators/templates/user.html">user.rb</a>
28
+ <a class="source" href="../omniauth/strategies/dailycred.html">dailycred.rb</a>
29
+ </div>
30
+ </div>
31
+ </div>
32
+ <table cellspacing=0 cellpadding=0>
33
+ <thead>
34
+ <tr>
35
+ <th class=docs><h1>user.rb</h1></th>
36
+ <th class=code></th>
37
+ </tr>
38
+ </thead>
39
+ <tbody>
40
+ <tr id='section-1'>
41
+ <td class=docs>
42
+ <div class="pilwrap">
43
+ <a class="pilcrow" href="#section-1">&#182;</a>
44
+ </div>
45
+
46
+ </td>
47
+ <td class=code>
48
+ <div class='highlight'><pre><span class="k">module</span> <span class="nn">Dailycred</span>
49
+ <span class="k">class</span> <span class="nc">User</span>
50
+ <span class="kp">include</span> <span class="no">ActiveModel</span><span class="o">::</span><span class="no">Validations</span>
51
+ <span class="kp">include</span> <span class="no">ActiveModel</span><span class="o">::</span><span class="no">Serialization</span>
52
+
53
+ <span class="n">validates_presence_of</span> <span class="ss">:email</span><span class="p">,</span> <span class="ss">:pass</span>
54
+
55
+ <span class="kp">attr_accessor</span> <span class="ss">:client</span><span class="p">,</span> <span class="ss">:email</span><span class="p">,</span> <span class="ss">:pass</span><span class="p">,</span> <span class="ss">:authorized</span>
56
+
57
+ <span class="k">def</span> <span class="nf">initialize</span> <span class="n">client</span><span class="p">,</span> <span class="n">user</span> <span class="o">=</span> <span class="p">{}</span>
58
+ <span class="nb">self</span><span class="o">.</span><span class="n">client</span> <span class="o">=</span> <span class="n">client</span>
59
+ <span class="nb">self</span><span class="o">.</span><span class="n">authorized</span> <span class="o">=</span> <span class="kp">false</span>
60
+ <span class="n">user</span><span class="o">.</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">k</span><span class="p">,</span><span class="n">v</span><span class="o">|</span>
61
+ <span class="nb">self</span><span class="o">[</span><span class="n">k</span><span class="o">]</span> <span class="o">=</span> <span class="n">v</span> <span class="k">if</span> <span class="nb">self</span><span class="o">.</span><span class="n">respond_to</span><span class="p">(</span><span class="n">k</span><span class="p">)</span>
62
+ <span class="k">end</span>
63
+ <span class="k">end</span>
64
+
65
+ <span class="k">def</span> <span class="nf">login</span>
66
+ <span class="k">if</span> <span class="o">!</span><span class="nb">self</span><span class="o">.</span><span class="n">valid?</span></pre></div>
67
+ </td>
68
+ </tr>
69
+ <tr id='section-2'>
70
+ <td class=docs>
71
+ <div class="pilwrap">
72
+ <a class="pilcrow" href="#section-2">&#182;</a>
73
+ </div>
74
+ <p>it didn&rsquo;t work already, return false</p>
75
+ </td>
76
+ <td class=code>
77
+ <div class='highlight'><pre> <span class="k">return</span> <span class="kp">false</span>
78
+ <span class="k">end</span>
79
+
80
+ <span class="n">response</span> <span class="o">=</span> <span class="no">JSON</span><span class="o">.</span><span class="n">parse</span> <span class="n">client</span><span class="o">.</span><span class="n">login</span><span class="p">(</span><span class="nb">self</span><span class="o">.</span><span class="n">to_hash</span><span class="p">)</span>
81
+ <span class="n">err_parser</span> <span class="n">response</span>
82
+
83
+ <span class="k">return</span> <span class="kp">false</span> <span class="k">if</span> <span class="o">!</span><span class="nb">self</span><span class="o">.</span><span class="n">valid?</span>
84
+ <span class="kp">true</span>
85
+ <span class="k">end</span>
86
+
87
+ <span class="k">def</span> <span class="nf">to_hash</span>
88
+ <span class="p">{</span>
89
+ <span class="ss">:email</span> <span class="o">=&gt;</span> <span class="nb">self</span><span class="o">.</span><span class="n">email</span><span class="p">,</span>
90
+ <span class="ss">:pass</span> <span class="o">=&gt;</span> <span class="nb">self</span><span class="o">.</span><span class="n">pass</span>
91
+ <span class="p">}</span>
92
+ <span class="k">end</span>
93
+
94
+ <span class="kp">private</span></pre></div>
95
+ </td>
96
+ </tr>
97
+ <tr id='section-3'>
98
+ <td class=docs>
99
+ <div class="pilwrap">
100
+ <a class="pilcrow" href="#section-3">&#182;</a>
101
+ </div>
102
+ <p>response is a hash, which is
103
+ a json-parsed http response body</p>
104
+
105
+ </td>
106
+ <td class=code>
107
+ <div class='highlight'><pre> <span class="k">def</span> <span class="nf">err_parser</span> <span class="n">response</span>
108
+ <span class="k">if</span> <span class="o">!</span><span class="n">response</span><span class="o">[</span><span class="s2">&quot;worked&quot;</span><span class="o">]</span>
109
+ <span class="nb">self</span><span class="o">.</span><span class="n">authorized</span> <span class="o">=</span> <span class="kp">false</span>
110
+ <span class="n">response</span><span class="o">[</span><span class="s2">&quot;errors&quot;</span><span class="o">].</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">err</span><span class="o">|</span>
111
+ <span class="n">attrib</span> <span class="o">=</span> <span class="n">err</span><span class="o">[</span><span class="s2">&quot;attribute&quot;</span><span class="o">]</span>
112
+ <span class="n">message</span> <span class="o">=</span> <span class="n">err</span><span class="o">[</span><span class="s2">&quot;message&quot;</span><span class="o">]</span>
113
+ <span class="k">if</span> <span class="n">attrib</span> <span class="o">==</span> <span class="s2">&quot;form&quot;</span>
114
+ <span class="nb">self</span><span class="o">.</span><span class="n">errors</span><span class="o">.</span><span class="n">add_to_base</span> <span class="n">message</span>
115
+ <span class="k">else</span>
116
+ <span class="k">if</span> <span class="n">attrib</span> <span class="o">==</span> <span class="s2">&quot;user&quot;</span>
117
+ <span class="nb">self</span><span class="o">.</span><span class="n">errors</span><span class="o">.</span><span class="n">add</span> <span class="ss">:email</span><span class="p">,</span> <span class="n">message</span>
118
+ <span class="k">elsif</span> <span class="nb">self</span><span class="o">.</span><span class="n">respond_to</span> <span class="n">attrib</span>
119
+ <span class="nb">self</span><span class="o">.</span><span class="n">errors</span><span class="o">.</span><span class="n">add</span> <span class="n">attrib</span><span class="p">,</span> <span class="n">message</span>
120
+ <span class="k">end</span>
121
+ <span class="k">end</span>
122
+ <span class="k">end</span>
123
+ <span class="k">end</span>
124
+ <span class="k">end</span>
125
+
126
+ <span class="k">end</span>
127
+
128
+ <span class="k">end</span></pre></div>
129
+ </td>
130
+ </tr>
131
+ </table>
132
+ </div>
133
+ </body>
@@ -0,0 +1,42 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
+ <title>dailycred.rb</title>
6
+ <link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
7
+ </head>
8
+ <body>
9
+ <div id='container'>
10
+ <div id="background"></div>
11
+ <div id="jump_to">
12
+ Jump To &hellip;
13
+ <div id="jump_wrapper">
14
+ <div id="jump_page">
15
+ <a class="source" href="dailycred.html">dailycred.rb</a>
16
+ <a class="source" href="dailycred/acts_as_dailycred.html">acts_as_dailycred.rb</a>
17
+ <a class="source" href="dailycred/client.html">client.rb</a>
18
+ <a class="source" href="dailycred/engine.html">engine.rb</a>
19
+ <a class="source" href="dailycred/helper.html">helper.rb</a>
20
+ <a class="source" href="dailycred/middleware.html">middleware.rb</a>
21
+ <a class="source" href="dailycred/tests_helper.html">tests_helper.rb</a>
22
+ <a class="source" href="dailycred/user.html">user.rb</a>
23
+ <a class="source" href="generators/dailycred_generator.html">dailycred_generator.rb</a>
24
+ <a class="source" href="generators/templates/migration_create_user.html">migration_create_user.rb</a>
25
+ <a class="source" href="generators/templates/omniauth.html">omniauth.rb</a>
26
+ <a class="source" href="generators/templates/sessions_controller.html">sessions_controller.rb</a>
27
+ <a class="source" href="generators/templates/user.html">user.rb</a>
28
+ <a class="source" href="omniauth/strategies/dailycred.html">dailycred.rb</a>
29
+ </div>
30
+ </div>
31
+ </div>
32
+ <table cellspacing=0 cellpadding=0>
33
+ <thead>
34
+ <tr>
35
+ <th class=docs><h1>dailycred.rb</h1></th>
36
+ <th class=code></th>
37
+ </tr>
38
+ </thead>
39
+ <tbody>
40
+ </table>
41
+ </div>
42
+ </body>
@@ -0,0 +1,42 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
+ <title>dailycred_generator.rb</title>
6
+ <link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
7
+ </head>
8
+ <body>
9
+ <div id='container'>
10
+ <div id="background"></div>
11
+ <div id="jump_to">
12
+ Jump To &hellip;
13
+ <div id="jump_wrapper">
14
+ <div id="jump_page">
15
+ <a class="source" href="../dailycred.html">dailycred.rb</a>
16
+ <a class="source" href="../dailycred/acts_as_dailycred.html">acts_as_dailycred.rb</a>
17
+ <a class="source" href="../dailycred/client.html">client.rb</a>
18
+ <a class="source" href="../dailycred/engine.html">engine.rb</a>
19
+ <a class="source" href="../dailycred/helper.html">helper.rb</a>
20
+ <a class="source" href="../dailycred/middleware.html">middleware.rb</a>
21
+ <a class="source" href="../dailycred/tests_helper.html">tests_helper.rb</a>
22
+ <a class="source" href="../dailycred/user.html">user.rb</a>
23
+ <a class="source" href="dailycred_generator.html">dailycred_generator.rb</a>
24
+ <a class="source" href="templates/migration_create_user.html">migration_create_user.rb</a>
25
+ <a class="source" href="templates/omniauth.html">omniauth.rb</a>
26
+ <a class="source" href="templates/sessions_controller.html">sessions_controller.rb</a>
27
+ <a class="source" href="templates/user.html">user.rb</a>
28
+ <a class="source" href="../omniauth/strategies/dailycred.html">dailycred.rb</a>
29
+ </div>
30
+ </div>
31
+ </div>
32
+ <table cellspacing=0 cellpadding=0>
33
+ <thead>
34
+ <tr>
35
+ <th class=docs><h1>dailycred_generator.rb</h1></th>
36
+ <th class=code></th>
37
+ </tr>
38
+ </thead>
39
+ <tbody>
40
+ </table>
41
+ </div>
42
+ </body>
@@ -0,0 +1,39 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
+ <title>migration_create_user.rb</title>
6
+ <link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
7
+ </head>
8
+ <body>
9
+ <div id='container'>
10
+ <div id="background"></div>
11
+ <div id="jump_to">
12
+ Jump To &hellip;
13
+ <div id="jump_wrapper">
14
+ <div id="jump_page">
15
+ <a class="source" href="../../dailycred.html">dailycred.rb</a>
16
+ <a class="source" href="../../dailycred/helper.html">helper.rb</a>
17
+ <a class="source" href="../../dailycred/user.html">user.rb</a>
18
+ <a class="source" href="../dailycred_generator.html">dailycred_generator.rb</a>
19
+ <a class="source" href="migration_create_user.html">migration_create_user.rb</a>
20
+ <a class="source" href="omniauth.html">omniauth.rb</a>
21
+ <a class="source" href="sessions_controller.html">sessions_controller.rb</a>
22
+ <a class="source" href="user.html">user.rb</a>
23
+ <a class="source" href="../../middleware/middleware.html">middleware.rb</a>
24
+ <a class="source" href="../../omniauth-dailycred/version.html">version.rb</a>
25
+ <a class="source" href="../../omniauth/strategies/dailycred.html">dailycred.rb</a>
26
+ </div>
27
+ </div>
28
+ </div>
29
+ <table cellspacing=0 cellpadding=0>
30
+ <thead>
31
+ <tr>
32
+ <th class=docs><h1>migration_create_user.rb</h1></th>
33
+ <th class=code></th>
34
+ </tr>
35
+ </thead>
36
+ <tbody>
37
+ </table>
38
+ </div>
39
+ </body>
@@ -0,0 +1,71 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
+ <title>omniauth.rb</title>
6
+ <link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
7
+ </head>
8
+ <body>
9
+ <div id='container'>
10
+ <div id="background"></div>
11
+ <div id="jump_to">
12
+ Jump To &hellip;
13
+ <div id="jump_wrapper">
14
+ <div id="jump_page">
15
+ <a class="source" href="../../dailycred.html">dailycred.rb</a>
16
+ <a class="source" href="../../dailycred/acts_as_dailycred.html">acts_as_dailycred.rb</a>
17
+ <a class="source" href="../../dailycred/client.html">client.rb</a>
18
+ <a class="source" href="../../dailycred/engine.html">engine.rb</a>
19
+ <a class="source" href="../../dailycred/helper.html">helper.rb</a>
20
+ <a class="source" href="../../dailycred/middleware.html">middleware.rb</a>
21
+ <a class="source" href="../../dailycred/tests_helper.html">tests_helper.rb</a>
22
+ <a class="source" href="../../dailycred/user.html">user.rb</a>
23
+ <a class="source" href="../dailycred_generator.html">dailycred_generator.rb</a>
24
+ <a class="source" href="migration_create_user.html">migration_create_user.rb</a>
25
+ <a class="source" href="omniauth.html">omniauth.rb</a>
26
+ <a class="source" href="sessions_controller.html">sessions_controller.rb</a>
27
+ <a class="source" href="user.html">user.rb</a>
28
+ <a class="source" href="../../omniauth/strategies/dailycred.html">dailycred.rb</a>
29
+ </div>
30
+ </div>
31
+ </div>
32
+ <table cellspacing=0 cellpadding=0>
33
+ <thead>
34
+ <tr>
35
+ <th class=docs><h1>omniauth.rb</h1></th>
36
+ <th class=code></th>
37
+ </tr>
38
+ </thead>
39
+ <tbody>
40
+ <tr id='section-1'>
41
+ <td class=docs>
42
+ <div class="pilwrap">
43
+ <a class="pilcrow" href="#section-1">&#182;</a>
44
+ </div>
45
+
46
+ </td>
47
+ <td class=code>
48
+ <div class='highlight'><pre><span class="no">Rails</span><span class="o">.</span><span class="n">configuration</span><span class="o">.</span><span class="n">DAILYCRED_CLIENT_ID</span> <span class="o">=</span> <span class="s2">&quot;&lt;%= client_id %&gt;&quot;</span>
49
+ <span class="no">Rails</span><span class="o">.</span><span class="n">configuration</span><span class="o">.</span><span class="n">DAILYCRED_SECRET_KEY</span> <span class="o">=</span> <span class="s2">&quot;&lt;%= secret_key %&gt;&quot;</span></pre></div>
50
+ </td>
51
+ </tr>
52
+ <tr id='section-2'>
53
+ <td class=docs>
54
+ <div class="pilwrap">
55
+ <a class="pilcrow" href="#section-2">&#182;</a>
56
+ </div>
57
+ <p>configure where users should be redirected after authentication</p>
58
+
59
+ <p>Rails.configuration.DAILYCRED<em>OPTIONS = {
60
+ :after</em>auth =&gt; &lsquo;/hello&rsquo;, #after login
61
+ :after_unauth =&gt; &lsquo;/goodbye&rsquo; #after logout
62
+ }</p>
63
+
64
+ </td>
65
+ <td class=code>
66
+ <div class='highlight'><pre></pre></div>
67
+ </td>
68
+ </tr>
69
+ </table>
70
+ </div>
71
+ </body>
@@ -0,0 +1,96 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
+ <title>sessions_controller.rb</title>
6
+ <link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
7
+ </head>
8
+ <body>
9
+ <div id='container'>
10
+ <div id="background"></div>
11
+ <div id="jump_to">
12
+ Jump To &hellip;
13
+ <div id="jump_wrapper">
14
+ <div id="jump_page">
15
+ <a class="source" href="../../dailycred.html">dailycred.rb</a>
16
+ <a class="source" href="../../dailycred/helper.html">helper.rb</a>
17
+ <a class="source" href="../../dailycred/user.html">user.rb</a>
18
+ <a class="source" href="../dailycred_generator.html">dailycred_generator.rb</a>
19
+ <a class="source" href="migration_create_user.html">migration_create_user.rb</a>
20
+ <a class="source" href="omniauth.html">omniauth.rb</a>
21
+ <a class="source" href="sessions_controller.html">sessions_controller.rb</a>
22
+ <a class="source" href="user.html">user.rb</a>
23
+ <a class="source" href="../../middleware/middleware.html">middleware.rb</a>
24
+ <a class="source" href="../../omniauth-dailycred/version.html">version.rb</a>
25
+ <a class="source" href="../../omniauth/strategies/dailycred.html">dailycred.rb</a>
26
+ </div>
27
+ </div>
28
+ </div>
29
+ <table cellspacing=0 cellpadding=0>
30
+ <thead>
31
+ <tr>
32
+ <th class=docs><h1>sessions_controller.rb</h1></th>
33
+ <th class=code></th>
34
+ </tr>
35
+ </thead>
36
+ <tbody>
37
+ <tr id='section-1'>
38
+ <td class=docs>
39
+ <div class="pilwrap">
40
+ <a class="pilcrow" href="#section-1">&#182;</a>
41
+ </div>
42
+
43
+ </td>
44
+ <td class=code>
45
+ <div class='highlight'><pre><span class="k">class</span> <span class="nc">SessionsController</span> <span class="o">&lt;</span> <span class="no">ApplicationController</span>
46
+ <span class="n">before_filter</span> <span class="ss">:authenticate</span><span class="p">,</span> <span class="ss">:only</span> <span class="o">=&gt;</span> <span class="o">[</span><span class="ss">:destroy</span><span class="o">]</span>
47
+ <span class="n">before_filter</span> <span class="ss">:current_user</span></pre></div>
48
+ </td>
49
+ </tr>
50
+ <tr id='section-2'>
51
+ <td class=docs>
52
+ <div class="pilwrap">
53
+ <a class="pilcrow" href="#section-2">&#182;</a>
54
+ </div>
55
+ <p>Callback Route for OAuth flow</p>
56
+ </td>
57
+ <td class=code>
58
+ <div class='highlight'><pre> <span class="k">def</span> <span class="nf">create</span>
59
+ <span class="vi">@user</span> <span class="o">=</span> <span class="no">User</span><span class="o">.</span><span class="n">find_or_create_with_omniauth</span> <span class="n">auth_hash</span>
60
+ <span class="n">session</span><span class="o">[</span><span class="ss">:user_id</span><span class="o">]</span> <span class="o">=</span> <span class="vi">@user</span><span class="o">.</span><span class="n">id</span>
61
+ <span class="n">redirect_to</span> <span class="n">auth_path</span>
62
+ <span class="k">end</span></pre></div>
63
+ </td>
64
+ </tr>
65
+ <tr id='section-3'>
66
+ <td class=docs>
67
+ <div class="pilwrap">
68
+ <a class="pilcrow" href="#section-3">&#182;</a>
69
+ </div>
70
+ <p>GET /logout</p>
71
+
72
+ </td>
73
+ <td class=code>
74
+ <div class='highlight'><pre> <span class="k">def</span> <span class="nf">destroy</span>
75
+ <span class="n">session</span><span class="o">[</span><span class="ss">:user_id</span><span class="o">]</span> <span class="o">=</span> <span class="kp">nil</span>
76
+ <span class="n">redirect_to</span> <span class="n">auth_path</span>
77
+ <span class="k">end</span>
78
+
79
+ <span class="k">def</span> <span class="nf">failure</span>
80
+ <span class="n">redirect_to</span> <span class="n">auth_path</span><span class="p">,</span> <span class="n">notice</span><span class="p">:</span> <span class="n">params</span><span class="o">[</span><span class="ss">:message</span><span class="o">]</span>
81
+ <span class="k">end</span>
82
+
83
+ <span class="k">def</span> <span class="nf">info</span>
84
+ <span class="k">end</span>
85
+
86
+ <span class="kp">private</span>
87
+
88
+ <span class="k">def</span> <span class="nf">auth_hash</span>
89
+ <span class="n">request</span><span class="o">.</span><span class="n">env</span><span class="o">[</span><span class="s1">&#39;omniauth.auth&#39;</span><span class="o">]</span>
90
+ <span class="k">end</span>
91
+ <span class="k">end</span></pre></div>
92
+ </td>
93
+ </tr>
94
+ </table>
95
+ </div>
96
+ </body>
@@ -0,0 +1,42 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
+ <title>user.rb</title>
6
+ <link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
7
+ </head>
8
+ <body>
9
+ <div id='container'>
10
+ <div id="background"></div>
11
+ <div id="jump_to">
12
+ Jump To &hellip;
13
+ <div id="jump_wrapper">
14
+ <div id="jump_page">
15
+ <a class="source" href="../../dailycred.html">dailycred.rb</a>
16
+ <a class="source" href="../../dailycred/acts_as_dailycred.html">acts_as_dailycred.rb</a>
17
+ <a class="source" href="../../dailycred/client.html">client.rb</a>
18
+ <a class="source" href="../../dailycred/engine.html">engine.rb</a>
19
+ <a class="source" href="../../dailycred/helper.html">helper.rb</a>
20
+ <a class="source" href="../../dailycred/middleware.html">middleware.rb</a>
21
+ <a class="source" href="../../dailycred/tests_helper.html">tests_helper.rb</a>
22
+ <a class="source" href="../../dailycred/user.html">user.rb</a>
23
+ <a class="source" href="../dailycred_generator.html">dailycred_generator.rb</a>
24
+ <a class="source" href="migration_create_user.html">migration_create_user.rb</a>
25
+ <a class="source" href="omniauth.html">omniauth.rb</a>
26
+ <a class="source" href="sessions_controller.html">sessions_controller.rb</a>
27
+ <a class="source" href="user.html">user.rb</a>
28
+ <a class="source" href="../../omniauth/strategies/dailycred.html">dailycred.rb</a>
29
+ </div>
30
+ </div>
31
+ </div>
32
+ <table cellspacing=0 cellpadding=0>
33
+ <thead>
34
+ <tr>
35
+ <th class=docs><h1>user.rb</h1></th>
36
+ <th class=code></th>
37
+ </tr>
38
+ </thead>
39
+ <tbody>
40
+ </table>
41
+ </div>
42
+ </body>
@@ -0,0 +1,38 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
+ <title>middleware.rb</title>
6
+ <link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
7
+ </head>
8
+ <body>
9
+ <div id='container'>
10
+ <div id="background"></div>
11
+ <div id="jump_to">
12
+ Jump To &hellip;
13
+ <div id="jump_wrapper">
14
+ <div id="jump_page">
15
+ <a class="source" href="../dailycred.html">dailycred.rb</a>
16
+ <a class="source" href="../generators/dailycred_generator.html">dailycred_generator.rb</a>
17
+ <a class="source" href="../generators/templates/migration_create_user.html">migration_create_user.rb</a>
18
+ <a class="source" href="../generators/templates/omniauth.html">omniauth.rb</a>
19
+ <a class="source" href="../generators/templates/sessions_controller.html">sessions_controller.rb</a>
20
+ <a class="source" href="../generators/templates/user.html">user.rb</a>
21
+ <a class="source" href="middleware.html">middleware.rb</a>
22
+ <a class="source" href="../omniauth-dailycred/version.html">version.rb</a>
23
+ <a class="source" href="../omniauth/strategies/dailycred.html">dailycred.rb</a>
24
+ <a class="source" href="../user/user.html">user.rb</a>
25
+ </div>
26
+ </div>
27
+ </div>
28
+ <table cellspacing=0 cellpadding=0>
29
+ <thead>
30
+ <tr>
31
+ <th class=docs><h1>middleware.rb</h1></th>
32
+ <th class=code></th>
33
+ </tr>
34
+ </thead>
35
+ <tbody>
36
+ </table>
37
+ </div>
38
+ </body>