volt-user_templates 0.1.7 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7facba424953a4eab19131d416e201c2d56ece0f
4
- data.tar.gz: 09b0bdfac1dfe9267b18d4e9ec54c0d09cdec77d
3
+ metadata.gz: a169f842ffc8ac6249c95f115aa4d83ca0d46ae9
4
+ data.tar.gz: d62855a1ef6018a30db81b58429db925fa4e6f1b
5
5
  SHA512:
6
- metadata.gz: 0f7ce24ed636bbb5292ce359947a425d1837cd3b2aa5dca8c1885c4c83749232c8cc6acffc5e69cf84723aa04cc85606163435d57cfdc096452c6611706c6de7
7
- data.tar.gz: 5c26297767e7aa98762336164141a1b37f02314805f47d79fc2c2175fed76201382a7e4d9483c2edc1fa9061ffd0ffeeca36face93cd1e0d85e10cf0a6f92341
6
+ metadata.gz: c65b247fc8120f057d3497d7cd9320dbe09e603af6d5ec0ff06a53d5fdf2d06ece15246f18c2f216145134feb67efaef5546db05f4151b253fcaf5bec5a15306
7
+ data.tar.gz: dca98dd40b3ee81946a7b4b66f9f17685ed952d9530be520caaa4f6cb058b865aa851fd379021586ce8d2431f839eaf433618489ae0a14c9ba53461345cce0b2
data/README.md CHANGED
@@ -4,18 +4,18 @@ Volt user templates provide out of the box templates for users to signup, login,
4
4
 
5
5
  ## Install
6
6
 
7
- volt-user-templates now ships with volt, but if you have removed it, you can add it back with the following:
7
+ volt-user_templates now ships with volt, but if you have removed it, you can add it back with the following:
8
8
 
9
9
  In your Gemfile, put:
10
10
 
11
11
  ```ruby
12
- gem 'volt-user-templates'
12
+ gem 'volt-user_templates'
13
13
  ```
14
14
 
15
15
  Then in any component you want to use the templates in, add the following to config/dependencies.rb
16
16
 
17
17
  ```ruby
18
- component 'user-templates'
18
+ component 'user_templates'
19
19
  ```
20
20
 
21
21
  ## Use
@@ -27,8 +27,9 @@ You can use volt-user-template two different ways.
27
27
  Add the following to your main components route file:
28
28
 
29
29
  ```ruby
30
- get '/signup', _controller: 'user-templates', _action: 'signup'
31
- get '/login', _controller: 'user-templates', _action: 'login'
30
+ client '/signup', component: 'user_templates', controller: 'signup'
31
+ client '/forgot', component: 'user_templates', controller: 'login', action: 'forgot'
32
+ client '/login', component: 'user_templates', controller: 'login', action: 'index'
32
33
  ```
33
34
 
34
35
  Now you can link to /signup and /login
@@ -38,7 +39,7 @@ Now you can link to /signup and /login
38
39
  ### Login
39
40
 
40
41
  ```html
41
- <:user-templates:login post-login-url="/" />
42
+ <:user_templates:login post-login-url="/" />
42
43
  ```
43
44
 
44
45
  The login template takes an optional post-login-url that will be redirected to after a successful login.
@@ -46,15 +47,21 @@ The login template takes an optional post-login-url that will be redirected to a
46
47
  ### Signup
47
48
 
48
49
  ```html
49
- <:user-templates:signup post-signup-url="/" />
50
+ <:user_templates:signup post-signup-url="/" />
50
51
  ```
51
52
 
52
53
  Signup takes an optional post-signup-url that will be redirected to after signup.
53
54
 
55
+ ### Forgot
56
+
57
+ ```html
58
+ <:user_templates:login:forgot post-forgot-url="/login" />
59
+ ```
60
+
54
61
  ### Logout
55
62
 
56
- volt-user-templates provides a nav bar tag that provides a login/logout link and shows the users name.
63
+ volt-user_templates provides a nav bar tag that provides a login/logout link and shows the users name.
57
64
 
58
65
  ```html
59
- <:user-templates:menu />
66
+ <:user_templates:menu />
60
67
  ```
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.7
1
+ 0.2.0
@@ -3,6 +3,7 @@ module UserTemplates
3
3
  reactive_accessor :errors
4
4
  reactive_accessor :login
5
5
  reactive_accessor :password
6
+ reactive_accessor :reset_email
6
7
 
7
8
  def do_login
8
9
  Volt.login(login, password).then do
@@ -20,6 +21,20 @@ module UserTemplates
20
21
  end
21
22
  end
22
23
 
24
+ def forgot_url
25
+ url_for(component: 'user_templates', controller: 'login', action: 'forgot')
26
+ end
27
+
28
+ def send_reset_email
29
+ UserTemplateTasks.send_reset_email(reset_email).then do
30
+ self.reset_email = ''
31
+ flash._notices << 'Reset email sent.'
32
+ redirect_to(attrs.post_forgot_url || '/login')
33
+ end.fail do |err|
34
+ flash._errors << err.to_s
35
+ end
36
+ end
37
+
23
38
  def use_username?
24
39
  Volt.config.public.try(:auth).try(:use_username)
25
40
  end
@@ -0,0 +1,13 @@
1
+ class UserTemplateTasks < Volt::Task
2
+ def send_reset_email(email)
3
+ # Find user by e-mail
4
+ Volt.skip_permissions do
5
+ store._users.where(email: email).fetch_first do |user|
6
+ Mailer.deliver('user_templates/mailers/forgot', {to: email, name: user._name}).then do
7
+ true
8
+ end
9
+ end
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ <:Title>
2
+ Forgot your Password
3
+
4
+ <:Body>
5
+ <div class="row">
6
+ <div class="col-md-6 col-md-offset-3">
7
+ <div class="span4 offset4 well">
8
+ <legend>Forgot your Password</legend>
9
+
10
+ <p>We'll e-mail you a reset link.</p>
11
+ <form e-submit="send_reset_email">
12
+ <div class="form-group">
13
+ <label class="control-label">Email</label>
14
+ <input class="form-control" type="text" value="{{ reset_email }}" autofocus />
15
+ </div>
16
+
17
+ <button class="btn btn-info btn-block">Reset Password</button>
18
+ </form>
19
+ </div>
20
+ </div>
21
+ </div>
@@ -20,11 +20,11 @@
20
20
  Email
21
21
  {{ end }}
22
22
  </label>
23
- <input class="form-control" type="text" value="{{ login }}">
23
+ <input class="form-control" type="text" value="{{ login }}" autofocus />
24
24
  </div>
25
25
 
26
26
  <div class="form-group">
27
- <label class="control-label">Password</label>
27
+ <label class="control-label">Password <small style="font-weight: normal;">(<a href="{{ forgot_url }}">forgot password</a>)</small></label>
28
28
  <input class="form-control" type="password" value="{{ password }}">
29
29
  </div>
30
30
 
@@ -0,0 +1,41 @@
1
+ <:Subject>
2
+ Reset your Password
3
+
4
+ <:Html>
5
+ <html>
6
+ <body>
7
+ <table cellspacing="0" cellpadding="0" border="0" style="color: #333; background: #fff; padding: 0; margin: 0; width: 100%; font: 15px/1.25em 'Helvetica Neue', Arial, Helvetica;">
8
+ <tbody>
9
+ <tr width="100%">
10
+ <td valign="top" align="left" style="background: #f0f0f0; font: 15px/1.25em 'Helvetica Neue', Arial, Helvetica;">
11
+ <table style="border: none; padding: 0 18px; margin: 50px auto; width: 500px;">
12
+ <tbody>
13
+ <tr width="100%" height="57">
14
+ <td valign="top" align="left" style="border-top-left-radius: 4px; border-top-right-radius: 4px; background: #337ab7; padding: 12px 18px; text-align: center; font-weight: bold; font-size: 28px; color: #fff; vertical-align: middle;">
15
+ {{ Volt.config.app_name }}
16
+ </td>
17
+ </tr>
18
+ <tr width="100%">
19
+ <td valign="top" align="left" style="border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; background:#fff; padding: 18px;">
20
+ <h1 style="font-size: 20px; margin: 0; color: #333;"> Hello {{ name }}, </h1>
21
+ <p style="font: 15px/1.25em 'Helvetica Neue', Arial, Helvetica; color: #333;"> We heard you needed to reset your password. Click the button below and you'll be redirected to a page where you can reset your password.</p>
22
+ <p style="font: 15px/1.25em 'Helvetica Neue', Arial, Helvetica; margin-bottom: 0; text-align: center; color: #333;">
23
+ <a href="" style="border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; background: #5cb85c; color: #fff; cursor: pointer; display: block; font-weight: 700; font-size: 16px; line-height: 1.25em; margin: 24px auto 24px; padding: 10px 18px; text-decoration: none; width: 180px; text-align: center;"> Reset Password </a>
24
+ </p>
25
+ </td>
26
+ </tr>
27
+ </tbody>
28
+ </table>
29
+ </td>
30
+ </tr>
31
+ </tbody>
32
+ </table>
33
+ </body>
34
+ </html>
35
+
36
+ <:Text>
37
+ Hey {{ name }},
38
+
39
+ We heard you needed to reset your password. Go to the following url to reset your password:
40
+
41
+ http://www.someurl.com/
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.name = "volt-user_templates"
10
10
  spec.version = version
11
11
  spec.authors = ["Ryan Stout"]
12
- spec.email = ["ryanstout@gmail.com"]
12
+ spec.email = ["ryan@agileproductions.com"]
13
13
  spec.summary = %q{Volt user templates provide out of the box templates for users to signup, login, and logout. }
14
14
  spec.homepage = ""
15
15
  spec.license = "MIT"
@@ -20,5 +20,6 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ["lib"]
21
21
 
22
22
  spec.add_dependency "volt-fields", "~> 0.1.0"
23
+ spec.add_dependency "volt-mailer", "~> 0.0.2"
23
24
  spec.add_development_dependency "rake"
24
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: volt-user_templates
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Stout
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-04 00:00:00.000000000 Z
11
+ date: 2015-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: volt-fields
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: volt-mailer
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.2
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -40,7 +54,7 @@ dependencies:
40
54
  version: '0'
41
55
  description:
42
56
  email:
43
- - ryanstout@gmail.com
57
+ - ryan@agileproductions.com
44
58
  executables: []
45
59
  extensions: []
46
60
  extra_rdoc_files: []
@@ -55,7 +69,10 @@ files:
55
69
  - app/user_templates/controllers/login_controller.rb
56
70
  - app/user_templates/controllers/menu_controller.rb
57
71
  - app/user_templates/controllers/signup_controller.rb
72
+ - app/user_templates/tasks/user_template_tasks.rb
73
+ - app/user_templates/views/login/forgot.html
58
74
  - app/user_templates/views/login/index.html
75
+ - app/user_templates/views/mailers/forgot.email
59
76
  - app/user_templates/views/menu/index.html
60
77
  - app/user_templates/views/signup/index.html
61
78
  - lib/volt/user-templates.rb