volt-user_templates 0.2.1 → 0.3.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: 0eaaeb969ed0696f54bb7050cb51ce7ff49897f7
4
- data.tar.gz: 006cd8c8e3220f4b7f48b0b77d5a7c53a114b52d
3
+ metadata.gz: 62412eb3bb8518f0265635d4e9eb5be024d41a7c
4
+ data.tar.gz: 90f2ce74a486c78799acc24dc900a6bbd79e9374
5
5
  SHA512:
6
- metadata.gz: 4511e46fd90c38d93946c54b767cfdb0a12b124635a649ce822abeda44d18205c69c3a4cdb56d2384852ce1092ccd23edbb7ea10d80084b9fd4403223ca17e9e
7
- data.tar.gz: a814236105ff75a201acc49df0523b7b5ea7db88e1edf4cd1231e3069cb5cdc3fd06f355a2f55caedef0cedf02c16b786de10c23761139bc122fdbca2509e999
6
+ metadata.gz: 54015581a0c66f3b80afd0917a2815e691afeb2623747deb7f03953542488abf037a36b66e4283a0cb19fa4d69c3537b7255123c6220809201da3ebaa00cb2b5
7
+ data.tar.gz: 08917295aeff55475203165c7104b93003bf266835a9aa354c58037d24287262e5cd25247c0069189fdbdae7869ec2ca41dd414c44588475bf3556dd7cb7182b
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.3.0
@@ -0,0 +1,16 @@
1
+ module UserTemplates
2
+ class AccountController < Volt::ModelController
3
+ before_action :require_login
4
+
5
+ def index
6
+ self.model = Volt.fetch_current_user.then(&:buffer)
7
+ end
8
+
9
+ def save
10
+ model.save! do
11
+ flash._notices << 'Account settings saved'
12
+ redirect_to '/'
13
+ end
14
+ end
15
+ end
16
+ end
@@ -6,13 +6,13 @@ module UserTemplates
6
6
  reactive_accessor :reset_email
7
7
 
8
8
  def do_login
9
- Volt.login(login, password).then do
9
+ Volt.login(login, password).then do |res|
10
10
  # Successful login, clear out the form
11
11
  self.errors = nil
12
12
  self.login = ''
13
13
  self.password = ''
14
14
 
15
- redirect_to(attrs.post_login_url || '/')
15
+ after_login
16
16
 
17
17
  nil
18
18
  end.fail do |errors|
@@ -21,6 +21,10 @@ module UserTemplates
21
21
  end
22
22
  end
23
23
 
24
+ def after_login
25
+ redirect_to(attrs.post_login_url || '/')
26
+ end
27
+
24
28
  def forgot_url
25
29
  url_for(component: 'user_templates', controller: 'login', action: 'forgot')
26
30
  end
@@ -12,12 +12,9 @@ module UserTemplates
12
12
  save!.then do |result|
13
13
  flash._notices << "Signup successful"
14
14
 
15
- post_signup_url = attrs.post_signup_url || '/'
16
-
17
15
  # On a successful signup, then login
18
16
  Volt.login(login, password).then do
19
- # Redirect to post signup url
20
- redirect_to post_signup_url
17
+ after_signup
21
18
  end.fail do |errors|
22
19
  # Show the error (probably only the server goes down)
23
20
  flash._errors << errors.to_s
@@ -27,6 +24,13 @@ module UserTemplates
27
24
  end
28
25
  end
29
26
 
27
+ def after_signup
28
+ post_signup_url = attrs.post_signup_url || '/'
29
+
30
+ # Redirect to post signup url
31
+ redirect_to post_signup_url
32
+ end
33
+
30
34
  def use_username?
31
35
  Volt.config.public.try(:auth).try(:use_username)
32
36
  end
@@ -1,10 +1,22 @@
1
+ require 'digest'
2
+
1
3
  class UserTemplateTasks < Volt::Task
4
+ def password_reset_token(user_id)
5
+ Digest::SHA256.hexdigest("#{user_id}||#{Volt.config.app_secret}")
6
+ end
7
+
2
8
  def send_reset_email(email)
3
9
  # Find user by e-mail
4
10
  Volt.skip_permissions do
5
11
  store._users.where(email: email).fetch_first do |user|
6
12
  if user
7
- Mailer.deliver('user_templates/mailers/forgot', {to: email, name: user._name})
13
+ reset_token = password_reset_token(user.id)
14
+
15
+ reset_url = "http://#{Volt.config.domain}/#{reset_token}"
16
+
17
+ Mailer.deliver('user_templates/mailers/forgot',
18
+ {to: email, name: user._name, reset_url: reset_url}
19
+ )
8
20
  else
9
21
  raise "There is no account with the e-mail of #{email}."
10
22
  end
@@ -0,0 +1,26 @@
1
+ <:Title>
2
+ Your Account
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>Basic Info</legend>
9
+
10
+ <form e-submit="save">
11
+ <:fields:text value="{{ _name }}" />
12
+ <:fields:textarea value="{{ _bio }}" />
13
+ <button class="btn btn-info btn-block">Save</button>
14
+ </form>
15
+
16
+ </div>
17
+ <hr />
18
+ <div class="span4 offset4 well">
19
+ <legend>Update Password</legend>
20
+ <form e-submit="save">
21
+ <:fields:text type="password" value="{{ _password }}" />
22
+ <button class="btn btn-info btn-block">Save</button>
23
+ </form>
24
+ </div>
25
+ </div>
26
+ </div>
@@ -24,7 +24,7 @@
24
24
  </div>
25
25
 
26
26
  <div class="form-group">
27
- <label class="control-label">Password <small style="font-weight: normal;">(<a href="{{ forgot_url }}">forgot password</a>)</small></label>
27
+ <label class="control-label">Password <small style="font-weight: normal;">(<a tabindex="-1" href="{{ forgot_url }}">forgot password</a>)</small></label>
28
28
  <input class="form-control" type="password" value="{{ password }}">
29
29
  </div>
30
30
 
@@ -20,7 +20,7 @@
20
20
  <h1 style="font-size: 20px; margin: 0; color: #333;"> Hello {{ name }}, </h1>
21
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
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>
23
+ <a href="{{ reset_url }}" 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
24
  </p>
25
25
  </td>
26
26
  </tr>
@@ -38,4 +38,4 @@ Hey {{ name }},
38
38
 
39
39
  We heard you needed to reset your password. Go to the following url to reset your password:
40
40
 
41
- http://www.someurl.com/
41
+ {{ reset_url }}
@@ -20,6 +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
+ spec.add_dependency "volt-mailer", "~> 0.1.0"
24
24
  spec.add_development_dependency "rake"
25
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.2.1
4
+ version: 0.3.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-05 00:00:00.000000000 Z
11
+ date: 2015-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: volt-fields
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.2
33
+ version: 0.1.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.0.2
40
+ version: 0.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,10 +66,12 @@ files:
66
66
  - VERSION
67
67
  - app/user_templates/config/dependencies.rb
68
68
  - app/user_templates/config/routes.rb
69
+ - app/user_templates/controllers/account_controller.rb
69
70
  - app/user_templates/controllers/login_controller.rb
70
71
  - app/user_templates/controllers/menu_controller.rb
71
72
  - app/user_templates/controllers/signup_controller.rb
72
73
  - app/user_templates/tasks/user_template_tasks.rb
74
+ - app/user_templates/views/account/index.html
73
75
  - app/user_templates/views/login/forgot.html
74
76
  - app/user_templates/views/login/index.html
75
77
  - app/user_templates/views/mailers/forgot.email
@@ -97,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
99
  version: '0'
98
100
  requirements: []
99
101
  rubyforge_project:
100
- rubygems_version: 2.2.2
102
+ rubygems_version: 2.4.5
101
103
  signing_key:
102
104
  specification_version: 4
103
105
  summary: Volt user templates provide out of the box templates for users to signup,