dailycred 0.1.30 → 0.1.31
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/README.md +102 -2
- data/Rakefile +10 -0
- data/app/controllers/sessions_controller.rb +32 -0
- data/app/views/sessions/info.html.erb +7 -0
- data/config/routes.rb +7 -0
- data/dailycred.gemspec +3 -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 +119 -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 +7 -177
- data/docs/lib/generators/dailycred_generator.html +7 -3
- data/docs/lib/generators/templates/migration_create_user.html +2 -1
- data/docs/lib/generators/templates/omniauth.html +36 -3
- data/docs/lib/generators/templates/sessions_controller.html +7 -2
- data/docs/lib/generators/templates/user.html +7 -3
- data/docs/lib/omniauth/strategies/dailycred.html +14 -9
- data/lib/dailycred/acts_as_dailycred.rb +25 -0
- data/lib/dailycred/client.rb +103 -0
- data/lib/dailycred/engine.rb +51 -0
- data/lib/dailycred/helper.rb +39 -1
- data/lib/{middleware → dailycred}/middleware.rb +12 -14
- data/lib/dailycred/tests_helper.rb +5 -0
- data/lib/dailycred/user.rb +2 -2
- data/lib/dailycred.rb +1 -106
- data/lib/generators/dailycred_generator.rb +3 -59
- data/lib/generators/templates/info.html.erb +1 -1
- data/lib/generators/templates/omniauth.rb +6 -17
- data/lib/generators/templates/user.rb +1 -16
- data/lib/omniauth/strategies/dailycred.rb +6 -5
- data/script/download_info.rb +11 -0
- data/spec/omniauth/strategies/dailycred_spec.rb +2 -2
- data/spec/support/dailycred_spec.rb +2 -2
- data/test/generator_test.rb +5 -36
- metadata +20 -6
- data/lib/omniauth-dailycred/version.rb +0 -5
@@ -0,0 +1,119 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
5
|
+
<title>helper.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>helper.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">module</span> <span class="nn">Helpers</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>use as a before<em>filter to only allow signed in users
|
58
|
+
example:
|
59
|
+
before</em>filter :authenticate</p>
|
60
|
+
</td>
|
61
|
+
<td class=code>
|
62
|
+
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">authenticate</span>
|
63
|
+
<span class="n">redirect_to_auth</span> <span class="k">unless</span> <span class="n">current_user</span>
|
64
|
+
<span class="k">end</span></pre></div>
|
65
|
+
</td>
|
66
|
+
</tr>
|
67
|
+
<tr id='section-3'>
|
68
|
+
<td class=docs>
|
69
|
+
<div class="pilwrap">
|
70
|
+
<a class="pilcrow" href="#section-3">¶</a>
|
71
|
+
</div>
|
72
|
+
<p>helper method for getting an instance of dailycred
|
73
|
+
example:
|
74
|
+
dailycred.tagUser “user_id”, “tag”</p>
|
75
|
+
|
76
|
+
<p>for more documentation, visit https://www.dailycred.com/api/ruby</p>
|
77
|
+
</td>
|
78
|
+
<td class=code>
|
79
|
+
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">dailycred</span>
|
80
|
+
<span class="n">config</span> <span class="o">=</span> <span class="no">Rails</span><span class="o">.</span><span class="n">configuration</span>
|
81
|
+
<span class="vi">@dailycred</span> <span class="o">||=</span> <span class="no">Dailycred</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="n">config</span><span class="o">.</span><span class="n">DAILYCRED_CLIENT_ID</span><span class="p">,</span> <span class="n">config</span><span class="o">.</span><span class="n">DAILYCRED_SECRET_KEY</span><span class="p">,</span> <span class="n">config</span><span class="o">.</span><span class="n">DAILYCRED_OPTIONS</span><span class="p">)</span>
|
82
|
+
<span class="k">end</span></pre></div>
|
83
|
+
</td>
|
84
|
+
</tr>
|
85
|
+
<tr id='section-4'>
|
86
|
+
<td class=docs>
|
87
|
+
<div class="pilwrap">
|
88
|
+
<a class="pilcrow" href="#section-4">¶</a>
|
89
|
+
</div>
|
90
|
+
<p>when making oauth calls, we may need to redirect to our oauth callback url
|
91
|
+
make sure we have the correct state passed back and forth</p>
|
92
|
+
|
93
|
+
</td>
|
94
|
+
<td class=code>
|
95
|
+
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">set_state</span>
|
96
|
+
<span class="vi">@state</span> <span class="o">=</span> <span class="n">session</span><span class="o">[</span><span class="s2">"omniauth.state"</span><span class="o">]</span> <span class="o">=</span> <span class="no">SecureRandom</span><span class="o">.</span><span class="n">hex</span><span class="p">(</span><span class="mi">24</span><span class="p">)</span>
|
97
|
+
<span class="k">end</span>
|
98
|
+
|
99
|
+
<span class="k">def</span> <span class="nf">login_path</span><span class="p">(</span><span class="n">params</span><span class="o">=</span><span class="p">{})</span>
|
100
|
+
<span class="s2">"/auth/dailycred"</span>
|
101
|
+
<span class="k">end</span>
|
102
|
+
|
103
|
+
<span class="k">def</span> <span class="nf">redirect_to_auth</span> <span class="n">opts</span><span class="o">=</span><span class="p">{}</span>
|
104
|
+
<span class="n">conf</span> <span class="o">=</span> <span class="no">Rails</span><span class="o">.</span><span class="n">configuration</span><span class="o">.</span><span class="n">DAILYCRED_OPTIONS</span>
|
105
|
+
<span class="n">path</span> <span class="o">=</span> <span class="o">!</span><span class="n">conf</span><span class="o">[</span><span class="ss">:after_auth</span><span class="o">].</span><span class="n">nil?</span> <span class="p">?</span> <span class="n">conf</span><span class="o">[</span><span class="ss">:after_auth</span><span class="o">]</span> <span class="p">:</span> <span class="n">dailycred_engine</span><span class="o">.</span><span class="n">auth_info_path</span>
|
106
|
+
<span class="n">redirect_to</span> <span class="n">path</span><span class="p">,</span> <span class="n">opts</span>
|
107
|
+
<span class="k">end</span>
|
108
|
+
|
109
|
+
|
110
|
+
<span class="no">ActiveSupport</span><span class="o">.</span><span class="n">on_load</span><span class="p">(</span><span class="ss">:action_controller</span><span class="p">)</span> <span class="k">do</span>
|
111
|
+
<span class="n">helper_method</span> <span class="ss">:current_user</span><span class="p">,</span> <span class="ss">:login_path</span><span class="p">,</span> <span class="ss">:set_state</span><span class="p">,</span> <span class="ss">:dailycred</span><span class="p">,</span> <span class="ss">:authenticate</span>
|
112
|
+
<span class="k">end</span>
|
113
|
+
<span class="k">end</span>
|
114
|
+
<span class="k">end</span></pre></div>
|
115
|
+
</td>
|
116
|
+
</tr>
|
117
|
+
</table>
|
118
|
+
</div>
|
119
|
+
</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>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="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>middleware.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>tests_helper.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>tests_helper.rb</h1></th>
|
36
|
+
<th class=code></th>
|
37
|
+
</tr>
|
38
|
+
</thead>
|
39
|
+
<tbody>
|
40
|
+
</table>
|
41
|
+
</div>
|
42
|
+
</body>
|
@@ -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>
|
data/docs/lib/dailycred.html
CHANGED
@@ -13,15 +13,19 @@
|
|
13
13
|
<div id="jump_wrapper">
|
14
14
|
<div id="jump_page">
|
15
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>
|
16
23
|
<a class="source" href="generators/dailycred_generator.html">dailycred_generator.rb</a>
|
17
24
|
<a class="source" href="generators/templates/migration_create_user.html">migration_create_user.rb</a>
|
18
25
|
<a class="source" href="generators/templates/omniauth.html">omniauth.rb</a>
|
19
26
|
<a class="source" href="generators/templates/sessions_controller.html">sessions_controller.rb</a>
|
20
27
|
<a class="source" href="generators/templates/user.html">user.rb</a>
|
21
|
-
<a class="source" href="middleware/middleware.html">middleware.rb</a>
|
22
|
-
<a class="source" href="omniauth-dailycred/version.html">version.rb</a>
|
23
28
|
<a class="source" href="omniauth/strategies/dailycred.html">dailycred.rb</a>
|
24
|
-
<a class="source" href="user/user.html">user.rb</a>
|
25
29
|
</div>
|
26
30
|
</div>
|
27
31
|
</div>
|
@@ -33,180 +37,6 @@
|
|
33
37
|
</tr>
|
34
38
|
</thead>
|
35
39
|
<tbody>
|
36
|
-
<tr id='section-1'>
|
37
|
-
<td class=docs>
|
38
|
-
<div class="pilwrap">
|
39
|
-
<a class="pilcrow" href="#section-1">¶</a>
|
40
|
-
</div>
|
41
|
-
|
42
|
-
</td>
|
43
|
-
<td class=code>
|
44
|
-
<div class='highlight'><pre><span class="nb">require</span> <span class="s2">"omniauth-dailycred/version"</span>
|
45
|
-
<span class="nb">require</span> <span class="s2">"omniauth/strategies/dailycred"</span>
|
46
|
-
<span class="nb">require</span> <span class="s2">"middleware/middleware"</span>
|
47
|
-
|
48
|
-
<span class="k">class</span> <span class="nc">Dailycred</span>
|
49
|
-
|
50
|
-
<span class="kp">attr_accessor</span> <span class="ss">:client_id</span><span class="p">,</span> <span class="ss">:secret_key</span><span class="p">,</span> <span class="ss">:options</span><span class="p">,</span> <span class="ss">:url</span>
|
51
|
-
|
52
|
-
<span class="no">URL</span> <span class="o">=</span> <span class="s2">"https://www.dailycred.com"</span>
|
53
|
-
|
54
|
-
<span class="no">ROUTES</span> <span class="o">=</span> <span class="p">{</span>
|
55
|
-
<span class="ss">:signup</span> <span class="o">=></span> <span class="s2">"/user/api/signup.json"</span><span class="p">,</span>
|
56
|
-
<span class="ss">:login</span> <span class="o">=></span> <span class="s2">"/user/api/signin.json"</span>
|
57
|
-
<span class="p">}</span></pre></div>
|
58
|
-
</td>
|
59
|
-
</tr>
|
60
|
-
<tr id='section-2'>
|
61
|
-
<td class=docs>
|
62
|
-
<div class="pilwrap">
|
63
|
-
<a class="pilcrow" href="#section-2">¶</a>
|
64
|
-
</div>
|
65
|
-
<p>Initializes a dailycred object</p>
|
66
|
-
|
67
|
-
<ul>
|
68
|
-
<li>@param [String] client_id the client’s daiycred client id</li>
|
69
|
-
<li>@param [String] secret_key the clients secret key</li>
|
70
|
-
<li>@param [Hash] opts a hash of options</li>
|
71
|
-
</ul>
|
72
|
-
</td>
|
73
|
-
<td class=code>
|
74
|
-
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="n">client_id</span><span class="p">,</span> <span class="n">secret_key</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> <span class="n">opts</span><span class="o">=</span><span class="p">{})</span>
|
75
|
-
<span class="vi">@client_id</span> <span class="o">=</span> <span class="n">client_id</span>
|
76
|
-
<span class="vi">@secret_key</span> <span class="o">=</span> <span class="n">secret_key</span>
|
77
|
-
<span class="vi">@options</span> <span class="o">=</span> <span class="n">opts</span>
|
78
|
-
<span class="n">opts</span><span class="o">[</span><span class="ss">:client_options</span><span class="o">]</span> <span class="o">||=</span> <span class="p">{}</span>
|
79
|
-
<span class="vi">@url</span> <span class="o">=</span> <span class="n">opts</span><span class="o">[</span><span class="ss">:client_options</span><span class="o">][</span><span class="ss">:site</span><span class="o">]</span> <span class="o">||</span> <span class="no">Dailycred</span><span class="o">::</span><span class="no">URL</span>
|
80
|
-
<span class="k">end</span></pre></div>
|
81
|
-
</td>
|
82
|
-
</tr>
|
83
|
-
<tr id='section-3'>
|
84
|
-
<td class=docs>
|
85
|
-
<div class="pilwrap">
|
86
|
-
<a class="pilcrow" href="#section-3">¶</a>
|
87
|
-
</div>
|
88
|
-
<p>Generates a Dailycred event</p>
|
89
|
-
|
90
|
-
<ul>
|
91
|
-
<li>@param [String] user_id the user’s dailycred user id</li>
|
92
|
-
<li>@param [String] key the name of the event type</li>
|
93
|
-
<li>@param [String] val the value of the event (optional)</li>
|
94
|
-
</ul>
|
95
|
-
</td>
|
96
|
-
<td class=code>
|
97
|
-
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">event</span><span class="p">(</span><span class="n">user_id</span><span class="p">,</span> <span class="n">key</span><span class="p">,</span> <span class="n">val</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span>
|
98
|
-
<span class="n">opts</span> <span class="o">=</span> <span class="p">{</span>
|
99
|
-
<span class="ss">:key</span> <span class="o">=></span> <span class="n">key</span><span class="p">,</span>
|
100
|
-
<span class="ss">:valuestring</span> <span class="o">=></span> <span class="n">val</span><span class="p">,</span>
|
101
|
-
<span class="ss">:user_id</span> <span class="o">=></span> <span class="n">user_id</span>
|
102
|
-
<span class="p">}</span>
|
103
|
-
<span class="n">post</span> <span class="s2">"/admin/api/customevent.json"</span><span class="p">,</span> <span class="n">opts</span>
|
104
|
-
<span class="k">end</span></pre></div>
|
105
|
-
</td>
|
106
|
-
</tr>
|
107
|
-
<tr id='section-4'>
|
108
|
-
<td class=docs>
|
109
|
-
<div class="pilwrap">
|
110
|
-
<a class="pilcrow" href="#section-4">¶</a>
|
111
|
-
</div>
|
112
|
-
<p>Tag a user in dailycred</p>
|
113
|
-
|
114
|
-
<ul>
|
115
|
-
<li>@param [String] user_id the user’s dailycred user id</li>
|
116
|
-
<li>@param [String] tag the desired tag to add</li>
|
117
|
-
</ul>
|
118
|
-
</td>
|
119
|
-
<td class=code>
|
120
|
-
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">tag</span><span class="p">(</span><span class="n">user_id</span><span class="p">,</span> <span class="n">tag</span><span class="p">)</span>
|
121
|
-
<span class="n">opts</span> <span class="o">=</span> <span class="p">{</span>
|
122
|
-
<span class="ss">:user_id</span> <span class="o">=></span> <span class="n">user_id</span><span class="p">,</span>
|
123
|
-
<span class="ss">:tag</span> <span class="o">=></span> <span class="n">tag</span>
|
124
|
-
<span class="p">}</span>
|
125
|
-
<span class="n">post</span> <span class="s2">"/admin/api/user/tag.json"</span><span class="p">,</span> <span class="n">opts</span>
|
126
|
-
<span class="k">end</span></pre></div>
|
127
|
-
</td>
|
128
|
-
</tr>
|
129
|
-
<tr id='section-5'>
|
130
|
-
<td class=docs>
|
131
|
-
<div class="pilwrap">
|
132
|
-
<a class="pilcrow" href="#section-5">¶</a>
|
133
|
-
</div>
|
134
|
-
<p>Untag a user in dailycred
|
135
|
-
(see #tag)</p>
|
136
|
-
</td>
|
137
|
-
<td class=code>
|
138
|
-
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">untag</span><span class="p">(</span><span class="n">user_id</span><span class="p">,</span> <span class="n">tag</span><span class="p">)</span>
|
139
|
-
<span class="n">opts</span> <span class="o">=</span> <span class="p">{</span>
|
140
|
-
<span class="ss">:user_id</span> <span class="o">=></span> <span class="n">user_id</span><span class="p">,</span>
|
141
|
-
<span class="ss">:tag</span> <span class="o">=></span> <span class="n">tag</span>
|
142
|
-
<span class="p">}</span>
|
143
|
-
<span class="n">post</span> <span class="s2">"/admin/api/user/untag.json"</span><span class="p">,</span> <span class="n">opts</span>
|
144
|
-
<span class="k">end</span></pre></div>
|
145
|
-
</td>
|
146
|
-
</tr>
|
147
|
-
<tr id='section-6'>
|
148
|
-
<td class=docs>
|
149
|
-
<div class="pilwrap">
|
150
|
-
<a class="pilcrow" href="#section-6">¶</a>
|
151
|
-
</div>
|
152
|
-
<p>Send a reset password email</p>
|
153
|
-
|
154
|
-
<ul>
|
155
|
-
<li>@param [string] user the user’s email or username</li>
|
156
|
-
</ul>
|
157
|
-
</td>
|
158
|
-
<td class=code>
|
159
|
-
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">passReset</span><span class="p">(</span><span class="n">user</span><span class="p">)</span>
|
160
|
-
<span class="n">opts</span> <span class="o">=</span> <span class="p">{</span>
|
161
|
-
<span class="ss">:user</span> <span class="o">=></span> <span class="n">user</span>
|
162
|
-
<span class="p">}</span>
|
163
|
-
<span class="n">post</span> <span class="s2">"/password/api/reset"</span><span class="p">,</span> <span class="n">opts</span>
|
164
|
-
<span class="k">end</span></pre></div>
|
165
|
-
</td>
|
166
|
-
</tr>
|
167
|
-
<tr id='section-7'>
|
168
|
-
<td class=docs>
|
169
|
-
<div class="pilwrap">
|
170
|
-
<a class="pilcrow" href="#section-7">¶</a>
|
171
|
-
</div>
|
172
|
-
<p>A wildcard for making any post requests to dailycred.
|
173
|
-
client<em>id and client</em>secret are automatically added to the request</p>
|
174
|
-
|
175
|
-
<ul>
|
176
|
-
<li>@param [string] url</li>
|
177
|
-
<li>@param [hash] opts</li>
|
178
|
-
<li>@param [boolean] secure whether the client_secret should be passed. Defaults to true</li>
|
179
|
-
</ul>
|
180
|
-
|
181
|
-
</td>
|
182
|
-
<td class=code>
|
183
|
-
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">post</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">opts</span><span class="p">,</span> <span class="n">secure</span><span class="o">=</span><span class="kp">true</span><span class="p">)</span>
|
184
|
-
<span class="n">opts</span><span class="o">.</span><span class="n">merge!</span> <span class="n">base_opts</span><span class="p">(</span><span class="n">secure</span><span class="p">)</span>
|
185
|
-
<span class="n">response</span> <span class="o">=</span> <span class="n">get_conn</span><span class="o">.</span><span class="n">post</span> <span class="n">url</span><span class="p">,</span> <span class="n">opts</span>
|
186
|
-
<span class="k">end</span>
|
187
|
-
|
188
|
-
<span class="kp">private</span>
|
189
|
-
|
190
|
-
<span class="k">def</span> <span class="nf">ssl_opts</span>
|
191
|
-
<span class="n">opts</span> <span class="o">=</span> <span class="p">{}</span>
|
192
|
-
<span class="k">if</span> <span class="vi">@options</span><span class="o">[</span><span class="ss">:client_options</span><span class="o">]</span> <span class="o">&&</span> <span class="vi">@options</span><span class="o">[</span><span class="ss">:client_options</span><span class="o">][</span><span class="ss">:ssl</span><span class="o">]</span>
|
193
|
-
<span class="n">opts</span><span class="o">[</span><span class="ss">:ssl</span><span class="o">]</span> <span class="o">=</span> <span class="vi">@options</span><span class="o">[</span><span class="ss">:client_options</span><span class="o">][</span><span class="ss">:ssl</span><span class="o">]</span>
|
194
|
-
<span class="k">end</span>
|
195
|
-
<span class="n">opts</span>
|
196
|
-
<span class="k">end</span>
|
197
|
-
|
198
|
-
<span class="k">def</span> <span class="nf">base_opts</span> <span class="n">secure</span><span class="o">=</span><span class="kp">true</span>
|
199
|
-
<span class="n">opts</span> <span class="o">=</span> <span class="p">{</span><span class="ss">:client_id</span> <span class="o">=></span> <span class="vi">@client_id</span><span class="p">}</span>
|
200
|
-
<span class="n">opts</span><span class="o">[</span><span class="ss">:client_secret</span><span class="o">]</span> <span class="o">=</span> <span class="vi">@secret_key</span> <span class="k">if</span> <span class="n">secure</span>
|
201
|
-
<span class="n">opts</span>
|
202
|
-
<span class="k">end</span>
|
203
|
-
|
204
|
-
<span class="k">def</span> <span class="nf">get_conn</span>
|
205
|
-
<span class="no">Faraday</span><span class="o">::</span><span class="no">Connection</span><span class="o">.</span><span class="n">new</span> <span class="vi">@url</span><span class="p">,</span> <span class="n">ssl_opts</span>
|
206
|
-
<span class="k">end</span>
|
207
|
-
<span class="k">end</span></pre></div>
|
208
|
-
</td>
|
209
|
-
</tr>
|
210
40
|
</table>
|
211
41
|
</div>
|
212
42
|
</body>
|
@@ -13,15 +13,19 @@
|
|
13
13
|
<div id="jump_wrapper">
|
14
14
|
<div id="jump_page">
|
15
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>
|
16
23
|
<a class="source" href="dailycred_generator.html">dailycred_generator.rb</a>
|
17
24
|
<a class="source" href="templates/migration_create_user.html">migration_create_user.rb</a>
|
18
25
|
<a class="source" href="templates/omniauth.html">omniauth.rb</a>
|
19
26
|
<a class="source" href="templates/sessions_controller.html">sessions_controller.rb</a>
|
20
27
|
<a class="source" href="templates/user.html">user.rb</a>
|
21
|
-
<a class="source" href="../middleware/middleware.html">middleware.rb</a>
|
22
|
-
<a class="source" href="../omniauth-dailycred/version.html">version.rb</a>
|
23
28
|
<a class="source" href="../omniauth/strategies/dailycred.html">dailycred.rb</a>
|
24
|
-
<a class="source" href="../user/user.html">user.rb</a>
|
25
29
|
</div>
|
26
30
|
</div>
|
27
31
|
</div>
|
@@ -13,6 +13,8 @@
|
|
13
13
|
<div id="jump_wrapper">
|
14
14
|
<div id="jump_page">
|
15
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>
|
16
18
|
<a class="source" href="../dailycred_generator.html">dailycred_generator.rb</a>
|
17
19
|
<a class="source" href="migration_create_user.html">migration_create_user.rb</a>
|
18
20
|
<a class="source" href="omniauth.html">omniauth.rb</a>
|
@@ -21,7 +23,6 @@
|
|
21
23
|
<a class="source" href="../../middleware/middleware.html">middleware.rb</a>
|
22
24
|
<a class="source" href="../../omniauth-dailycred/version.html">version.rb</a>
|
23
25
|
<a class="source" href="../../omniauth/strategies/dailycred.html">dailycred.rb</a>
|
24
|
-
<a class="source" href="../../user/user.html">user.rb</a>
|
25
26
|
</div>
|
26
27
|
</div>
|
27
28
|
</div>
|