tkh_authentication 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
 
4
4
 
5
+ ## 0.1.3
6
+
7
+ * Added login module partial to embed in pages and set it up with bootstrap tabs
8
+ * Refactored login and signup forms
9
+ * A logged-in user cannot got to login or signup page. They are redirected to the root page.
10
+ * The two reset password views have now headings and one explanation. More friendly and it makes it clear that it can be used to change one's password even without having forgotten it.
11
+
12
+
5
13
  ## 0.1.2
6
14
 
7
15
  * Minor translation fix
@@ -1,10 +1,12 @@
1
1
  class SessionsController < ApplicationController
2
2
 
3
3
  def new
4
+ redirect_to root_path if current_user
4
5
  end
5
6
 
6
7
  def create
7
8
  user = User.find_by_email(params[:email])
9
+ set_target_page
8
10
  if user && user.authenticate(params[:password])
9
11
  if params[:remember_me]
10
12
  cookies.permanent[:auth_token] = user.auth_token
@@ -23,5 +25,11 @@ class SessionsController < ApplicationController
23
25
  cookies.delete(:auth_token)
24
26
  redirect_to safe_root_url, notice: t('authentication.logout_confirmation')
25
27
  end
28
+
29
+ private
30
+
31
+ def set_target_page
32
+ session[:target_page] = request.referer unless session[:target_page] # && !request.referer.nil?
33
+ end
26
34
 
27
35
  end
@@ -14,8 +14,9 @@ class UsersController < ApplicationController
14
14
 
15
15
  def create
16
16
  @user = User.new(params[:user])
17
+ set_target_page
17
18
  if @user.save
18
- cookies[:auth_token] = @user.auth_token
19
+ cookies[:auth_token] = @user.auth_token # logging in the user
19
20
  redirect_to session[:target_page] || safe_root_url, notice: t('authentication.signup_confirmation')
20
21
  session[:target_page] = nil
21
22
  else
@@ -37,4 +38,10 @@ class UsersController < ApplicationController
37
38
  redirect_to users_path, notice: t('authentication.admin_disabled_confirmation')
38
39
  end
39
40
 
41
+ private
42
+
43
+ def set_target_page
44
+ session[:target_page] = request.referer unless session[:target_page] # && !request.referer.nil?
45
+ end
46
+
40
47
  end
data/app/models/user.rb CHANGED
@@ -2,7 +2,9 @@ class User < ActiveRecord::Base
2
2
 
3
3
  has_secure_password
4
4
 
5
+ # associations connected to tkh_content gem. Any page or comment model will do
5
6
  has_many :pages
7
+ has_many :comments, :dependent => :destroy
6
8
 
7
9
  # not allowed are :admin:boolean, :auth_token:string, password_reset_token:string, password_reset_sent_at:datetime
8
10
  attr_accessible :email, :password, :password_confirmation, :first_name, :last_name
@@ -1,3 +1,5 @@
1
+ <h1>Create a new Password</h1>
2
+
1
3
  <%= simple_form_for @user, :url => password_reset_path(params[:id]) do |f| %>
2
4
  <%= f.error_notification %>
3
5
 
@@ -6,5 +8,4 @@
6
8
  <%= f.input :password_confirmation %>
7
9
  </div>
8
10
  <div class="actions"><%= f.submit t('authentication.update_password') %></div>
9
- <% end %>
10
-
11
+ <% end %>
@@ -1,3 +1,7 @@
1
+ <h1>Request a new Password</h1>
2
+
3
+ <p>Whether you forgot your password or you just want to change it, please give us your email address. We will send you an email with instructions on how to complete the two-click, 30 second process.</p>
4
+
1
5
  <%= form_tag password_resets_path, :method => :post do %>
2
6
  <div class="field">
3
7
  <%= label_tag :email %>
@@ -0,0 +1,33 @@
1
+ <%= form_tag sessions_path, class: 'simple_form form-horizontal' do %>
2
+
3
+ <div class="form-inputs">
4
+
5
+ <div class="control-group email required">
6
+ <%= label_tag :email, t('activerecord.attributes.user.email'), class: "email required control-label" %>
7
+ <div class="controls">
8
+ <%= text_field_tag :email, params[:email], :html => { class: 'string email required' } %>
9
+ <p class="help-block"><%= link_to t('authentication.not_registered'), signup_path %></p>
10
+ </div>
11
+ </div>
12
+
13
+ <div class="control-group password required">
14
+ <%= label_tag :password, t('activerecord.attributes.user.password'), class: "password required control-label" %>
15
+ <div class="controls">
16
+ <%= password_field_tag :password %>
17
+ <p class="help-block"><%= link_to t('authentication.forgot_password'), new_password_reset_path %></p>
18
+ </div>
19
+ </div>
20
+
21
+ <div class="control-group boolean optional">
22
+ <div class="controls">
23
+ <label class="checkbox"><input class="boolean optional" id="remember_me" name="remember_me" type="checkbox" value="1" /><%= t('authentication.remember_me') %></label>
24
+ </div>
25
+ </div>
26
+
27
+ </div>
28
+
29
+ <div class="form-actions">
30
+ <%= submit_tag t('authentication.login_now'), class: 'btn btn-primary' %>
31
+ </div>
32
+
33
+ <% end %>
@@ -1,38 +1,6 @@
1
1
  <h1><%= t('authentication.login_now') %></h1>
2
2
 
3
- <%= form_tag sessions_path, class: 'simple_form form-horizontal' do %>
4
-
5
- <div class="form-inputs">
6
-
7
- <div class="control-group email required">
8
- <%= label_tag :email, t('activerecord.attributes.user.email'), class: "email required control-label" %>
9
- <div class="controls">
10
- <%= text_field_tag :email, params[:email], :html => { class: 'string email required' } %>
11
- <p class="help-block"><%= link_to t('authentication.not_registered'), signup_path %></p>
12
- </div>
13
- </div>
14
-
15
- <div class="control-group password required">
16
- <%= label_tag :password, t('activerecord.attributes.user.password'), class: "password required control-label" %>
17
- <div class="controls">
18
- <%= password_field_tag :password %>
19
- <p class="help-block"><%= link_to t('authentication.forgot_password'), new_password_reset_path %></p>
20
- </div>
21
- </div>
22
-
23
- <div class="control-group boolean optional">
24
- <div class="controls">
25
- <label class="checkbox"><input class="boolean optional" id="remember_me" name="remember_me" type="checkbox" value="1" /><%= t('authentication.remember_me') %></label>
26
- </div>
27
- </div>
28
-
29
- </div>
30
-
31
- <div class="form-actions">
32
- <%= submit_tag t('authentication.login_now'), class: 'btn btn-primary' %>
33
- </div>
34
-
35
- <% end %>
3
+ <%= render 'form' %>
36
4
 
37
5
  <%# partial in tkh_menus gem or has to be added in host app %>
38
6
  <%= render './shared/menus' %>
@@ -0,0 +1,13 @@
1
+ <ul class="nav nav-tabs" id="loginTab">
2
+ <li class="active"><a href="#login-tab" data-toggle="tab">login</a></li>
3
+ <li><a href="#signup-tab" data-toggle="tab">create account</a></li>
4
+ </ul>
5
+
6
+ <div class="tab-content">
7
+ <div class="tab-pane active" id="login-tab">
8
+ <%= render 'sessions/form' %>
9
+ </div>
10
+ <div class="tab-pane" id="signup-tab">
11
+ <%= render 'users/form', user: User.new %>
12
+ </div>
13
+ </div>
@@ -0,0 +1,15 @@
1
+ <%= simple_form_for user, :html => { class: 'form-horizontal' } do |f| %>
2
+ <%= f.error_notification %>
3
+
4
+ <div class="form-inputs">
5
+ <%= f.input :email %>
6
+ <%= f.input :first_name %>
7
+ <%= f.input :last_name %>
8
+ <%= f.input :password %>
9
+ <%= f.input :password_confirmation, required: true %>
10
+ </div>
11
+
12
+ <div class="form-actions">
13
+ <%= f.button :submit, t('authentication.create_account'), :class => 'btn btn-primary' %>
14
+ </div>
15
+ <% end %>
@@ -1,20 +1,6 @@
1
1
  <h1><%= t('authentication.create_account') %></h1>
2
2
 
3
- <%= simple_form_for @user, :html => { class: 'form-horizontal' } do |f| %>
4
- <%= f.error_notification %>
5
-
6
- <div class="form-inputs">
7
- <%= f.input :email %>
8
- <%= f.input :first_name %>
9
- <%= f.input :last_name %>
10
- <%= f.input :password %>
11
- <%= f.input :password_confirmation, required: true %>
12
- </div>
13
-
14
- <div class="form-actions">
15
- <%= f.button :submit, t('authentication.create_account'), :class => 'btn btn-primary' %>
16
- </div>
17
- <% end %>
3
+ <%= render 'form', user: @user %>
18
4
 
19
5
  <%# partial in tkh_menus gem or has to be added in host app %>
20
6
  <%= render './shared/menus' %>
@@ -1,3 +1,3 @@
1
1
  module TkhAuthentication
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tkh_authentication
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-27 00:00:00.000000000 Z
12
+ date: 2013-01-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -106,10 +106,13 @@ files:
106
106
  - app/models/user.rb
107
107
  - app/views/password_resets/edit.html.erb
108
108
  - app/views/password_resets/new.html.erb
109
+ - app/views/sessions/_form.html.erb
109
110
  - app/views/sessions/new.html.erb
111
+ - app/views/shared/_embedded_login_module.html.erb
110
112
  - app/views/shared/_login_info.html.erb
111
113
  - app/views/shared/_login_info_for_sidebar.html.erb
112
114
  - app/views/user_mailer/password_reset.text.erb
115
+ - app/views/users/_form.html.erb
113
116
  - app/views/users/index.html.erb
114
117
  - app/views/users/new.html.erb
115
118
  - config/routes.rb
@@ -173,7 +176,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
173
176
  version: '0'
174
177
  segments:
175
178
  - 0
176
- hash: 3853324972041632603
179
+ hash: -4266320656794431571
177
180
  required_rubygems_version: !ruby/object:Gem::Requirement
178
181
  none: false
179
182
  requirements:
@@ -182,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
185
  version: '0'
183
186
  segments:
184
187
  - 0
185
- hash: 3853324972041632603
188
+ hash: -4266320656794431571
186
189
  requirements: []
187
190
  rubyforge_project:
188
191
  rubygems_version: 1.8.23