volt-user_templates 0.1.0 → 0.1.1

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: 8b5ea73fe65c14ed0de4064bfc68ee1dca8ed22e
4
- data.tar.gz: 536c392da63960d6d8c99e4ede4bcb63c04f1ccc
3
+ metadata.gz: 8bc3fdfa501803f047965774ac3691620c6afb88
4
+ data.tar.gz: a70a2d74fd4b366fdb4c5b3e7cb4f10b504fe9af
5
5
  SHA512:
6
- metadata.gz: 3a85ff6c08000e56d0dd23b838965cbdfd4b085f5e36030186463f9e64472bac3c636824c15bfcd479c5969e34b4781862b44d83d46ce51724b608326df24768
7
- data.tar.gz: 1fdbdd5caf3ecb191ba11343e2896d7f3d17874f3d7f1cb663197f041bff55e9aa4dcd3c0c5ff87e66d7a065cfd662d57f3b95e933dffe6bbc7a34c1b992b3e4
6
+ metadata.gz: 1dcf2619d390198ab04ba54cc0a23f2016ecf88df0f2e105c747e35b1c4d7f250eb9301db1bb7c951ed7b16a8cd455afc8ed9bcc9e8b722428bd8ad9411b02e2
7
+ data.tar.gz: f5bb4f75f76e4e5973ff6c37f62817da2a5bf009b41f320cd5bc6fe2269abc6108e3536b5a7e37ee84225cb80871d1b6be254745c9ed79d752f7c85f9bc0c4b1
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,9 +27,8 @@ 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
- 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'
30
+ get '/signup', _controller: 'user-templates', _action: 'signup'
31
+ get '/login', _controller: 'user-templates', _action: 'login'
33
32
  ```
34
33
 
35
34
  Now you can link to /signup and /login
@@ -39,7 +38,7 @@ Now you can link to /signup and /login
39
38
  ### Login
40
39
 
41
40
  ```html
42
- <:user_templates:login post-login-url="/" />
41
+ <:user-templates:login post-login-url="/" />
43
42
  ```
44
43
 
45
44
  The login template takes an optional post-login-url that will be redirected to after a successful login.
@@ -47,21 +46,15 @@ The login template takes an optional post-login-url that will be redirected to a
47
46
  ### Signup
48
47
 
49
48
  ```html
50
- <:user_templates:signup post-signup-url="/" />
49
+ <:user-templates:signup post-signup-url="/" />
51
50
  ```
52
51
 
53
52
  Signup takes an optional post-signup-url that will be redirected to after signup.
54
53
 
55
- ### Forgot
56
-
57
- ```html
58
- <:user_templates:login:forgot post-forgot-url="/login" />
59
- ```
60
-
61
54
  ### Logout
62
55
 
63
- volt-user_templates provides a nav bar tag that provides a login/logout link and shows the users name.
56
+ volt-user-templates provides a nav bar tag that provides a login/logout link and shows the users name.
64
57
 
65
58
  ```html
66
- <:user_templates:menu />
59
+ <:user-templates:menu />
67
60
  ```
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -0,0 +1,28 @@
1
+ module UserTemplates
2
+ class LoginController < Volt::ModelController
3
+ reactive_accessor :errors
4
+ reactive_accessor :login
5
+ reactive_accessor :password
6
+
7
+ def do_login
8
+ Volt.login(login, password).then do
9
+ # Successful login, clear out the form
10
+ self.errors = nil
11
+ self.login = ''
12
+ self.password = ''
13
+
14
+ go(attrs.post_login_url.or('/'))
15
+
16
+ nil
17
+ end.fail do |errors|
18
+ # Login fail
19
+ self.errors = errors
20
+ end
21
+ end
22
+
23
+ def use_username?
24
+ Volt.config.public.try(:auth).try(:use_username)
25
+ end
26
+
27
+ end
28
+ end
@@ -2,12 +2,8 @@ module UserTemplates
2
2
  class MenuController < Volt::ModelController
3
3
  def show_name
4
4
  Volt.fetch_current_user.then do |user|
5
- user._name || user._email || user._username
5
+ user._name.or(user._email).or(user._username)
6
6
  end
7
7
  end
8
-
9
- def is_active?
10
- url.path.split('/')[1] == 'login'
11
- end
12
8
  end
13
9
  end
@@ -12,9 +12,12 @@ module UserTemplates
12
12
  save!.then do |result|
13
13
  flash._notices << "Signup successful"
14
14
 
15
+ post_signup_url = attrs.post_signup_url.or('/')
16
+
15
17
  # On a successful signup, then login
16
18
  Volt.login(login, password).then do
17
- after_signup
19
+ # Redirect to post signup url
20
+ go post_signup_url
18
21
  end.fail do |errors|
19
22
  # Show the error (probably only the server goes down)
20
23
  flash._errors << errors.to_s
@@ -24,13 +27,6 @@ module UserTemplates
24
27
  end
25
28
  end
26
29
 
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
-
34
30
  def use_username?
35
31
  Volt.config.public.try(:auth).try(:use_username)
36
32
  end
@@ -20,11 +20,11 @@
20
20
  Email
21
21
  {{ end }}
22
22
  </label>
23
- <input class="form-control" type="text" value="{{ login }}" autofocus />
23
+ <input class="form-control" type="text" value="{{ login }}">
24
24
  </div>
25
25
 
26
26
  <div class="form-group">
27
- <label class="control-label">Password <small style="font-weight: normal;">(<a tabindex="-1" href="{{ forgot_url }}">forgot password</a>)</small></label>
27
+ <label class="control-label">Password</label>
28
28
  <input class="form-control" type="password" value="{{ password }}">
29
29
  </div>
30
30
 
@@ -16,7 +16,7 @@
16
16
  </ul>
17
17
  </li>
18
18
  {{ else }}
19
- <li class="{{ if is_active? }}active{{ end }}">
19
+ <li>
20
20
  <a href="/login">
21
21
  <span class="glyphicon glyphicon-user"></span>
22
22
  Login
@@ -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 = ["ryan@agileproductions.com"]
12
+ spec.email = ["ryanstout@gmail.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"
@@ -19,7 +19,6 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency "volt-fields", "~> 0.1.0"
23
- spec.add_dependency "volt-mailer", "~> 0.1.0"
22
+ spec.add_dependency "volt-fields", "~> 0.0.11"
24
23
  spec.add_development_dependency "rake"
25
24
  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.0
4
+ version: 0.1.1
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-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: volt-fields
@@ -16,28 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.0
19
+ version: 0.0.11
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
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.1.0
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 0.1.0
26
+ version: 0.0.11
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rake
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -54,7 +40,7 @@ dependencies:
54
40
  version: '0'
55
41
  description:
56
42
  email:
57
- - ryan@agileproductions.com
43
+ - ryanstout@gmail.com
58
44
  executables: []
59
45
  extensions: []
60
46
  extra_rdoc_files: []
@@ -64,19 +50,14 @@ files:
64
50
  - README.md
65
51
  - Rakefile
66
52
  - VERSION
67
- - app/user_templates/config/dependencies.rb
68
- - app/user_templates/config/routes.rb
69
- - app/user_templates/controllers/account_controller.rb
70
- - app/user_templates/controllers/login_controller.rb
71
- - app/user_templates/controllers/menu_controller.rb
72
- - app/user_templates/controllers/signup_controller.rb
73
- - app/user_templates/tasks/user_template_tasks.rb
74
- - app/user_templates/views/account/index.html
75
- - app/user_templates/views/login/forgot.html
76
- - app/user_templates/views/login/index.html
77
- - app/user_templates/views/mailers/forgot.email
78
- - app/user_templates/views/menu/index.html
79
- - app/user_templates/views/signup/index.html
53
+ - app/user-templates/config/dependencies.rb
54
+ - app/user-templates/config/routes.rb
55
+ - app/user-templates/controllers/login_controller.rb
56
+ - app/user-templates/controllers/menu_controller.rb
57
+ - app/user-templates/controllers/signup_controller.rb
58
+ - app/user-templates/views/login/index.html
59
+ - app/user-templates/views/menu/index.html
60
+ - app/user-templates/views/signup/index.html
80
61
  - lib/volt/user-templates.rb
81
62
  - volt-user_templates.gemspec
82
63
  homepage: ''
@@ -99,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
80
  version: '0'
100
81
  requirements: []
101
82
  rubyforge_project:
102
- rubygems_version: 2.4.5
83
+ rubygems_version: 2.2.2
103
84
  signing_key:
104
85
  specification_version: 4
105
86
  summary: Volt user templates provide out of the box templates for users to signup,
@@ -1,16 +0,0 @@
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
@@ -1,47 +0,0 @@
1
- module UserTemplates
2
- class LoginController < Volt::ModelController
3
- reactive_accessor :errors
4
- reactive_accessor :login
5
- reactive_accessor :password
6
- reactive_accessor :reset_email
7
-
8
- def do_login
9
- Volt.login(login, password).then do |res|
10
- # Successful login, clear out the form
11
- self.errors = nil
12
- self.login = ''
13
- self.password = ''
14
-
15
- after_login
16
-
17
- nil
18
- end.fail do |errors|
19
- # Login fail
20
- self.errors = errors
21
- end
22
- end
23
-
24
- def after_login
25
- redirect_to(attrs.post_login_url || '/')
26
- end
27
-
28
- def forgot_url
29
- url_for(component: 'user_templates', controller: 'login', action: 'forgot')
30
- end
31
-
32
- def send_reset_email
33
- UserTemplateTasks.send_reset_email(reset_email).then do
34
- self.reset_email = ''
35
- flash._notices << 'Reset email sent.'
36
- redirect_to(attrs.post_forgot_url || '/login')
37
- end.fail do |err|
38
- flash._errors << err.to_s
39
- end
40
- end
41
-
42
- def use_username?
43
- Volt.config.public.try(:auth).try(:use_username)
44
- end
45
-
46
- end
47
- end
@@ -1,26 +0,0 @@
1
- require 'digest'
2
-
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
- def send_reset_email(email)
9
- # Find user by e-mail
10
- Volt.skip_permissions do
11
- store._users.where(email: email).fetch_first do |user|
12
- if user
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
- )
20
- else
21
- raise "There is no account with the e-mail of #{email}."
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,26 +0,0 @@
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>
@@ -1,21 +0,0 @@
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>
@@ -1,41 +0,0 @@
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="{{ 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
- </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
- {{ reset_url }}