merb-auth-slice-password 0.9.9 → 0.9.10

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.
data/README.textile CHANGED
@@ -1,23 +1,22 @@
1
1
  MerbAuthSlicePassword ==================
2
2
 
3
3
  A slice for the Merb framework that uses the merb-auth-core authentication
4
- framework. This provides basic form based login as well as basic auth login.
5
- To see how to customize the authentication process, see merb-auth-core.
4
+ framework. This slice provides a basic login and logout function. By default
5
+ it also include the form based password logins and basic authentication.
6
6
 
7
- To use this slice you should supply a User type model that logs in via an
8
- identifier and password. i.e. "email" and "password", or "login" & "password"
7
+ To see how to customize it see the merb-auth-core
9
8
 
10
- Additionally your model should implement a class level method,
11
- authenticate(login, password) This should return the user object, or if not
12
- found should return false or nil
9
+ To use this slice setup some strategies and make sure you have everything required there.
10
+ Usually a "User" model of some kind.
13
11
 
14
- For example
12
+ To overwrite the login form, you should just create a view file in
13
+ app/views/exceptions/unauthenticated.html.erb in the host app.
15
14
 
16
- User.authenticate("fred", "sekrit") #=> The user object for the "fred" login
17
- or nil / false if not found
18
-
19
- You can use the salted_user mixin from merb-auth-more for use with this slice.
15
+ By default the slice will load the password_form and the basic_auth strategies.
16
+ To prevent the slice from loading strategeis use:
17
+ MerbAutheSliceDefault[:no_default_strategies] = true
20
18
 
19
+ <pre>
21
20
  ------------------------------------------------------------------------------
22
21
 
23
22
  |-- LICENSE
@@ -59,7 +58,7 @@ You can use the salted_user mixin from merb-auth-more for use with this slice.
59
58
  `-- main.rb
60
59
 
61
60
 
62
-
61
+ </pre>
63
62
  1. Rake tasks to package/install the gem - edit this to modify the manifest.
64
63
  2. The slice application: controllers, models, helpers, views.
65
64
  3. The default layout, as specified in Merb::Slices::config[:mauth_password_slice][:layout]
@@ -177,4 +176,4 @@ and other runtime code from within the host application.
177
176
 
178
177
  To create your own Slice run this (somewhere outside of your merb app):
179
178
 
180
- $ merb-gen slice <your-lowercase-slice-name>
179
+ $ merb-gen slice <your-lowercase-slice-name>
data/Rakefile CHANGED
@@ -5,11 +5,12 @@ require 'merb-core'
5
5
  require 'merb-core/tasks/merb'
6
6
 
7
7
  GEM_NAME = "merb-auth-slice-password"
8
- AUTHOR = "Your Name"
9
- EMAIL = "Your Email"
8
+ AUTHOR = "Daniel Neighman"
9
+ EMAIL = "has.sox@gmail.com"
10
10
  HOMEPAGE = "http://merbivore.com/"
11
- SUMMARY = "Merb Slice that provides ..."
12
- GEM_VERSION = Merb::VERSION
11
+ SUMMARY = "Merb Slice that provides UI for password strategy of merb-auth."
12
+ PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
13
+ GEM_VERSION = Merb::VERSION + PKG_BUILD
13
14
 
14
15
  spec = Gem::Specification.new do |s|
15
16
  s.rubyforge_project = 'merb'
@@ -23,9 +24,9 @@ spec = Gem::Specification.new do |s|
23
24
  s.author = AUTHOR
24
25
  s.email = EMAIL
25
26
  s.homepage = HOMEPAGE
26
- s.add_dependency('merb-slices', '>= 0.9.9')
27
- s.add_dependency('merb-auth-core', "= #{Merb::VERSION}")
28
- s.add_dependency('merb-auth-more', "= #{Merb::VERSION}")
27
+ s.add_dependency('merb-slices', ">= #{Merb::VERSION}")
28
+ s.add_dependency('merb-auth-core', ">= #{Merb::VERSION}")
29
+ s.add_dependency('merb-auth-more', ">= #{Merb::VERSION}")
29
30
  s.require_path = 'lib'
30
31
  s.files = %w(LICENSE README.textile Rakefile TODO) + Dir.glob("{lib,spec,app,public,stubs}/**/*")
31
32
  end
@@ -49,4 +50,4 @@ end
49
50
  require 'spec/rake/spectask'
50
51
  require 'merb-core/test/tasks/spectasks'
51
52
  desc 'Default: run spec examples'
52
- task :default => 'spec'
53
+ task :default => 'spec'
@@ -1,18 +1,7 @@
1
- class Application < Merb::Controller; end
2
-
3
- class Exceptions < Application
4
- include Merb::Slices::Support # Required to provide slice_url
5
-
6
- # # This stuff allows us to provide a default view
7
- the_view_path = File.expand_path(File.dirname(__FILE__) / ".." / "views")
8
- self._template_roots ||= []
9
- self._template_roots << [the_view_path, :_template_location]
10
- self._template_roots << [Merb.dir_for(:view), :_template_location]
11
-
1
+ # the mixin to provide the exceptions controller action for Unauthenticated
2
+ module MerbAuthSlicePassword::ExceptionsMixin
12
3
  def unauthenticated
13
4
  provides :xml, :js, :json, :yaml
14
-
15
- session.abandon!
16
5
 
17
6
  case content_type
18
7
  when :html
@@ -21,6 +10,24 @@ class Exceptions < Application
21
10
  basic_authentication.request!
22
11
  ""
23
12
  end
24
- end
13
+ end # unauthenticated
14
+ end
15
+
16
+ Merb::Authentication.customize_default do
17
+
18
+ Exceptions.class_eval do
19
+ include Merb::Slices::Support # Required to provide slice_url
20
+
21
+ # # This stuff allows us to provide a default view
22
+ the_view_path = File.expand_path(File.dirname(__FILE__) / ".." / "views")
23
+ self._template_roots ||= []
24
+ self._template_roots << [the_view_path, :_template_location]
25
+ self._template_roots << [Merb.dir_for(:view), :_template_location]
26
+
27
+ include MerbAuthSlicePassword::ExceptionsMixin
28
+
29
+ show_action :unauthenticated
30
+
31
+ end# Exceptions.class_eval
25
32
 
26
- end
33
+ end # Customize default
@@ -3,8 +3,8 @@ class MerbAuthSlicePassword::Sessions < MerbAuthSlicePassword::Application
3
3
  before :_grab_return_to # Need to hang onto the redirection during the session.abandon!
4
4
  after :_store_return_to_in_session # Need to hang onto the redirection during the session.abandon!
5
5
 
6
- before(nil, :only => [:update, :destroy]) { session.abandon! }
7
- before :ensure_authenticated
6
+ before :_abandon_session, :only => [:update, :destroy]
7
+ before :ensure_authenticated, :only => [:update]
8
8
 
9
9
  # redirect from an after filter for max flexibility
10
10
  # We can then put it into a slice and ppl can easily
@@ -24,12 +24,14 @@ class MerbAuthSlicePassword::Sessions < MerbAuthSlicePassword::Application
24
24
  private
25
25
  # @overwritable
26
26
  def redirect_after_login
27
- redirect_back_or "/", :message => "Authenticated Successfully", :ignore => [url(:login), url(:logout)]
27
+ message[:notice] = "Authenticated Successfully"
28
+ redirect_back_or "/", :message => message, :ignore => [slice_url(:login), slice_url(:logout)]
28
29
  end
29
30
 
30
31
  # @overwritable
31
32
  def redirect_after_logout
32
- redirect "/", :message => "Logged Out"
33
+ message[:notice] = "Logged Out"
34
+ redirect "/", :message => message
33
35
  end
34
36
 
35
37
  # @private
@@ -41,4 +43,9 @@ class MerbAuthSlicePassword::Sessions < MerbAuthSlicePassword::Application
41
43
  def _store_return_to_in_session
42
44
  session.authentication.return_to_url = session.authentication.return_to_url
43
45
  end
46
+
47
+ # @private
48
+ def _abandon_session
49
+ session.abandon!
50
+ end
44
51
  end
@@ -25,7 +25,7 @@ if defined?(Merb::Plugins)
25
25
 
26
26
  # Slice metadata
27
27
  self.description = "MerbAuthSlicePassword is a merb slice that provides basic password based logins"
28
- self.version = "0.9.9"
28
+ self.version = "0.9.10"
29
29
  self.author = "Daniel Neighman"
30
30
 
31
31
  # Stub classes loaded hook - runs before LoadClasses BootLoader
@@ -0,0 +1,19 @@
1
+ class MerbAuthSlicePassword::Sessions < MerbAuthSlicePassword::Application
2
+
3
+ after :redirect_after_login, :only => :update, :if => lambda{ !(300..399).include?(status) }
4
+ after :redirect_after_logout, :only => :destroy
5
+
6
+ private
7
+ # @overwritable
8
+ def redirect_after_login
9
+ message[:notice] = "Authenticated Successfully"
10
+ redirect_back_or "/", :message => message, :ignore => [slice_url(:login), slice_url(:logout)]
11
+ end
12
+
13
+ # @overwritable
14
+ def redirect_after_logout
15
+ message[:notice] = "Logged Out"
16
+ redirect "/", :message => message
17
+ end
18
+
19
+ end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merb-auth-slice-password
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.9
4
+ version: 0.9.10
5
5
  platform: ruby
6
6
  authors:
7
- - Your Name
7
+ - Daniel Neighman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-13 00:00:00 -07:00
12
+ date: 2008-10-21 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.9.9
23
+ version: 0.9.10
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: merb-auth-core
@@ -28,9 +28,9 @@ dependencies:
28
28
  version_requirement:
29
29
  version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "="
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.9.9
33
+ version: 0.9.10
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: merb-auth-more
@@ -38,12 +38,12 @@ dependencies:
38
38
  version_requirement:
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - "="
41
+ - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: 0.9.9
43
+ version: 0.9.10
44
44
  version:
45
- description: Merb Slice that provides ...
46
- email: Your Email
45
+ description: Merb Slice that provides UI for password strategy of merb-auth.
46
+ email: has.sox@gmail.com
47
47
  executables: []
48
48
 
49
49
  extensions: []
@@ -81,8 +81,7 @@ files:
81
81
  - public/stylesheets/master.css
82
82
  - stubs/app
83
83
  - stubs/app/controllers
84
- - stubs/app/controllers/application.rb
85
- - stubs/app/controllers/main.rb
84
+ - stubs/app/controllers/sessions.rb
86
85
  has_rdoc: true
87
86
  homepage: http://merbivore.com/
88
87
  post_install_message:
@@ -105,9 +104,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
104
  requirements: []
106
105
 
107
106
  rubyforge_project: merb
108
- rubygems_version: 1.2.0
107
+ rubygems_version: 1.3.0
109
108
  signing_key:
110
109
  specification_version: 2
111
- summary: Merb Slice that provides ...
110
+ summary: Merb Slice that provides UI for password strategy of merb-auth.
112
111
  test_files: []
113
112
 
@@ -1,2 +0,0 @@
1
- class MerbAuthSlicePassword::Application < Merb::Controller
2
- end
@@ -1,2 +0,0 @@
1
- class MerbAuthSlicePassword::Main < MerbAuthSlicePassword::Application
2
- end