tb_core 1.3.3 → 1.3.4
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 +4 -4
- data/README.md +10 -0
- data/app/assets/javascripts/admin/core/application.js +2 -1
- data/app/assets/javascripts/admin/core/modal.js +36 -6
- data/app/assets/javascripts/admin/core/users.js +121 -2
- data/app/assets/javascripts/tb_core/configuration.js.erb +1 -1
- data/app/assets/javascripts/tb_core/remote.js +9 -6
- data/app/assets/javascripts/tb_core/utility.js +11 -0
- data/app/assets/stylesheets/admin/core/application.scss +118 -117
- data/app/assets/stylesheets/admin/core/login.scss +15 -14
- data/app/assets/stylesheets/admin/core/users.scss +14 -0
- data/app/controllers/admin/application_controller.rb +4 -14
- data/app/controllers/admin/password_resets_controller.rb +1 -1
- data/app/controllers/admin/user_sessions_controller.rb +0 -27
- data/app/controllers/admin/users_controller.rb +37 -4
- data/app/controllers/password_resets_controller.rb +1 -1
- data/app/controllers/spud/application_controller.rb +37 -11
- data/app/controllers/user_sessions_controller.rb +46 -10
- data/app/helpers/admin/application_helper.rb +8 -1
- data/app/helpers/spud/application_helper.rb +36 -0
- data/app/helpers/tb_core/application_helper.rb +2 -2
- data/app/mailers/tb_core_mailer.rb +25 -0
- data/app/models/spud/spud_user_model.rb +14 -0
- data/app/views/admin/setup/new.html.erb +6 -14
- data/app/views/admin/user_sessions/new.html.erb +1 -25
- data/app/views/admin/users/_form.html.erb +25 -2
- data/app/views/layouts/admin/application.html.erb +2 -2
- data/app/views/layouts/admin/login.html.erb +2 -1
- data/app/views/layouts/mailer.html.erb +23 -0
- data/app/views/tb_core_mailer/forgot_password_notification.html.erb +12 -0
- data/app/views/tb_core_mailer/user_credentials.html.erb +19 -0
- data/app/views/user_sessions/_form.html.erb +24 -0
- data/app/views/user_sessions/change_password.html.erb +21 -0
- data/app/views/user_sessions/new.html.erb +1 -22
- data/config/locales/en.yml +12 -2
- data/config/routes.rb +5 -2
- data/db/migrate/20150610143438_add_requires_password_change_to_spud_users.rb +5 -0
- data/lib/generators/spud/setup_generator.rb +5 -0
- data/lib/generators/spud/templates/assets/application.js +1 -1
- data/lib/generators/spud/templates/assets/application.scss +2 -2
- data/lib/generators/spud/templates/assets/bootstrap.js +14 -0
- data/lib/spud_core/belongs_to_app.rb +1 -1
- data/lib/spud_core/engine.rb +1 -0
- data/lib/spud_core/errors.rb +8 -0
- data/lib/spud_core/version.rb +1 -1
- data/lib/tb_core/form_builder.rb +31 -6
- data/spec/controllers/admin/user_sessions_controller_spec.rb +0 -28
- data/spec/dummy/config/environments/development.rb +2 -2
- data/spec/dummy/db/migrate/20150610180845_add_requires_password_change_to_spud_users.tb_core.rb +6 -0
- data/spec/dummy/db/schema.rb +23 -22
- data/spec/models/spud_user_spec.rb +18 -2
- metadata +28 -20
- data/app/assets/libs/jquery-ui/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/app/assets/libs/jquery-ui/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/app/assets/libs/jquery-ui/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/app/assets/libs/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/app/assets/libs/jquery-ui/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/app/assets/libs/jquery-ui/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/app/assets/libs/jquery-ui/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/app/assets/libs/jquery-ui/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/app/assets/libs/jquery-ui/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/libs/jquery-ui/images/ui-icons_2e83ff_256x240.png +0 -0
- data/app/assets/libs/jquery-ui/images/ui-icons_454545_256x240.png +0 -0
- data/app/assets/libs/jquery-ui/images/ui-icons_888888_256x240.png +0 -0
- data/app/assets/libs/jquery-ui/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/app/assets/libs/jquery-ui/jquery-ui.js +0 -8952
- data/app/assets/libs/jquery-ui/jquery-ui.scss +0 -784
- data/app/mailers/core_mailer.rb +0 -9
- data/app/views/core_mailer/forgot_password_notification.html.erb +0 -14
- data/app/views/core_mailer/forgot_password_notification.text.erb +0 -10
@@ -12,36 +12,9 @@ class Admin::UserSessionsController < Admin::ApplicationController
|
|
12
12
|
end
|
13
13
|
@user_session = SpudUserSession.new
|
14
14
|
end
|
15
|
-
|
16
|
-
def create
|
17
|
-
@user_session = SpudUserSession.new(params[:spud_user_session])
|
18
|
-
if @user_session.save
|
19
|
-
flash[:notice] = "Login successful!"
|
20
|
-
redirect_to redirect_path_for_admin
|
21
|
-
else
|
22
|
-
render :action => :new
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def destroy
|
27
|
-
current_user_session.destroy unless current_user_session.blank?
|
28
|
-
flash[:notice] = "Logout successful!"
|
29
|
-
redirect_to admin_login_path
|
30
|
-
end
|
31
15
|
|
32
16
|
def legacy_redirect
|
33
17
|
redirect_to admin_login_path
|
34
18
|
end
|
35
19
|
|
36
|
-
private
|
37
|
-
|
38
|
-
def redirect_path_for_admin
|
39
|
-
back_or_default = back_or_default(admin_root_path)
|
40
|
-
if /\/admin\//.match(back_or_default)
|
41
|
-
return back_or_default
|
42
|
-
else
|
43
|
-
return admin_root_path
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
20
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
class Admin::UsersController < Admin::ApplicationController
|
2
2
|
|
3
|
+
self.responder = TbCore::Responder
|
3
4
|
belongs_to_spud_app :users
|
4
5
|
add_breadcrumb "Users", :admin_users_path
|
5
6
|
before_action :load_user, :only => [:edit, :update, :show, :destroy]
|
7
|
+
after_action :send_credentials_email, :only => [:create, :update]
|
6
8
|
respond_to :html
|
7
9
|
|
8
10
|
def index
|
@@ -19,7 +21,15 @@ class Admin::UsersController < Admin::ApplicationController
|
|
19
21
|
|
20
22
|
def new
|
21
23
|
@user = SpudUser.new
|
22
|
-
respond_with @user
|
24
|
+
respond_with @user do |format|
|
25
|
+
format.html{
|
26
|
+
if request.xhr?
|
27
|
+
render 'new', :layout => false
|
28
|
+
else
|
29
|
+
render 'new'
|
30
|
+
end
|
31
|
+
}
|
32
|
+
end
|
23
33
|
end
|
24
34
|
|
25
35
|
def create
|
@@ -28,17 +38,33 @@ class Admin::UsersController < Admin::ApplicationController
|
|
28
38
|
end
|
29
39
|
|
30
40
|
def edit
|
31
|
-
respond_with @user
|
41
|
+
respond_with @user do |format|
|
42
|
+
format.html{
|
43
|
+
if request.xhr?
|
44
|
+
render 'edit', :layout => false
|
45
|
+
else
|
46
|
+
render 'edit'
|
47
|
+
end
|
48
|
+
}
|
49
|
+
end
|
32
50
|
end
|
33
51
|
|
34
52
|
def update
|
35
|
-
@user.update_attributes(user_params)
|
53
|
+
if @user.update_attributes(user_params)
|
54
|
+
if @user == current_user && user_params[:password].present?
|
55
|
+
SpudUserSession.create(@user)
|
56
|
+
end
|
57
|
+
end
|
36
58
|
respond_with @user, :location => admin_user_path(@user), :status => 200
|
37
59
|
end
|
38
60
|
|
39
61
|
def destroy
|
40
62
|
@user.destroy
|
41
|
-
respond_with @user, :location => admin_users_path
|
63
|
+
respond_with @user, :location => admin_users_path do |format|
|
64
|
+
format.js{
|
65
|
+
render :nothing => true, :status => 200
|
66
|
+
}
|
67
|
+
end
|
42
68
|
end
|
43
69
|
|
44
70
|
private
|
@@ -56,4 +82,11 @@ private
|
|
56
82
|
params.require(:spud_user).permit!
|
57
83
|
end
|
58
84
|
|
85
|
+
def send_credentials_email
|
86
|
+
if params[:send_email] && user_params[:password] && !@user.errors.any?
|
87
|
+
TbCoreMailer.user_credentials(@user, user_params[:password]).deliver_later
|
88
|
+
end
|
89
|
+
return true
|
90
|
+
end
|
91
|
+
|
59
92
|
end
|
@@ -13,7 +13,7 @@ class PasswordResetsController < ApplicationController
|
|
13
13
|
@user = SpudUser.find_by_email(params[:email])
|
14
14
|
if @user
|
15
15
|
@user.reset_perishable_token!
|
16
|
-
|
16
|
+
TbCoreMailer.forgot_password_notification(@user, password_reset_url(@user.perishable_token)).deliver_later
|
17
17
|
flash[:notice] = "Password reset instructions have been sent to your email"
|
18
18
|
redirect_to login_path
|
19
19
|
else
|
@@ -3,8 +3,9 @@ class Spud::ApplicationController < ActionController::Base
|
|
3
3
|
ActiveSupport.run_load_hooks(:spud_application_controller, self)
|
4
4
|
|
5
5
|
protect_from_forgery
|
6
|
-
helper_method :current_user_session, :current_user, :current_user_id
|
7
|
-
|
6
|
+
helper_method :current_user_session, :current_user, :current_user_id, :back_or_default
|
7
|
+
before_action :check_requires_password_change
|
8
|
+
around_action :set_time_zone
|
8
9
|
|
9
10
|
include TbCore::ApplicationHelper
|
10
11
|
before_action :set_mailer_default_url
|
@@ -43,19 +44,22 @@ private
|
|
43
44
|
|
44
45
|
def require_user
|
45
46
|
unless current_user
|
46
|
-
|
47
|
-
format.html{ redirect_to login_path(:return_to => request.path) }
|
48
|
-
format.json{ raise Spud::AccessDeniedError.new() }
|
49
|
-
end
|
50
|
-
return false
|
47
|
+
raise Spud::UnauthorizedError.new()
|
51
48
|
end
|
52
49
|
return true
|
53
50
|
end
|
54
51
|
|
52
|
+
# Override this in a controller to redifine where the login form is
|
53
|
+
#
|
54
|
+
def login_path_for_require_user
|
55
|
+
login_path(:return_to => request.path)
|
56
|
+
end
|
57
|
+
|
55
58
|
def require_admin_user
|
56
|
-
if current_user.blank?
|
59
|
+
if current_user.blank?
|
60
|
+
raise Spud::UnauthorizedError.new()
|
61
|
+
elsif !current_user.has_admin_rights?
|
57
62
|
raise Spud::AccessDeniedError.new()
|
58
|
-
return false
|
59
63
|
end
|
60
64
|
end
|
61
65
|
|
@@ -63,12 +67,19 @@ private
|
|
63
67
|
redirect_to(back_or_default(default))
|
64
68
|
end
|
65
69
|
|
66
|
-
def back_or_default(default)
|
70
|
+
def back_or_default(default='/')
|
67
71
|
if params[:return_to]
|
68
72
|
uri = URI.parse(params[:return_to].to_s)
|
69
73
|
return uri.path
|
70
74
|
else
|
71
|
-
return default
|
75
|
+
return default
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def check_requires_password_change
|
80
|
+
if current_user.present? && current_user.requires_password_change?
|
81
|
+
redirect_to(login_change_password_path(:return_to => request.path))
|
82
|
+
return false
|
72
83
|
end
|
73
84
|
end
|
74
85
|
|
@@ -82,6 +93,17 @@ private
|
|
82
93
|
|
83
94
|
def handle_request_error(error)
|
84
95
|
error.request_url = request.original_url
|
96
|
+
error.template = template_for_request_error() if respond_to?(:template_for_request_error, true)
|
97
|
+
|
98
|
+
if error.is_a?(Spud::UnauthorizedError)
|
99
|
+
if should_present_basic_auth?
|
100
|
+
headers["WWW-Authenticate"] = "Basic realm=\"#{Spud::Core.config.site_name}\""
|
101
|
+
elsif request.format.html?
|
102
|
+
redirect_to(login_path_for_require_user)
|
103
|
+
return false
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
85
107
|
respond_to do |format|
|
86
108
|
format.json{ render :json => {:errors => error.message}, :status => error.code }
|
87
109
|
format.xml{ render :xml => {:errors => error.message}, :status => error.code }
|
@@ -92,6 +114,10 @@ private
|
|
92
114
|
end
|
93
115
|
end
|
94
116
|
|
117
|
+
def should_present_basic_auth?
|
118
|
+
return request.headers['X-TWICE-BAKED-BASIC-AUTH'].present?
|
119
|
+
end
|
120
|
+
|
95
121
|
def handle_record_not_found(error)
|
96
122
|
error = Spud::NotFoundError.new('record')
|
97
123
|
handle_request_error(error)
|
@@ -1,27 +1,63 @@
|
|
1
|
-
class UserSessionsController < ApplicationController
|
1
|
+
class UserSessionsController < ApplicationController
|
2
2
|
|
3
|
-
skip_before_action :require_user
|
4
|
-
|
3
|
+
skip_before_action :require_user, :only => [:new, :create, :destroy]
|
4
|
+
skip_before_action :check_requires_password_change, :only => [:destroy, :change_password, :set_change_password]
|
5
|
+
|
6
|
+
respond_to :html, :json, :js
|
7
|
+
self.responder = TbCore::Responder
|
5
8
|
layout 'user_sessions'
|
6
9
|
|
7
10
|
def new
|
8
11
|
@user_session = SpudUserSession.new
|
12
|
+
render 'new'
|
9
13
|
end
|
10
14
|
|
11
15
|
def create
|
12
16
|
@user_session = SpudUserSession.new(params[:spud_user_session])
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
17
|
+
logged_in = @user_session.save()
|
18
|
+
respond_with @user_session do |format|
|
19
|
+
format.html{
|
20
|
+
if logged_in
|
21
|
+
flash[:notice] = "Login successful!"
|
22
|
+
redirect_back_or_default('/')
|
23
|
+
else
|
24
|
+
render 'new'
|
25
|
+
end
|
26
|
+
}
|
18
27
|
end
|
19
28
|
end
|
20
29
|
|
21
30
|
def destroy
|
22
31
|
current_user_session.destroy unless current_user_session.blank?
|
23
|
-
|
24
|
-
|
32
|
+
respond_with({}) do |format|
|
33
|
+
format.html{
|
34
|
+
flash[:notice] = "Logout successful!"
|
35
|
+
redirect_back_or_default(login_path)
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def change_password
|
41
|
+
render 'change_password'
|
42
|
+
end
|
43
|
+
|
44
|
+
def set_change_password
|
45
|
+
current_user.update_attributes(change_password_params)
|
46
|
+
respond_with current_user do |format|
|
47
|
+
format.html{
|
48
|
+
if current_user.errors.any?
|
49
|
+
render 'change_password'
|
50
|
+
else
|
51
|
+
redirect_back_or_default('/')
|
52
|
+
end
|
53
|
+
}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def change_password_params
|
60
|
+
params.require(:spud_user).permit(:password, :password_confirmation)
|
25
61
|
end
|
26
62
|
|
27
63
|
end
|
@@ -2,7 +2,14 @@ module Admin::ApplicationHelper
|
|
2
2
|
|
3
3
|
def timestamp(timedate=nil)
|
4
4
|
return "Never" if timedate.blank?
|
5
|
-
|
5
|
+
|
6
|
+
if Time.now() > timedate # in the past
|
7
|
+
return Time.now() - timedate > 604800 ? timedate.strftime("%B %d, %Y") + ' at ' + timedate.strftime("%I:%M %p") : time_ago_in_words(timedate) + ' ago'
|
8
|
+
elsif Time.now() < timedate # in the future
|
9
|
+
return timedate.strftime("%B %d, %Y") + ' at ' + timedate.strftime("%I:%M %p")
|
10
|
+
else
|
11
|
+
return "Right now"
|
12
|
+
end
|
6
13
|
end
|
7
14
|
|
8
15
|
def url_for_admin_dashboard_application(url)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Spud::ApplicationHelper
|
2
|
+
|
3
|
+
def tb_page_title
|
4
|
+
if content_for?(:title)
|
5
|
+
title = content_for(:title) + ' | ' + Spud::Core.site_name
|
6
|
+
elsif @page_title
|
7
|
+
title = @page_title + ' | ' + Spud::Core.site_name
|
8
|
+
else
|
9
|
+
title = Spud::Core.site_name
|
10
|
+
end
|
11
|
+
return content_tag :title, title
|
12
|
+
end
|
13
|
+
|
14
|
+
def current_site_name
|
15
|
+
return Spud::Core.config.site_name
|
16
|
+
end
|
17
|
+
|
18
|
+
def cache_key_for_spud_collection(collection, key:'view', cache_params:[], for_user:false)
|
19
|
+
cache_keys = [controller_name, action_name, key]
|
20
|
+
cache_keys << collection.collect(&:updated_at).max().try(:utc).try(:to_i)
|
21
|
+
if for_user
|
22
|
+
cache_keys << current_user_id
|
23
|
+
end
|
24
|
+
if cache_params.any?
|
25
|
+
cache_keys += cache_params.collect{ |cache_param| params[cache_param] || 'nil' }
|
26
|
+
end
|
27
|
+
cache_keys += collection.collect(&:id)
|
28
|
+
cache_key = cache_keys.join('/')
|
29
|
+
if cache_key.length > 250
|
30
|
+
return Digest::SHA1.hexdigest(cache_key)
|
31
|
+
else
|
32
|
+
return cache_key
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -54,9 +54,9 @@ module TbCore::ApplicationHelper
|
|
54
54
|
|
55
55
|
def tb_page_title
|
56
56
|
if content_for?(:title)
|
57
|
-
title = content_for(:title) + '
|
57
|
+
title = content_for(:title) + ' | ' + Spud::Core.site_name
|
58
58
|
elsif @page_title
|
59
|
-
title = @page_title + '
|
59
|
+
title = @page_title + ' | ' + Spud::Core.site_name
|
60
60
|
else
|
61
61
|
title = Spud::Core.site_name
|
62
62
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class TbCoreMailer < ActionMailer::Base
|
2
|
+
|
3
|
+
layout 'mailer'
|
4
|
+
|
5
|
+
def forgot_password_notification(user, url)
|
6
|
+
@user = user
|
7
|
+
@url = url
|
8
|
+
mail(:from =>Spud::Core.from_address, :to => to_address_for_user(user), :subject => default_i18n_subject(:site_name => Spud::Core.site_name))
|
9
|
+
end
|
10
|
+
|
11
|
+
def user_credentials(user, password)
|
12
|
+
@user = user
|
13
|
+
@password = password
|
14
|
+
mail(:from => Spud::Core.from_address, :to => to_address_for_user(user), :subject => default_i18n_subject(:site_name => Spud::Core.site_name))
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def to_address_for_user(user)
|
20
|
+
address = Mail::Address.new(user.email)
|
21
|
+
address.display_name = user.full_name
|
22
|
+
return address.format
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -13,7 +13,10 @@ class Spud::SpudUserModel < ActiveRecord::Base
|
|
13
13
|
|
14
14
|
belongs_to :role, :class_name => 'SpudRole', :foreign_key => 'spud_role_id'
|
15
15
|
has_many :spud_user_settings
|
16
|
+
|
17
|
+
validates :first_name, :last_name, :presence => true
|
16
18
|
before_validation :set_login_to_email, :if => ->{ Spud::Core.config.use_email_as_login }
|
19
|
+
before_update :unset_requires_password_change
|
17
20
|
|
18
21
|
scope :admins, ->{
|
19
22
|
where('super_admin = 1 OR role_id IS NOT NULL')
|
@@ -33,6 +36,10 @@ class Spud::SpudUserModel < ActiveRecord::Base
|
|
33
36
|
return "#{self.first_name} #{self.last_name}"
|
34
37
|
end
|
35
38
|
|
39
|
+
def full_name_with_email
|
40
|
+
return "#{full_name} (#{email})"
|
41
|
+
end
|
42
|
+
|
36
43
|
# Returns true if user can view at least one dashboard app
|
37
44
|
def has_admin_rights?
|
38
45
|
if self.super_admin?
|
@@ -114,4 +121,11 @@ private
|
|
114
121
|
return true
|
115
122
|
end
|
116
123
|
|
124
|
+
def unset_requires_password_change
|
125
|
+
if password_changed? && !requires_password_change_changed?(:to => true)
|
126
|
+
self.requires_password_change = false
|
127
|
+
end
|
128
|
+
return true
|
129
|
+
end
|
130
|
+
|
117
131
|
end
|
@@ -4,25 +4,17 @@
|
|
4
4
|
%>
|
5
5
|
|
6
6
|
<% content_for :detail do %>
|
7
|
-
<%
|
7
|
+
<% tb_form_for @spud_user, :url => admin_setup_path do |f| %>
|
8
8
|
<%= tb_form_errors f.object %>
|
9
9
|
|
10
10
|
<% if !Spud::Core.config.use_email_as_login %>
|
11
|
-
|
12
|
-
<%= f.label :login, "Login", :class => "col-sm-2 control-label" %>
|
13
|
-
<div class="col-sm-10">
|
14
|
-
<%= f.text_field :login, :class=>'form-control' %>
|
15
|
-
</div>
|
16
|
-
</div>
|
11
|
+
<%= f.tb_text_field :login %>
|
17
12
|
<% end %>
|
18
13
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
</div>
|
24
|
-
</div>
|
25
|
-
|
14
|
+
<%= f.tb_text_field :email %>
|
15
|
+
<%= f.tb_text_field :first_name %>
|
16
|
+
<%= f.tb_text_field :last_name %>
|
17
|
+
|
26
18
|
<div class="form-group">
|
27
19
|
<%= f.label :password, "Password", :class => "col-sm-2 control-label" %>
|
28
20
|
<div class="col-sm-10">
|
@@ -1,25 +1 @@
|
|
1
|
-
<%=
|
2
|
-
|
3
|
-
<%= tb_form_errors(f.object) %>
|
4
|
-
|
5
|
-
<% if params[:return_to] %>
|
6
|
-
<%= hidden_field_tag :return_to, params[:return_to] %>
|
7
|
-
<% end %>
|
8
|
-
<div class="form-group">
|
9
|
-
<% if Spud::Core.config.use_email_as_login %>
|
10
|
-
<%= f.label :email, :class => 'form-label' %>
|
11
|
-
<%= f.text_field :email, :placeholder => 'Email', :autofocus => 'autofocus', :autocomplete => 'username', :class => 'form-control' %>
|
12
|
-
<% else %>
|
13
|
-
<%= f.label :login, :class => 'form-label' %>
|
14
|
-
<%= f.text_field :login, :placeholder => 'Username', :autofocus => 'autofocus', :autocomplete => 'username', :class => 'form-control' %>
|
15
|
-
<% end %>
|
16
|
-
</div>
|
17
|
-
<div class="form-group">
|
18
|
-
<%= f.label :password, :class => 'form-label' %>
|
19
|
-
<%= f.password_field :password, :placeholder => 'Password', :autocomplete => 'current-password', :class => 'form-control' %>
|
20
|
-
</div>
|
21
|
-
<div class="form-group">
|
22
|
-
<%= f.submit "Login", :class => 'btn btn-primary' %> or <%=link_to "Forgot Password?", admin_password_resets_path %>
|
23
|
-
</div>
|
24
|
-
|
25
|
-
<% end %>
|
1
|
+
<%= render '/user_sessions/form', :return_to => admin_root_path, :password_resets_path => admin_password_resets_path %>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<%= tb_form_for @user, :url => path, :remote => true, :data => {:errors => :inline, :success => admin_users_path} do |f| %>
|
2
|
-
|
1
|
+
<%= tb_form_for @user, :url => path, :remote => true, :data => {:errors => :inline, :success => back_or_default(admin_users_path)}, :html => {:class => 'user-form'} do |f| %>
|
2
|
+
|
3
3
|
<%= tb_form_error_header(f.object) %>
|
4
4
|
|
5
5
|
<h4>User Details</h4>
|
@@ -19,6 +19,29 @@
|
|
19
19
|
<%= f.tb_password_field :password %>
|
20
20
|
<%= f.tb_password_field :password_confirmation %>
|
21
21
|
|
22
|
+
<div class="form-group">
|
23
|
+
<div class="col-sm-10 col-sm-offset-2">
|
24
|
+
<%= link_to 'Generate Password', '#', :class => 'btn btn-default btn-sm btn-generate-password' %>
|
25
|
+
<span class="generated-password text-success"></span>
|
26
|
+
</div>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<div class="form-group">
|
30
|
+
<%= f.tb_label :requires_password_change %>
|
31
|
+
<div class="col-sm-10">
|
32
|
+
<%= f.check_box :requires_password_change %>
|
33
|
+
<span class="text-muted">Require the user changes their password the next time they log in.</span>
|
34
|
+
</div>
|
35
|
+
</div>
|
36
|
+
|
37
|
+
<div class="form-group user-send-email-group">
|
38
|
+
<%= label_tag :send_email, 'Send email', :class => 'control-label col-sm-2' %>
|
39
|
+
<div class="col-sm-10">
|
40
|
+
<%= check_box_tag :send_email %>
|
41
|
+
<span class="text-muted">Send the user an email containing their password.</span>
|
42
|
+
</div>
|
43
|
+
</div>
|
44
|
+
|
22
45
|
<h4>Permissions</h4>
|
23
46
|
|
24
47
|
<%= f.tb_check_box :super_admin, :help_block => 'The super administrator bypasses all permissions and roles.' %>
|
@@ -24,7 +24,7 @@
|
|
24
24
|
<div class="pull-right">
|
25
25
|
Hello <%= current_user.full_name %> |
|
26
26
|
<%= link_to "Settings", admin_settings_path %> |
|
27
|
-
<%= link_to "Logout",
|
27
|
+
<%= link_to "Logout", logout_path(:return_to => admin_login_path) %>
|
28
28
|
</div>
|
29
29
|
<% end %>
|
30
30
|
</div>
|
@@ -46,7 +46,7 @@
|
|
46
46
|
<div class="modal-content">
|
47
47
|
<div class="modal-header">
|
48
48
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
49
|
-
<
|
49
|
+
<h3 class="modal-title"></h3>
|
50
50
|
</div>
|
51
51
|
<div class="modal-body">
|
52
52
|
<p>One fine body…</p>
|
@@ -3,6 +3,7 @@
|
|
3
3
|
<head>
|
4
4
|
<title><%= Spud::Core.config.site_name %> Admin: Login</title>
|
5
5
|
<%= stylesheet_link_tag 'admin/core/application' %>
|
6
|
+
<%= javascript_include_tag 'admin/core/application' %>
|
6
7
|
<%= csrf_meta_tags %>
|
7
8
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
8
9
|
<meta name="viewport" content="width=device-width"/>
|
@@ -10,7 +11,7 @@
|
|
10
11
|
<body>
|
11
12
|
|
12
13
|
<div class="container">
|
13
|
-
<div class="login-
|
14
|
+
<div class="login-container col-md-6 col-md-offset-3">
|
14
15
|
<h1><%= @login_title || 'Login' %></h1>
|
15
16
|
<%= yield %>
|
16
17
|
</div>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<style>
|
4
|
+
body{
|
5
|
+
font-family: "Helvetica Neue", sans-serif;
|
6
|
+
}
|
7
|
+
.container{
|
8
|
+
margin: 0 20px;
|
9
|
+
}
|
10
|
+
a{
|
11
|
+
color: #0088cc;
|
12
|
+
text-decoration: none;
|
13
|
+
}
|
14
|
+
a:hover{
|
15
|
+
text-decoration: underline;
|
16
|
+
}
|
17
|
+
</style>
|
18
|
+
<body>
|
19
|
+
<div class="container">
|
20
|
+
<%= yield %>
|
21
|
+
</div>
|
22
|
+
</body>
|
23
|
+
</html>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<h1>Hello <%= @user.full_name %>,</h1>
|
2
|
+
|
3
|
+
<p>A password reset has recently been requested for your user account on <strong><%= Spud::Core.config.site_name %></strong>. Please the link below to set your new password.</p>
|
4
|
+
|
5
|
+
<p><%= link_to @url, @url %></p>
|
6
|
+
|
7
|
+
<p>For reference, the username tied to your account is <strong><%= @user.login %></strong>. If you remember your password you can log in here: <%= link_to login_url, login_url %></p>
|
8
|
+
|
9
|
+
<p>
|
10
|
+
Thanks,<br/>
|
11
|
+
<strong><%= Spud::Core.config.site_name %></strong>
|
12
|
+
</p>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<h1>Hello <%= @user.full_name %>,</h1>
|
2
|
+
|
3
|
+
<p><%= t('tb_core_mailer.user_credentials.greeting', :site_name => Spud::Core.config.site_name) %></p>
|
4
|
+
|
5
|
+
<ul>
|
6
|
+
<li><strong>Username:</strong> <%= @user.login %></li>
|
7
|
+
<li><strong>Password:</strong> <%= @password %></li>
|
8
|
+
</ul>
|
9
|
+
|
10
|
+
<p><%= link_to 'Click here', login_url %> to log in.</p>
|
11
|
+
|
12
|
+
<% if @user.requires_password_change? %>
|
13
|
+
<p><strong>Note:</strong> You will be asked to create a new password after you log in.</p>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<p>
|
17
|
+
Thanks,<br/>
|
18
|
+
<strong><%= Spud::Core.config.site_name %></strong>
|
19
|
+
</p>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<% @user_session ||= SpudUserSession.new %>
|
2
|
+
<% return_to = '/' if local_assigns[:return_to].nil? %>
|
3
|
+
|
4
|
+
<%= form_for @user_session, :url => login_path, :html => {:class => 'login-form'}, :remote => true, :data => {:success => back_or_default(return_to), :errors => :inline} do |f| %>
|
5
|
+
<%= tb_form_errors(@user_session) %>
|
6
|
+
<%= hidden_field_tag :return_to, return_to %>
|
7
|
+
<div class="form-group">
|
8
|
+
<% if Spud::Core.config.use_email_as_login %>
|
9
|
+
<%= f.label :email %>
|
10
|
+
<%= f.text_field :email, :placeholder => 'Email', :autofocus => 'autofocus', :autocomplete => 'username', :class => 'form-control' %>
|
11
|
+
<% else %>
|
12
|
+
<%= f.label :login %>
|
13
|
+
<%= f.text_field :login, :placeholder => 'Username', :autofocus => 'autofocus', :autocomplete => 'username', :class => 'form-control' %>
|
14
|
+
<% end %>
|
15
|
+
</div>
|
16
|
+
<div class="form-group">
|
17
|
+
<%= f.label :password %>
|
18
|
+
<%= f.password_field :password, :placeholder => 'Password', :autocomplete => 'current-password', :class => 'form-control' %>
|
19
|
+
</div>
|
20
|
+
<div class="form-group">
|
21
|
+
<%= f.submit "Login", :class => 'btn btn-primary', :data => {:disable_with => 'Logging in...', :enable_with => 'Done!'} %>
|
22
|
+
<span>or</span> <%= link_to "Forgot Password?", password_resets_path %>
|
23
|
+
</div>
|
24
|
+
<% end %>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<% @page_title = 'Login' %>
|
2
|
+
|
3
|
+
<h1>Set New Password</h1>
|
4
|
+
|
5
|
+
<p>You must set a new password before you may continue.</p>
|
6
|
+
|
7
|
+
<%= form_for current_user, :url => login_change_password_path, :method => :post, :remote => true, :data => {:errors => :inline, :success => back_or_default('/')} do |f| %>
|
8
|
+
<%= hidden_field_tag :return_to, back_or_default('/') %>
|
9
|
+
<%= tb_form_errors(current_user) %>
|
10
|
+
<div class="form-group">
|
11
|
+
<%= f.label :password %>
|
12
|
+
<%= f.password_field :password, :placeholder => 'Password', :class => 'form-control' %>
|
13
|
+
</div>
|
14
|
+
<div class="form-group">
|
15
|
+
<%= f.label :password_confirmation %>
|
16
|
+
<%= f.password_field :password_confirmation, :placeholder => 'Password Confirmation', :class => 'form-control' %>
|
17
|
+
</div>
|
18
|
+
<div class="form-group">
|
19
|
+
<%= f.submit 'Set Password', :class => 'btn btn-primary', :data => {:disable_with => 'Setting...', :enable_with => 'Done!'} %>
|
20
|
+
</div>
|
21
|
+
<% end %>
|