tb_core 1.2.7 → 1.2.8

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: 1b7fb2a20414e7e1f3c6231fc0d87d8884c770e0
4
- data.tar.gz: 7abfcd98b5851a0d15b8a46b189c24e01e69f1b4
3
+ metadata.gz: 739d972307395196f258e7586655f5d3e4dc05f4
4
+ data.tar.gz: 4c96571597213dd796a09b8b7a2616a6987e69ee
5
5
  SHA512:
6
- metadata.gz: 5b0a3a31e3129b89d02ea0b6b028f12fd2ad9d37f4a9bccebc9ffd19afc8db1d0ea81d403007875efea708912840727c5005a4b407356897780297b998e299f0
7
- data.tar.gz: 2f49b1ae926d600e560287de6187bbf23c15e613af3c51bb7627ad564aa1caecc6a603e3ff542ef91a03856f49d0b9d83974bfdd3707efa78a5320b8f6518a70
6
+ metadata.gz: 1de99edf127c590639325dbf5b3241b329b2d5ec211eaff041e590db6a318707a297efa4909aa3354faca84a878ac1d84134dfc01d07d039c780e9ca0a4647a7
7
+ data.tar.gz: fde33ac415dd3fe5701d098a48f91a9f16191f3b82708776e923986c857e754efa02a18012537338020c3643403ad860785319b54f195c2e12c4b85833c76907
@@ -30,7 +30,7 @@ class Admin::PasswordResetsController < Admin::ApplicationController
30
30
  @user.password = params[:spud_user][:password]
31
31
  @user.password_confirmation = params[:spud_user][:password_confirmation]
32
32
  if @user.save
33
- SpudUserSession.create(:login => @user.login, :password => params[:spud_user][:password])
33
+ SpudUserSession.create(@user)
34
34
  flash[:notice] = "Password successfully updated"
35
35
  redirect_to admin_login_path
36
36
  else
@@ -16,7 +16,7 @@ class Admin::SettingsController < Admin::ApplicationController
16
16
  def update
17
17
  if @current_user.update_attributes(user_params)
18
18
  if user_params.include?(:password)
19
- SpudUserSession.create(:login => @current_user.login, :password => user_params[:password])
19
+ SpudUserSession.create(@current_user)
20
20
  end
21
21
  flash[:notice] = "User settings saved successfully."
22
22
  respond_with @current_user, :location => admin_settings_path
@@ -15,7 +15,7 @@ class Admin::SetupController < Admin::ApplicationController
15
15
  @spud_user = SpudUser.new(user_params)
16
16
  @spud_user.super_admin = true
17
17
  if @spud_user.save
18
- SpudUserSession.create(:login => @spud_user.login, :password => user_params[:password])
18
+ SpudUserSession.create(@spud_user)
19
19
  redirect_to admin_root_path
20
20
  else
21
21
  render 'new', :status => 422
@@ -25,7 +25,7 @@ class Admin::SetupController < Admin::ApplicationController
25
25
  private
26
26
 
27
27
  def user_params
28
- params.require(:spud_user).permit(:login, :email, :password, :password_confirmation)
28
+ params.require(:spud_user).permit(:login, :email, :password, :password_confirmation, :first_name, :last_name)
29
29
  end
30
30
 
31
31
  end
@@ -32,7 +32,7 @@ class PasswordResetsController < ApplicationController
32
32
  @user.password = params[:spud_user][:password]
33
33
  @user.password_confirmation = params[:spud_user][:password_confirmation]
34
34
  if @user.save()
35
- SpudUserSession.create(:login => @user.login, :password => params[:spud_user][:password])
35
+ SpudUserSession.create(@user)
36
36
  flash[:notice] = "Password successfully updated"
37
37
  redirect_back_or_default(root_path)
38
38
  return
@@ -13,7 +13,7 @@ class Spud::ApplicationController < ActionController::Base
13
13
  before_action :set_mailer_default_url
14
14
 
15
15
  rescue_from Spud::RequestError, :with => :handle_request_error
16
- rescue_from ActionController::UnknownFormat, :with => :handle_unknown_format_error
16
+ rescue_from ActionController::UnknownFormat, ActionView::MissingTemplate, :with => :handle_unknown_format_error
17
17
 
18
18
  def not_found
19
19
  raise Spud::NotFoundError
@@ -72,9 +72,13 @@ private
72
72
  end
73
73
 
74
74
  def back_or_default(default)
75
- result = !session[:return_to].blank? ? session[:return_to] : default
76
- session[:return_to] = nil
77
- return result
75
+ if params[:return_to]
76
+ return params[:return_to]
77
+ elsif session[:return_to]
78
+ return session[:return_to]
79
+ else
80
+ return default
81
+ end
78
82
  end
79
83
 
80
84
  def set_time_zone
@@ -111,13 +115,10 @@ private
111
115
  end
112
116
 
113
117
  def handle_unknown_format_error(error)
114
- error = Spud::NotFoundError.new()
115
- handle_request_error(error)
116
- end
117
-
118
- def handle_routing_error(error)
119
- error = Spud::NotFoundError.new()
120
- handle_request_error(error)
118
+ if Rails.env.production?
119
+ error = Spud::NotFoundError.new()
120
+ handle_request_error(error)
121
+ end
121
122
  end
122
123
 
123
124
  end
@@ -11,7 +11,7 @@ class UserSessionsController < ApplicationController
11
11
  @user_session = SpudUserSession.new(params[:spud_user_session])
12
12
  if @user_session.save
13
13
  flash[:notice] = "Login successful!"
14
- redirect_back_or_default(root_path)
14
+ redirect_back_or_default('/')
15
15
  else
16
16
  render 'new'
17
17
  end
@@ -2,13 +2,17 @@ class Spud::SpudUserModel < ActiveRecord::Base
2
2
  self.table_name = 'spud_users'
3
3
 
4
4
  acts_as_authentic do |c|
5
- c.transition_from_crypto_providers = Authlogic::CryptoProviders::Sha512,
5
+ c.transition_from_crypto_providers = Authlogic::CryptoProviders::Sha512
6
6
  c.crypto_provider = Authlogic::CryptoProviders::SCrypt
7
7
  c.logged_in_timeout = 24.hours
8
+ if Spud::Core.config.use_email_as_login
9
+ c.login_field = :email
10
+ end
8
11
  end
9
12
 
10
13
  belongs_to :role, :class_name => 'SpudRole', :foreign_key => 'spud_role_id'
11
14
  has_many :spud_user_settings
15
+ before_validation :set_login_to_email, :if => ->{ Spud::Core.config.use_email_as_login }
12
16
 
13
17
  def full_name
14
18
  if first_name.blank? && last_name.blank?
@@ -94,4 +98,13 @@ class Spud::SpudUserModel < ActiveRecord::Base
94
98
  end
95
99
  end
96
100
 
101
+ private
102
+
103
+ def set_login_to_email
104
+ if self.email.present?
105
+ self.login = self.email
106
+ end
107
+ return true
108
+ end
109
+
97
110
  end
@@ -2,13 +2,15 @@
2
2
  <fieldset>
3
3
  <legend>User Details</legend>
4
4
 
5
- <div class="control-group">
6
- <%= f.label :login, :required => true, :class => "control-label" %>
7
- <div class="controls">
8
- <%= f.text_field :login, :size => 25, :autocomplete => 'username' %>
9
- </div>
10
-
11
- </div>
5
+ <% if !Spud::Core.config.use_email_as_login %>
6
+ <div class="control-group">
7
+ <%= f.label :login, :required => true, :class => "control-label" %>
8
+ <div class="controls">
9
+ <%= f.text_field :login, :size => 25, :autocomplete => 'username' %>
10
+ </div>
11
+ </div>
12
+ <% end %>
13
+
12
14
  <div class="control-group">
13
15
  <%=f.label :email,:class=>"control-label"%>
14
16
  <div class="controls">
@@ -8,16 +8,30 @@
8
8
  <%= error_messages_for f.object %>
9
9
  <fieldset>
10
10
  <legend>New Admin Account</legend>
11
+ <% if !Spud::Core.config.use_email_as_login %>
12
+ <div class="control-group">
13
+ <%= f.label :login, "Login", :class => "control-label" %>
14
+ <div class="controls">
15
+ <%= f.text_field :login %>
16
+ </div>
17
+ </div>
18
+ <% end %>
11
19
  <div class="control-group">
12
- <%= f.label :login, "Login", :class => "control-label" %>
20
+ <%= f.label :email, "Email", :class => "control-label" %>
13
21
  <div class="controls">
14
- <%= f.text_field :login %>
22
+ <%= f.text_field :email %>
15
23
  </div>
16
24
  </div>
17
25
  <div class="control-group">
18
- <%= f.label :email, "Email", :class => "control-label" %>
26
+ <%= f.label :first_name, :class => "control-label" %>
19
27
  <div class="controls">
20
- <%= f.text_field :email %>
28
+ <%= f.text_field :first_name %>
29
+ </div>
30
+ </div>
31
+ <div class="control-group">
32
+ <%= f.label :last_name, :class => "control-label" %>
33
+ <div class="controls">
34
+ <%= f.text_field :last_name %>
21
35
  </div>
22
36
  </div>
23
37
  <div class="control-group">
@@ -3,12 +3,17 @@
3
3
  <%= error_messages_for(f.object) %>
4
4
 
5
5
  <div class="login-form-row">
6
- <%= f.label :login %>
7
- <%= f.text_field :login, :autofocus => 'autofocus', :autocomplete => 'username' %>
6
+ <% if Spud::Core.config.use_email_as_login %>
7
+ <%= f.label :email %>
8
+ <%= f.text_field :email, :placeholder => 'Email', :autofocus => 'autofocus', :autocomplete => 'username' %>
9
+ <% else %>
10
+ <%= f.label :login %>
11
+ <%= f.text_field :login, :placeholder => 'Username', :autofocus => 'autofocus', :autocomplete => 'username' %>
12
+ <% end %>
8
13
  </div>
9
14
  <div class="login-form-row">
10
15
  <%= f.label :password %>
11
- <%= f.password_field :password, :autocomplete => 'current-password' %>
16
+ <%= f.password_field :password, :placeholder => 'Password', :autocomplete => 'current-password' %>
12
17
  </div>
13
18
  <div class="login-form-row">
14
19
  <%= f.submit "Login", :class => 'btn' %> or <%=link_to "Forgot Password?", admin_password_resets_path %>
@@ -3,14 +3,16 @@
3
3
  <fieldset>
4
4
  <legend>User Details</legend>
5
5
 
6
- <div class="control-group">
7
- <%=f.label :login, :required=>true,:class=> "control-label"%>
8
- <div class="controls">
9
- <%=f.text_field :login,:title => "",:size=>25%>
10
- <p class="help-block">This is the username used to login to the account.</p>
11
- </div>
12
-
13
- </div>
6
+ <% if !Spud::Core.config.use_email_as_login %>
7
+ <div class="control-group">
8
+ <%=f.label :login, :required=>true,:class=> "control-label"%>
9
+ <div class="controls">
10
+ <%=f.text_field :login,:title => "",:size=>25%>
11
+ <p class="help-block">This is the username used to login to the account.</p>
12
+ </div>
13
+ </div>
14
+ <% end %>
15
+
14
16
  <div class="control-group">
15
17
  <%=f.label :email,:class=> "control-label"%>
16
18
  <div class="controls">
@@ -12,8 +12,10 @@
12
12
  </div>
13
13
  <h2><%= @user.full_name %></h2>
14
14
  <dl>
15
- <dt>Login</dt>
16
- <dd><%= @user.login %></dd>
15
+ <% if !Spud::Core.config.use_email_as_login %>
16
+ <dt>Login</dt>
17
+ <dd><%= @user.login %></dd>
18
+ <% end %>
17
19
  <dt>Email</dt>
18
20
  <dd><%= mail_to @user.email %></dd>
19
21
  <dt>Last Login</dt>
@@ -4,6 +4,9 @@
4
4
  <h1>Password Reset</h1>
5
5
  <%= form_for @user, :url => password_reset_path(:id => @user.perishable_token), :html => {:class => 'password-reset-form'} do |f| %>
6
6
  <%= tb_form_errors(@user) %>
7
+ <% if params[:return_to] %>
8
+ <%= hidden_field_tag :return_to, params[:return_to] %>
9
+ <% end %>
7
10
  <div class="form-row">
8
11
  <%= f.label :password %>
9
12
  <%= f.password_field :password, :placeholder => 'password', :autofocus => 'autofocus' %>
@@ -4,13 +4,21 @@
4
4
 
5
5
  <%= form_for @user_session, :url => login_path, :html => {:class => 'login-form'} do |f| %>
6
6
  <%= tb_form_errors(@user_session) %>
7
+ <% if params[:return_to] %>
8
+ <%= hidden_field_tag :return_to, params[:return_to] %>
9
+ <% end %>
7
10
  <div class="form-row">
8
- <%= f.label :login %>
9
- <%= f.text_field :login, :placeholder => 'username', :autofocus => 'autofocus', :autocomplete => 'username' %>
11
+ <% if Spud::Core.config.use_email_as_login %>
12
+ <%= f.label :email %>
13
+ <%= f.text_field :email, :placeholder => 'Email', :autofocus => 'autofocus', :autocomplete => 'username' %>
14
+ <% else %>
15
+ <%= f.label :login %>
16
+ <%= f.text_field :login, :placeholder => 'Username', :autofocus => 'autofocus', :autocomplete => 'username' %>
17
+ <% end %>
10
18
  </div>
11
19
  <div class="form-row">
12
20
  <%= f.label :password %>
13
- <%= f.password_field :password, :placeholder => 'password', :autocomplete => 'current-password' %>
21
+ <%= f.password_field :password, :placeholder => 'Password', :autocomplete => 'current-password' %>
14
22
  </div>
15
23
  <div class="form-row">
16
24
  <%= f.submit "Login", :class => 'btn btn-primary' %> <span>or</span> <%=link_to "Forgot Password?", password_resets_path %>
@@ -1,7 +1,9 @@
1
1
  module Spud
2
2
  module Core
3
3
  include ActiveSupport::Configurable
4
- config_accessor :site_name,:admin_applications,:sitemap_urls,:multisite_mode_enabled,:multisite_config,:from_address,:site_id,:short_name, :javascripts,:stylesheets, :admin_javascripts, :admin_stylesheets, :permissions, :production_alert_domain
4
+ config_accessor :site_name, :admin_applications, :sitemap_urls, :multisite_mode_enabled, :multisite_config,
5
+ :from_address, :site_id, :short_name, :javascripts, :stylesheets, :admin_javascripts, :admin_stylesheets,
6
+ :permissions, :production_alert_domain, :use_email_as_login
5
7
  self.admin_applications = []
6
8
  self.site_name = "Company Name"
7
9
  self.site_id = 0
@@ -16,6 +18,7 @@ module Spud
16
18
  self.admin_javascripts = ['admin/core/application', 'admin/application']
17
19
  self.admin_stylesheets = ['admin/core/application', 'admin/application']
18
20
  self.production_alert_domain = nil
21
+ self.use_email_as_login = false
19
22
 
20
23
  def self.site_config_for_host(host)
21
24
  configs = Spud::Core.multisite_config.select{|p| p[:hosts].include?(host)}
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Core
3
- VERSION = "1.2.7"
3
+ VERSION = "1.2.8"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tb_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.7
4
+ version: 1.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Woods
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-09 00:00:00.000000000 Z
11
+ date: 2014-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails