simple_sign_in 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +22 -0
  5. data/app/assets/javascripts/simple_sign_in/application.js +13 -0
  6. data/app/assets/javascripts/simple_sign_in/login.js +2 -0
  7. data/app/assets/stylesheets/simple_sign_in/application.css +13 -0
  8. data/app/assets/stylesheets/simple_sign_in/login.css +13 -0
  9. data/app/controllers/simple_sign_in/application_controller.rb +5 -0
  10. data/app/controllers/simple_sign_in/login_controller.rb +26 -0
  11. data/app/helpers/simple_sign_in/application_helper.rb +4 -0
  12. data/app/helpers/simple_sign_in/login_helper.rb +4 -0
  13. data/app/views/layouts/simple_sign_in/application.html.erb +15 -0
  14. data/app/views/simple_sign_in/login/new.html.erb +29 -0
  15. data/config/routes.rb +5 -0
  16. data/lib/simple_sign_in/controller_methods.rb +29 -0
  17. data/lib/simple_sign_in/engine.rb +23 -0
  18. data/lib/simple_sign_in/version.rb +3 -0
  19. data/lib/simple_sign_in.rb +5 -0
  20. data/lib/tasks/simple_sign_in_tasks.rake +4 -0
  21. data/spec/controllers/simple_sign_in/login_controller_spec.rb +42 -0
  22. data/spec/dummy/README.rdoc +28 -0
  23. data/spec/dummy/Rakefile +6 -0
  24. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  25. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  26. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  27. data/spec/dummy/app/controllers/public_controller.rb +7 -0
  28. data/spec/dummy/app/controllers/secrets_controller.rb +5 -0
  29. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  30. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  31. data/spec/dummy/app/views/public/index.html.erb +1 -0
  32. data/spec/dummy/app/views/secrets/index.html.erb +2 -0
  33. data/spec/dummy/bin/bundle +3 -0
  34. data/spec/dummy/bin/rails +4 -0
  35. data/spec/dummy/bin/rake +4 -0
  36. data/spec/dummy/config/application.rb +29 -0
  37. data/spec/dummy/config/boot.rb +5 -0
  38. data/spec/dummy/config/database.yml +25 -0
  39. data/spec/dummy/config/environment.rb +5 -0
  40. data/spec/dummy/config/environments/development.rb +29 -0
  41. data/spec/dummy/config/environments/production.rb +80 -0
  42. data/spec/dummy/config/environments/test.rb +36 -0
  43. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  44. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  45. data/spec/dummy/config/initializers/inflections.rb +16 -0
  46. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  47. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  48. data/spec/dummy/config/initializers/session_store.rb +3 -0
  49. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  50. data/spec/dummy/config/locales/en.yml +23 -0
  51. data/spec/dummy/config/routes.rb +6 -0
  52. data/spec/dummy/config.ru +4 -0
  53. data/spec/dummy/db/development.sqlite3 +0 -0
  54. data/spec/dummy/db/test.sqlite3 +0 -0
  55. data/spec/dummy/log/development.log +11426 -0
  56. data/spec/dummy/log/test.log +5352 -0
  57. data/spec/dummy/public/404.html +58 -0
  58. data/spec/dummy/public/422.html +58 -0
  59. data/spec/dummy/public/500.html +57 -0
  60. data/spec/dummy/public/favicon.ico +0 -0
  61. data/spec/dummy/tmp/cache/assets/development/sprockets/09f847bad5c38ac9566e1ce53f354ca5 +0 -0
  62. data/spec/dummy/tmp/cache/assets/development/sprockets/0eec9b0107101ed19acf49f0c8284333 +0 -0
  63. data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  64. data/spec/dummy/tmp/cache/assets/development/sprockets/1fa8afc413f553b3e784a30c9c8bb124 +0 -0
  65. data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  66. data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  67. data/spec/dummy/tmp/cache/assets/development/sprockets/3a965b06713dd238c43a7dda73d07f2b +0 -0
  68. data/spec/dummy/tmp/cache/assets/development/sprockets/3c941c17a6569cfb2c882aa9f41ee036 +0 -0
  69. data/spec/dummy/tmp/cache/assets/development/sprockets/3ffbe3d6494067ce895cfcedaa2a091b +0 -0
  70. data/spec/dummy/tmp/cache/assets/development/sprockets/4acbe0bee9852ebc9369f3460e1037a6 +0 -0
  71. data/spec/dummy/tmp/cache/assets/development/sprockets/60808c9c70a3e71f23258e2e07b413a5 +0 -0
  72. data/spec/dummy/tmp/cache/assets/development/sprockets/79ab54deddfe98f7a569388cbbe22271 +0 -0
  73. data/spec/dummy/tmp/cache/assets/development/sprockets/9d1aaaef3ed07c86494e16ae882fdb30 +0 -0
  74. data/spec/dummy/tmp/cache/assets/development/sprockets/a0dc5630084f477bd96cb889b4732422 +0 -0
  75. data/spec/dummy/tmp/cache/assets/development/sprockets/b69f45bbf61db55374b8fa4911e4720f +0 -0
  76. data/spec/dummy/tmp/cache/assets/development/sprockets/ba9086cd45f087b00f233b32fae0542a +0 -0
  77. data/spec/dummy/tmp/cache/assets/development/sprockets/bd6036d4fcbb0cda7e3d3ee44fe11bca +0 -0
  78. data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  79. data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  80. data/spec/dummy/tmp/cache/assets/development/sprockets/de506abedf03f4f69ae8a2e86ee06ba8 +0 -0
  81. data/spec/dummy/tmp/cache/assets/development/sprockets/de62d8814fc20e093094b6bf5d417823 +0 -0
  82. data/spec/dummy/tmp/cache/assets/development/sprockets/f318b38f3aa115b6cae66657e35cd3fe +0 -0
  83. data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  84. data/spec/dummy/tmp/cache/assets/development/sprockets/fb4a32219974bda2986ac225499cd272 +0 -0
  85. data/spec/dummy/tmp/cache/assets/test/sprockets/0eec9b0107101ed19acf49f0c8284333 +0 -0
  86. data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  87. data/spec/dummy/tmp/cache/assets/test/sprockets/1fa8afc413f553b3e784a30c9c8bb124 +0 -0
  88. data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  89. data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  90. data/spec/dummy/tmp/cache/assets/test/sprockets/3a965b06713dd238c43a7dda73d07f2b +0 -0
  91. data/spec/dummy/tmp/cache/assets/test/sprockets/3ffbe3d6494067ce895cfcedaa2a091b +0 -0
  92. data/spec/dummy/tmp/cache/assets/test/sprockets/4acbe0bee9852ebc9369f3460e1037a6 +0 -0
  93. data/spec/dummy/tmp/cache/assets/test/sprockets/60808c9c70a3e71f23258e2e07b413a5 +0 -0
  94. data/spec/dummy/tmp/cache/assets/test/sprockets/79ab54deddfe98f7a569388cbbe22271 +0 -0
  95. data/spec/dummy/tmp/cache/assets/test/sprockets/9d1aaaef3ed07c86494e16ae882fdb30 +0 -0
  96. data/spec/dummy/tmp/cache/assets/test/sprockets/a0dc5630084f477bd96cb889b4732422 +0 -0
  97. data/spec/dummy/tmp/cache/assets/test/sprockets/ba9086cd45f087b00f233b32fae0542a +0 -0
  98. data/spec/dummy/tmp/cache/assets/test/sprockets/bd6036d4fcbb0cda7e3d3ee44fe11bca +0 -0
  99. data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  100. data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  101. data/spec/dummy/tmp/cache/assets/test/sprockets/de506abedf03f4f69ae8a2e86ee06ba8 +0 -0
  102. data/spec/dummy/tmp/cache/assets/test/sprockets/de62d8814fc20e093094b6bf5d417823 +0 -0
  103. data/spec/dummy/tmp/cache/assets/test/sprockets/f318b38f3aa115b6cae66657e35cd3fe +0 -0
  104. data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  105. data/spec/features/simple_sign_in_login_flows_spec.rb +42 -0
  106. data/spec/spec_helper.rb +50 -0
  107. metadata +319 -0
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/404.html -->
52
+ <div class="dialog">
53
+ <h1>The page you were looking for doesn't exist.</h1>
54
+ <p>You may have mistyped the address or the page may have moved.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/422.html -->
52
+ <div class="dialog">
53
+ <h1>The change you wanted was rejected.</h1>
54
+ <p>Maybe you tried to change something you didn't have access to.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/500.html -->
52
+ <div class="dialog">
53
+ <h1>We're sorry, but something went wrong.</h1>
54
+ </div>
55
+ <p>If you are the application owner check the logs for more information.</p>
56
+ </body>
57
+ </html>
File without changes
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe "LoginFlow" do
4
+ describe "user logs in successfully" do
5
+
6
+ before do
7
+ @login = ENV['SIMPLE_SIGN_IN_LOGIN']
8
+ @pass = ENV['SIMPLE_SIGN_IN_PASSWORD']
9
+ end
10
+
11
+ it "displays error notice if login / password are incorrect" do
12
+ visit "/"
13
+ fill_in("Login", with: 'wrong')
14
+ fill_in("Password", with: 'sss')
15
+ click_button('Submit')
16
+ page.should have_content('Incorrect login or password')
17
+ end
18
+
19
+ it "redirects the user to login screen where the user logs in", js: true do
20
+ visit "/"
21
+ fill_in("Login", with: @login)
22
+ fill_in("Password", with: @pass)
23
+ click_button('Submit')
24
+ page.should have_content('Secret')
25
+ click_link "Sign Out"
26
+ page.should have_content('You have been signed out')
27
+ end
28
+
29
+ it "can be overrided in a specific controller" do
30
+ visit "/public"
31
+ page.should have_content("Public")
32
+ end
33
+
34
+ it "can be completely turned off in certain environments" do
35
+ ApplicationController.class_eval("@@simple_sign_in_envs ||= [:development]")
36
+ visit "/"
37
+ page.should have_content("Top Secret")
38
+ ApplicationController.class_eval("@@simple_sign_in_envs = nil")
39
+ end
40
+
41
+ end
42
+ end
@@ -0,0 +1,50 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+ ENV["SIMPLE_SIGN_IN_LOGIN"] = 'admin'
4
+ ENV["SIMPLE_SIGN_IN_PASSWORD"] = 'admin123'
5
+
6
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
7
+ require 'pry'
8
+ require 'rspec/rails'
9
+ require 'rspec/autorun'
10
+ require 'capybara/rspec'
11
+ require 'capybara-webkit'
12
+
13
+ Capybara.javascript_driver = :webkit
14
+
15
+ # Requires supporting ruby files with custom matchers and macros, etc,
16
+ # in spec/support/ and its subdirectories.
17
+ Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
18
+
19
+ # Checks for pending migrations before tests are run.
20
+ # If you are not using ActiveRecord, you can remove this line.
21
+ ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
22
+
23
+ RSpec.configure do |config|
24
+ # ## Mock Framework
25
+ #
26
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
27
+ #
28
+ # config.mock_with :mocha
29
+ # config.mock_with :flexmock
30
+ # config.mock_with :rr
31
+
32
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
33
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
34
+
35
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
36
+ # examples within a transaction, remove the following line or assign false
37
+ # instead of true.
38
+ config.use_transactional_fixtures = true
39
+
40
+ # If true, the base class of anonymous controllers will be inferred
41
+ # automatically. This will be the default behavior in future versions of
42
+ # rspec-rails.
43
+ config.infer_base_class_for_anonymous_controllers = false
44
+
45
+ # Run specs in random order to surface order dependencies. If you find an
46
+ # order dependency and want to debug it, you can fix the order by providing
47
+ # the seed, which is printed after each run.
48
+ # --seed 1234
49
+ config.order = "random"
50
+ end