caboose-cms 0.3.100 → 0.3.101

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NWIyNGU5OTMwOGFjNDcwMmRlMWE1ZWRiMDZhMzg4ZmYxZTExMmQ1MA==
4
+ N2NlYzU4ZDY3MmRkNDQ1NmE0ZDFlYmNmNmY4ODU3YzEzYTEwYWFhMQ==
5
5
  data.tar.gz: !binary |-
6
- OGQxMGIzNjdmYjRmMzU5ZDRhMzA0MDVlMjQ0MmQ2ZGE1ZmVlMmRkNg==
6
+ NzE1MjhlNmNhY2I4OGVhZTQxNThmZDdkZDVlNzZhNGYzNTA4NWU2ZQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MjNlZTc2NDRhNjY2ZTk4MmQ3Njc3ZTliMGI3ZGE1NDM0MTcwNDQyNWJmYzVi
10
- NDY1NzFkZmVkMzkxOTc4MzMyNTA2Nzc0Njc5MzZjZTU3ZmU1MzM4MjFmMTEx
11
- ZTAwMDYyNWMzOGU0M2JlNWZkNGU2ZmM1ODNiMGVkYWRhNmRiZmI=
9
+ YjRhZTAzYTQxNzA2ZTc2ZjU0YTI1MTMxMDBlNjhmMTBiYzc4ZGFkOTQ2MGI0
10
+ ZWRkY2M4NTE1NmY2NGUwZjM0ZWVhMzc5YjczZjAyNGMxMWJkM2Y5MWZjYmI2
11
+ ZTQ5ZGE5ZjI2Y2JhMWUzNzc5ZGIyNDE3MGNkOWJkMzFiZmNiOTY=
12
12
  data.tar.gz: !binary |-
13
- NDM2YzJjOGMyY2ZhYmYyOTdmMTNmZGI0OTUxZDUxOTk0MmFjMDk2MjBhNjJh
14
- ZmJiZmIzMmM4ZWQxYmU1ZTFkZmQwODNmZWUxODc4MWRjYmNiODMyYjgzMTFi
15
- OTMyMjEwNGI1Nzk0NzgzN2E1MjBmOGRmZTM2MjI4ZWFiODk3MTM=
13
+ NDgyMWZmNTA0YmVmYzM2ODMxMTFmZmYxMzE3M2FjZmJkNDBhMGU2YTE2OTQz
14
+ ODgzZTAzYzE3OTZlMmU2ZTZlODNiYzkwZDkzNTkzY2E3OGRlNjNmMTVlODcw
15
+ YzRkOGQwZGI4ZDhhYzc0ZjdlOTc1YTVlZGQ4ZjgyMTI3MzBhZjY=
@@ -134,6 +134,7 @@ module Caboose
134
134
  @user = logged_in_user
135
135
  if (!@user.is_allowed(resource, action))
136
136
  @error = "You don't have permission to " + action + " " + resource
137
+ @return_url = request.fullpath
137
138
  render :template => "caboose/extras/error"
138
139
  return false
139
140
  end
@@ -159,6 +160,7 @@ module Caboose
159
160
  @user = logged_in_user
160
161
  unless @user.is_allowed(resource, action)
161
162
  @error = "You don't have permission to #{action} #{resource}"
163
+ @return_url = request.fullpath
162
164
  render :template => "caboose/extras/error"
163
165
  return false
164
166
  end
@@ -4,26 +4,30 @@ module Caboose
4
4
 
5
5
  # GET /login
6
6
  def index
7
+ if params[:logout]
8
+ logout_user
9
+ elo = User.find(User::LOGGED_OUT_USER_ID)
10
+ login_user(elo)
11
+ end
7
12
  @return_url = params[:return_url].nil? ? "/" : params[:return_url]
8
13
  @modal = params[:modal].nil? ? false : params[:modal]
9
14
  redirect_to @return_url and return if logged_in?
10
15
  end
11
16
 
12
17
  # POST /login
13
- def login
18
+ def login
14
19
  resp = StdClass.new('error' => '', 'redirect' => '')
15
20
  return_url = params[:return_url].nil? ? "/" : params[:return_url]
16
21
 
17
- if (logged_in?)
22
+ if logged_in?
18
23
  resp.redirect = return_url
19
24
  else
20
25
  username = params[:username].downcase
21
26
  password = params[:password]
22
27
 
23
- if (username.nil? || password.nil? || password.strip.length == 0)
28
+ if username.nil? || password.nil? || password.strip.length == 0
24
29
  resp.error = "Invalid credentials"
25
- else
26
-
30
+ else
27
31
  bouncer_class = Caboose::authenticator_class.constantize
28
32
  bouncer = bouncer_class.new
29
33
  login_resp = bouncer.authenticate(username, password)
@@ -37,8 +41,8 @@ module Caboose
37
41
  Caboose.plugin_hook('login_success')
38
42
  end
39
43
  end
40
- end
41
- render :json => resp
44
+ end
45
+ render :json => resp
42
46
  end
43
47
 
44
48
  # GET /login/forgot-password
@@ -1,2 +1,3 @@
1
1
  <h1>Error</h1>
2
2
  <p class='note error'><%= @error %></p>
3
+ <p><a href="/modal/login?logout=1&return_url=<%= @return_url %>">Login as a different user</a></p>
@@ -13,7 +13,7 @@ Caboose::Engine.routes.draw do
13
13
  get "login/reset-password/:reset_id" => "login#reset_password_form"
14
14
  post "login/reset-password" => "login#reset_password"
15
15
  get "login" => "login#index"
16
- post "login" => "login#login"
16
+ post "login" => "login#login"
17
17
  get "logout" => "logout#index"
18
18
  get "register" => "register#index"
19
19
  post "register" => "register#register"
@@ -57,6 +57,10 @@ module Caboose
57
57
 
58
58
  # API key for timezonedb.com/api
59
59
  mattr_accessor :timezonedb_api_key
60
- @@timezonedb_api_key = ''
60
+ @@timezonedb_api_key = ''
61
+
62
+ # Session length (in hours)
63
+ mattr_accessor :session_length
64
+ @@session_length = 24
61
65
 
62
66
  end
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.3.100'
2
+ VERSION = '0.3.101'
3
3
  end
@@ -53,6 +53,11 @@ namespace :caboose do
53
53
  `pg_restore --verbose --clean --no-acl --no-owner -h #{ddb['host']} -U #{ddb['username']} -d #{ddb['database']} #{dump_file}`
54
54
 
55
55
  end
56
+
57
+ desc "Clears sessions older than the length specified in the caboose config from the sessions table"
58
+ task :clear_old_sessions => :environment do
59
+ ActiveRecord::SessionStore::Session.delete_all(["updated_at < ?", Caboose::session_length.hours.ago])
60
+ end
56
61
 
57
62
  desc "Loads and refreshes the timezones from timezonedb.com"
58
63
  task :load_timezones => :environment do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.100
4
+ version: 0.3.101
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-19 00:00:00.000000000 Z
11
+ date: 2014-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails