defcon 1.0.0 → 1.0.1

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be9f1fc08009487f9d55a03da06f24c9cb147aa2
4
- data.tar.gz: 78a08aadf0131031805615ce7f282c5bc2aaf68f
3
+ metadata.gz: 20bc5842476a4eb7364aed19bfe432bfd889455b
4
+ data.tar.gz: c929ad5de421b8f9e03417aefc9ebb554b982bb4
5
5
  SHA512:
6
- metadata.gz: f73052a1a1300c3dc740d81262203bec013a475fa49675637eae8f3f1095a5c04680f4443535898a04937d2d5ebbbd9d7f97ef8403cd1a930ca02370d019838e
7
- data.tar.gz: b4025258d8137fdc14fbefc06f86b95b8e9599faa40385b7032fc713f144bd31529054bee17ea812cc710bfeee970e842cbaf478d97335661941931e6cc99479
6
+ metadata.gz: 579bf1bb18acc501f4bbccd0b7bd6280f0fc35618435222e005003c9ee84b4661077637d121bfeebac782f6e42c999e3157048c30858b2bdf8d21c5474a8cc32
7
+ data.tar.gz: 37b7174e4e21af37756a12bea39327822b55ff58f08d2ddfa6b3dd87b1c954ae9aec51ea46eae35cfbe2a9ae32116033a555960207de0a819c6f295256c4e31a
@@ -17,27 +17,29 @@ module Defcon
17
17
  session[:admin_username] = admin.username
18
18
  redirect_to admin_root_path, notice: "Welcome back!"
19
19
  else
20
- admin.attempts = admin.attempts + 1
21
- admin.save
20
+ if !admin.nil?
21
+ admin.attempts = admin.attempts + 1
22
+ admin.save
23
+ end
22
24
  message = "Are you sure you belong here?"
23
- if admin.locked_out?
25
+ if !admin.nil? && admin.locked_out?
24
26
  message = "Locked out!"
25
27
  end
26
- redirect_to login_path, alert: message
28
+ redirect_to defcon_login_path, alert: message
27
29
  end
28
30
  end
29
31
 
30
32
  def destroy
31
33
  session[:admin_id] = nil
32
34
  session[:admin_username] = nil
33
- redirect_to login_path, notice: "Until next time!"
35
+ redirect_to defcon_login_path, notice: "Until next time!"
34
36
  end
35
37
 
36
38
  private
37
39
 
38
40
  def logged_in_check
39
41
  if !logged_in?
40
- redirect_to login_path, alert: "You are not logged in."
42
+ redirect_to defcon_login_path, alert: "You are not logged in."
41
43
  return false
42
44
  else
43
45
  return true
@@ -1,4 +1,6 @@
1
- <h1>Admin</h1>
1
+ <div class="text-center">
2
+ <h1>Admin</h1>
3
+ </div>
2
4
 
3
5
  <div class="text-center">
4
6
  <% flash.each do |name, msg| -%>
@@ -28,5 +30,6 @@
28
30
  <br>
29
31
  <div class="actions"><%= submit_tag("Login", class: "btn btn-large btn-primary") %></div>
30
32
  </div>
31
- <% end %>
32
- </div>
33
+ </div>
34
+
35
+ <% end %>
data/config/routes.rb CHANGED
@@ -1,11 +1,10 @@
1
1
  Defcon::Engine.routes.draw do
2
-
3
- get 'admin/login' => "sessions#new", as: 'login'
2
+ root to: "sessions#new"
3
+ get 'admin/login' => "sessions#new", as: 'defcon_login'
4
4
  post 'sessions/create'
5
5
  post 'sessions/destroy'
6
- post 'admin/logout' => "sessions#destroy", as: 'logout'
6
+ post 'admin/logout' => "sessions#destroy", as: 'defcon_logout'
7
7
  #This get is only here for convenience
8
8
  #get 'admin/logout' => "sessions#destroy"
9
9
  #Need to define an admin_root_path if not using active admin
10
-
11
10
  end
@@ -0,0 +1,5 @@
1
+ class AddIndexToDefconAdminUsers < ActiveRecord::Migration
2
+ def change
3
+ add_index :defcon_admin_users, :username
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module Defcon
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
Binary file
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20141008173352) do
14
+ ActiveRecord::Schema.define(version: 20141008214632) do
15
15
 
16
16
  create_table "defcon_admin_users", force: true do |t|
17
17
  t.string "username"
@@ -25,4 +25,6 @@ ActiveRecord::Schema.define(version: 20141008173352) do
25
25
  t.datetime "updated_at"
26
26
  end
27
27
 
28
+ add_index "defcon_admin_users", ["username"], name: "index_defcon_admin_users_on_username"
29
+
28
30
  end
@@ -8,3 +8,19 @@ Migrating to CreateDefconAdminUsers (20141008173352)
8
8
  SQL (0.5ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20141008173352"]]
9
9
   (140.4ms) commit transaction
10
10
  ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
11
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
12
+ Migrating to AddIndexToDefconAdminUsers (20141008214632)
13
+  (0.1ms) begin transaction
14
+  (0.1ms) select sqlite_version(*)
15
+  (23.7ms) CREATE INDEX "index_defcon_admin_users_on_username" ON "defcon_admin_users" ("username")
16
+ SQL (0.6ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20141008214632"]]
17
+  (510.7ms) commit transaction
18
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
19
+  (0.2ms) SELECT sql
20
+ FROM sqlite_master
21
+ WHERE name='index_defcon_admin_users_on_username' AND type='index'
22
+ UNION ALL
23
+ SELECT sql
24
+ FROM sqlite_temp_master
25
+ WHERE name='index_defcon_admin_users_on_username' AND type='index'
26
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: defcon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cleophus Robinson
@@ -61,6 +61,7 @@ files:
61
61
  - app/views/layouts/defcon/default/application.html.erb
62
62
  - config/routes.rb
63
63
  - db/migrate/20141008173352_create_defcon_admin_users.rb
64
+ - db/migrate/20141008214632_add_index_to_defcon_admin_users.rb
64
65
  - lib/defcon.rb
65
66
  - lib/defcon/engine.rb
66
67
  - lib/defcon/version.rb