cz_auth 0.0.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +45 -0
  3. data/Rakefile +9 -15
  4. data/app/controllers/cz_auth/application_controller.rb +1 -22
  5. data/app/controllers/cz_auth/authentication_controller.rb +26 -0
  6. data/app/controllers/cz_auth/concerns/authentication.rb +118 -0
  7. data/app/views/cz_auth/authentication/create.json.erb +4 -0
  8. data/app/views/cz_auth/authentication/invalid.json +1 -0
  9. data/config/environment.rb +1 -0
  10. data/config/routes.rb +3 -11
  11. data/lib/cz_auth.rb +1 -4
  12. data/lib/cz_auth/engine.rb +6 -0
  13. data/lib/cz_auth/requires_authentication.rb +39 -8
  14. data/lib/cz_auth/version.rb +1 -1
  15. data/lib/generators/cz_auth/install_generator.rb +1 -1
  16. data/spec/dummy/README.rdoc +28 -0
  17. data/spec/dummy/Rakefile +6 -0
  18. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  19. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  20. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  21. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  22. data/spec/dummy/app/models/user.rb +3 -0
  23. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  24. data/spec/dummy/bin/bundle +3 -0
  25. data/spec/dummy/bin/rails +4 -0
  26. data/spec/dummy/bin/rake +4 -0
  27. data/spec/dummy/config.ru +4 -0
  28. data/spec/dummy/config/application.rb +28 -0
  29. data/spec/dummy/config/boot.rb +5 -0
  30. data/spec/dummy/config/database.yml +13 -0
  31. data/spec/dummy/config/environment.rb +5 -0
  32. data/spec/dummy/config/environments/development.rb +29 -0
  33. data/spec/dummy/config/environments/production.rb +80 -0
  34. data/spec/dummy/config/environments/test.rb +36 -0
  35. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  36. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  37. data/spec/dummy/config/initializers/inflections.rb +16 -0
  38. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  39. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  40. data/spec/dummy/config/initializers/session_store.rb +3 -0
  41. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  42. data/spec/dummy/config/locales/en.yml +23 -0
  43. data/spec/dummy/config/routes.rb +3 -0
  44. data/spec/dummy/db/migrate/20130725213651_create_users.rb +12 -0
  45. data/spec/dummy/db/schema.rb +25 -0
  46. data/spec/dummy/log/test.log +1180 -0
  47. data/spec/dummy/public/404.html +58 -0
  48. data/spec/dummy/public/422.html +58 -0
  49. data/spec/dummy/public/500.html +57 -0
  50. data/spec/dummy/public/favicon.ico +0 -0
  51. data/spec/dummy/spec/factories/user.rb +9 -0
  52. data/spec/dummy/spec/models/user_spec.rb +40 -0
  53. data/spec/dummy/spec/spec_helper.rb +37 -0
  54. data/spec/spec_helper.rb +37 -0
  55. metadata +58 -26
  56. data/README.rdoc +0 -19
  57. data/app/controllers/cz_auth/registrations_controller.rb +0 -19
  58. data/app/controllers/cz_auth/sessions_controller.rb +0 -22
  59. data/app/helpers/cz_auth/application_helper.rb +0 -11
  60. data/app/views/cz_auth/registrations/new.html.erb +0 -1
  61. data/app/views/cz_auth/sessions/new.html.erb +0 -1
  62. data/lib/tasks/cz_auth_tasks.rake +0 -4
data/README.rdoc DELETED
@@ -1,19 +0,0 @@
1
- == CzAuth
2
-
3
- Just a simple authentication implementation using has_secure_password for convenience. This gem is not supported for public consumption. It's just something I threw together to simplify my daily life.
4
-
5
- === Usage
6
-
7
- rails g cz_auth:install <model_name>
8
- rake db:migrate
9
-
10
- === Details
11
-
12
- The generator will generate a model with the following attributes:
13
-
14
- * username
15
- * email
16
- * password_digest
17
- * auth_token
18
-
19
- It will then place a 'requires_authentication' method at the top of the model. This will trigger the has_secure_password, and before filter used to generate an auth_token.
@@ -1,19 +0,0 @@
1
- module CzAuth
2
- class RegistrationsController < CzAuth::ApplicationController
3
-
4
- def new
5
- @resource = @klass.new
6
- end
7
-
8
- def create
9
- @resource = @klass.new(params[:resource])
10
- if @resource.save
11
- cookies[:auth_token] = @resource.auth_token
12
- redirect_to root_url
13
- else
14
- render :new
15
- end
16
- end
17
-
18
- end
19
- end
@@ -1,22 +0,0 @@
1
- module CzAuth
2
- class SessionsController < CzAuth::ApplicationController
3
-
4
- def new
5
- @resource = @klass.new
6
- end
7
-
8
- def create
9
- @resource = @klass.where(:resourcename => params[:resourcename]).first
10
- if @resource && @resource.authenticate(params[:password])
11
- cookies.permanent[:auth_token] = @resource.auth_token
12
- end
13
- redirect_to root_url
14
- end
15
-
16
- def destroy
17
- cookies.delete(:auth_token)
18
- redirect_to root_url
19
- end
20
-
21
- end
22
- end
@@ -1,11 +0,0 @@
1
- module CzAuth
2
- module ApplicationHelper
3
- def current_user
4
- @current_user ||= User.find_by_auth_token(cookies[:auth_token]) if cookies[:auth_token]
5
- end
6
-
7
- def user_signed_in?
8
- !current_user.nil?
9
- end
10
- end
11
- end
@@ -1 +0,0 @@
1
- <h1>Registrations#New</h1>
@@ -1 +0,0 @@
1
- <h1>Sessions#New</h1>
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :cz_auth do
3
- # # Task goes here
4
- # end