volt-user_templates 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62412eb3bb8518f0265635d4e9eb5be024d41a7c
4
- data.tar.gz: 90f2ce74a486c78799acc24dc900a6bbd79e9374
3
+ metadata.gz: 145bf08ec26e29200d73efe316caeec2374efe25
4
+ data.tar.gz: eb4990ffeb13fae9a9c107116b6cce6d26d1944b
5
5
  SHA512:
6
- metadata.gz: 54015581a0c66f3b80afd0917a2815e691afeb2623747deb7f03953542488abf037a36b66e4283a0cb19fa4d69c3537b7255123c6220809201da3ebaa00cb2b5
7
- data.tar.gz: 08917295aeff55475203165c7104b93003bf266835a9aa354c58037d24287262e5cd25247c0069189fdbdae7869ec2ca41dd414c44588475bf3556dd7cb7182b
6
+ metadata.gz: 69a7cca480dcb1d833dc0ca04341191388d2bb555e4bbc0cc90b4bf759e7784c01ec5fab592af922762b05bc376575b86745ae7d3afaf539310f7549383c7a8a
7
+ data.tar.gz: 52daf097444a39267f1fe516daf7680dba838f976845cb8a41addd3d2aef12f08438ec4ead2badc036414003cc5763eba0635ceab285f76e3c9cb89f3dfc5417
data/README.md CHANGED
@@ -28,6 +28,7 @@ Add the following to your main components route file:
28
28
 
29
29
  ```ruby
30
30
  client '/signup', component: 'user_templates', controller: 'signup'
31
+ client '/password_reset', component: 'user_templates', controller: 'password_reset', action: 'index'
31
32
  client '/forgot', component: 'user_templates', controller: 'login', action: 'forgot'
32
33
  client '/login', component: 'user_templates', controller: 'login', action: 'index'
33
34
  ```
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
@@ -3,7 +3,7 @@ module UserTemplates
3
3
  before_action :require_login
4
4
 
5
5
  def index
6
- self.model = Volt.fetch_current_user.then(&:buffer)
6
+ self.model = Volt.current_user.then(&:buffer)
7
7
  end
8
8
 
9
9
  def save
@@ -4,6 +4,7 @@ module UserTemplates
4
4
  reactive_accessor :login
5
5
  reactive_accessor :password
6
6
  reactive_accessor :reset_email
7
+ reactive_accessor :new_password
7
8
 
8
9
  def do_login
9
10
  Volt.login(login, password).then do |res|
@@ -1,8 +1,13 @@
1
1
  module UserTemplates
2
2
  class MenuController < Volt::ModelController
3
3
  def show_name
4
- Volt.fetch_current_user.then do |user|
5
- user._name || user._email || user._username
4
+ Volt.current_user.then do |user|
5
+ # Make sure there is a user
6
+ if user
7
+ user._name || user._email || user._username
8
+ else
9
+ ''
10
+ end
6
11
  end
7
12
  end
8
13
 
@@ -0,0 +1,10 @@
1
+ module UserTemplates
2
+ class PasswordResetController < Volt::ModelController
3
+ reactive_accessor :new_password
4
+
5
+ def reset_password
6
+
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ class PasswordResetTasks < Volt::Task
2
+ def reset_password(user_id, token, new_password)
3
+
4
+ end
5
+ end
@@ -1,10 +1,6 @@
1
1
  require 'digest'
2
2
 
3
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
-
8
4
  def send_reset_email(email)
9
5
  # Find user by e-mail
10
6
  Volt.skip_permissions do
@@ -12,7 +8,11 @@ class UserTemplateTasks < Volt::Task
12
8
  if user
13
9
  reset_token = password_reset_token(user.id)
14
10
 
15
- reset_url = "http://#{Volt.config.domain}/#{reset_token}"
11
+ reset_base_url = url_for(component: 'user_templates',
12
+ controller: 'password_reset', action: 'index')
13
+
14
+ reset_url = "http://#{Volt.config.domain}/#{reset_base_url}/?"
15
+ + "user_id=#{user_id}&token=#{reset_token}"
16
16
 
17
17
  Mailer.deliver('user_templates/mailers/forgot',
18
18
  {to: email, name: user._name, reset_url: reset_url}
@@ -23,4 +23,9 @@ class UserTemplateTasks < Volt::Task
23
23
  end
24
24
  end
25
25
  end
26
+
27
+ private
28
+ def password_reset_token(user_id)
29
+ Digest::SHA256.hexdigest("#{user_id}||#{Volt.config.app_secret}")
30
+ end
26
31
  end
@@ -0,0 +1,10 @@
1
+ <:Title>
2
+ Reset Password
3
+
4
+ <:Body>
5
+ <h1>Reset Password</h1>
6
+
7
+ <form e-click="reset_password">
8
+ <:fields:password label="New Password" value="{{ new_password }}" />
9
+ <button>Reset Password</button>
10
+ </form>
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.3.0
4
+ version: 0.4.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-26 00:00:00.000000000 Z
11
+ date: 2015-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: volt-fields
@@ -69,13 +69,16 @@ files:
69
69
  - app/user_templates/controllers/account_controller.rb
70
70
  - app/user_templates/controllers/login_controller.rb
71
71
  - app/user_templates/controllers/menu_controller.rb
72
+ - app/user_templates/controllers/password_reset_controller.rb
72
73
  - app/user_templates/controllers/signup_controller.rb
74
+ - app/user_templates/tasks/password_reset_tasks.rb
73
75
  - app/user_templates/tasks/user_template_tasks.rb
74
76
  - app/user_templates/views/account/index.html
75
77
  - app/user_templates/views/login/forgot.html
76
78
  - app/user_templates/views/login/index.html
77
79
  - app/user_templates/views/mailers/forgot.email
78
80
  - app/user_templates/views/menu/index.html
81
+ - app/user_templates/views/password_reset/index.html
79
82
  - app/user_templates/views/signup/index.html
80
83
  - lib/volt/user-templates.rb
81
84
  - volt-user_templates.gemspec