dailycred 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +14 -2
- data/Guardfile +15 -0
- data/README.md +159 -33
- data/Rakefile +30 -0
- data/app/controllers/sessions_controller.rb +31 -0
- data/app/views/sessions/info.html.erb +13 -0
- data/config/routes.rb +7 -0
- data/dailycred.gemspec +4 -3
- data/docs/lib/dailycred/acts_as_dailycred.html +42 -0
- data/docs/lib/dailycred/client.html +214 -0
- data/docs/lib/dailycred/engine.html +112 -0
- data/docs/lib/dailycred/helper.html +125 -0
- data/docs/lib/dailycred/middleware.html +42 -0
- data/docs/lib/dailycred/tests_helper.html +42 -0
- data/docs/lib/dailycred/user.html +133 -0
- data/docs/lib/dailycred.html +42 -0
- data/docs/lib/generators/dailycred_generator.html +42 -0
- data/docs/lib/generators/templates/migration_create_user.html +39 -0
- data/docs/lib/generators/templates/omniauth.html +71 -0
- data/docs/lib/generators/templates/sessions_controller.html +96 -0
- data/docs/lib/generators/templates/user.html +42 -0
- data/docs/lib/middleware/middleware.html +38 -0
- data/docs/lib/omniauth/strategies/dailycred.html +199 -0
- data/docs/lib/omniauth-dailycred/version.html +38 -0
- data/docs/lib/user/user.html +129 -0
- data/dummy/.gitignore +15 -0
- data/dummy/Gemfile +55 -0
- data/dummy/Guardfile +31 -0
- data/dummy/README.rdoc +261 -0
- data/dummy/Rakefile +7 -0
- data/dummy/app/assets/images/rails.png +0 -0
- data/dummy/app/assets/javascripts/application.js +15 -0
- data/dummy/app/assets/javascripts/posts.js.coffee +3 -0
- data/dummy/app/assets/stylesheets/application.css +13 -0
- data/dummy/app/assets/stylesheets/posts.css.scss +3 -0
- data/dummy/app/assets/stylesheets/scaffolds.css.scss +69 -0
- data/dummy/app/controllers/application_controller.rb +16 -0
- data/dummy/app/controllers/posts_controller.rb +85 -0
- data/dummy/app/helpers/application_helper.rb +2 -0
- data/dummy/app/helpers/posts_helper.rb +2 -0
- data/dummy/app/mailers/.gitkeep +0 -0
- data/dummy/app/models/.gitkeep +0 -0
- data/dummy/app/models/post.rb +3 -0
- data/dummy/app/models/user.rb +3 -0
- data/dummy/app/views/layouts/application.html.erb +14 -0
- data/dummy/app/views/posts/_form.html.erb +21 -0
- data/dummy/app/views/posts/edit.html.erb +6 -0
- data/dummy/app/views/posts/index.html.erb +23 -0
- data/dummy/app/views/posts/new.html.erb +5 -0
- data/dummy/app/views/posts/show.html.erb +10 -0
- data/dummy/config/application.rb +62 -0
- data/dummy/config/boot.rb +6 -0
- data/dummy/config/database.yml +25 -0
- data/dummy/config/environment.rb +5 -0
- data/dummy/config/environments/development.rb +37 -0
- data/dummy/config/environments/production.rb +67 -0
- data/dummy/config/environments/test.rb +37 -0
- data/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/dummy/config/initializers/inflections.rb +15 -0
- data/dummy/config/initializers/mime_types.rb +5 -0
- data/dummy/config/initializers/omniauth.rb +13 -0
- data/dummy/config/initializers/secret_token.rb +7 -0
- data/dummy/config/initializers/session_store.rb +8 -0
- data/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/dummy/config/locales/en.yml +5 -0
- data/dummy/config/routes.rb +61 -0
- data/dummy/config.ru +4 -0
- data/dummy/db/migrate/20120925172903_create_users.rb +68 -0
- data/dummy/db/migrate/20120926012555_create_posts.rb +9 -0
- data/dummy/db/migrate/20121002192037_update_users_2.rb +70 -0
- data/dummy/db/schema.rb +45 -0
- data/dummy/db/seeds.rb +7 -0
- data/dummy/lib/assets/.gitkeep +0 -0
- data/dummy/lib/tasks/.gitkeep +0 -0
- data/dummy/log/.gitkeep +0 -0
- data/dummy/public/404.html +26 -0
- data/dummy/public/422.html +26 -0
- data/dummy/public/500.html +25 -0
- data/dummy/public/favicon.ico +0 -0
- data/dummy/public/index.html +241 -0
- data/dummy/public/robots.txt +5 -0
- data/dummy/script/rails +6 -0
- data/dummy/test/fixtures/.gitkeep +0 -0
- data/dummy/test/fixtures/posts.yml +7 -0
- data/dummy/test/fixtures/users.yml +3 -0
- data/dummy/test/functional/.gitkeep +0 -0
- data/dummy/test/functional/posts_controller_test.rb +51 -0
- data/dummy/test/integration/.gitkeep +0 -0
- data/dummy/test/performance/browsing_test.rb +12 -0
- data/dummy/test/test_helper.rb +62 -0
- data/dummy/test/unit/.gitkeep +0 -0
- data/dummy/test/unit/helpers/posts_helper_test.rb +4 -0
- data/dummy/test/unit/post_test.rb +7 -0
- data/dummy/test/unit/user_test.rb +77 -0
- data/dummy/vendor/assets/javascripts/.gitkeep +0 -0
- data/dummy/vendor/assets/stylesheets/.gitkeep +0 -0
- data/dummy/vendor/plugins/.gitkeep +0 -0
- data/lib/dailycred/acts_as_dailycred.rb +87 -0
- data/lib/dailycred/client.rb +105 -0
- data/lib/dailycred/engine.rb +52 -0
- data/lib/dailycred/helper.rb +60 -0
- data/lib/{middleware → dailycred}/middleware.rb +25 -15
- data/lib/dailycred/tests_helper.rb +5 -0
- data/lib/dailycred/user.rb +63 -0
- data/lib/dailycred.rb +1 -79
- data/lib/generators/dailycred_generator.rb +94 -44
- data/lib/generators/templates/info.html.erb +1 -1
- data/lib/generators/templates/login.html.erb +13 -0
- data/lib/generators/templates/migration_create_user.rb +60 -10
- data/lib/generators/templates/omniauth.rb +6 -17
- data/lib/generators/templates/sessions_controller.rb +8 -2
- data/lib/generators/templates/user.rb +1 -23
- data/lib/omniauth/strategies/dailycred.rb +37 -20
- data/script/download_info.rb +11 -0
- data/spec/{spec_helper.rb → helper_spec.rb} +4 -2
- data/spec/omniauth/strategies/dailycred_spec.rb +52 -10
- data/spec/support/dailycred_spec.rb +72 -0
- data/spec/support/shared_examples.rb +40 -0
- data/test/generator_test.rb +85 -0
- data/test/test_helper.rb +6 -0
- metadata +116 -8
- 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 …
|
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">¶</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">¶</a>
|
73
|
+
</div>
|
74
|
+
<p>it didn’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">=></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">=></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">¶</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">"worked"</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">"errors"</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">"attribute"</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">"message"</span><span class="o">]</span>
|
113
|
+
<span class="k">if</span> <span class="n">attrib</span> <span class="o">==</span> <span class="s2">"form"</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">"user"</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 …
|
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 …
|
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 …
|
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 …
|
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">¶</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">"<%= client_id %>"</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">"<%= secret_key %>"</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">¶</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 => ‘/hello’, #after login
|
61
|
+
:after_unauth => ‘/goodbye’ #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 …
|
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">¶</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"><</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">=></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">¶</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">¶</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">'omniauth.auth'</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 …
|
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 …
|
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>
|