puffer 0.0.28 → 0.0.29

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -9,6 +9,7 @@ group :development, :test do
9
9
  gem "mongoid"
10
10
  gem "bson_ext"
11
11
 
12
+ gem 'devise'
12
13
 
13
14
  gem "rspec-rails"
14
15
  gem "capybara"
data/Gemfile.lock CHANGED
@@ -45,6 +45,10 @@ GEM
45
45
  childprocess (0.2.2)
46
46
  ffi (~> 1.0.6)
47
47
  database_cleaner (0.6.7)
48
+ devise (1.4.5)
49
+ bcrypt-ruby (~> 3.0)
50
+ orm_adapter (~> 0.0.3)
51
+ warden (~> 1.0.3)
48
52
  diff-lcs (1.1.3)
49
53
  erubis (2.7.0)
50
54
  fabrication (1.1.0)
@@ -142,6 +146,8 @@ GEM
142
146
  polyglot
143
147
  polyglot (>= 0.3.1)
144
148
  tzinfo (0.3.29)
149
+ warden (1.0.5)
150
+ rack (>= 1.0)
145
151
  xpath (0.1.4)
146
152
  nokogiri (~> 1.3)
147
153
 
@@ -152,6 +158,7 @@ DEPENDENCIES
152
158
  bson_ext
153
159
  capybara
154
160
  database_cleaner
161
+ devise
155
162
  fabrication
156
163
  forgery
157
164
  guard
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.28
1
+ 0.0.29
@@ -0,0 +1,3 @@
1
+ class Admin::PufferUsersController < Puffer::PufferUsersBase
2
+
3
+ end
@@ -1,35 +1,23 @@
1
1
  class Admin::SessionsController < Puffer::SessionsBase
2
- unloadable
3
- # This is example session controller for puffer authentication.
4
- # You can define your own actions.
5
- # Also, you can redefine <tt>new<tt> action view as you wish,
6
- # but more effectively will be definig fields with standart
7
- # puffer DSL:
8
- # create do
9
- # field :login
10
- # field :password
11
- # field :remember_me
12
- # end
13
- #
14
- # By default defined <tt>email<tt> and <tt>password<tt> fields.
15
- # If puffer can`t calculate field type, just set it manually.
16
2
 
17
3
  def new
18
- # @record = UserSession.new
4
+ @record = PufferUser.new
19
5
  end
20
6
 
21
7
  def create
22
- # @record = UserSession.new params[:user_session]
23
- # if @record.save
24
- # redirect_back_or_default puffer_root_url
25
- # else
26
- # render 'new'
27
- # end
8
+ @record = PufferUser.find_by_email(params[:puffer_user][:email])
9
+ if @record && @record.authenticate(params[:puffer_user][:password])
10
+ session[:puffer_user_id] = @record.id
11
+ redirect_to admin_root_url
12
+ else
13
+ @record = PufferUser.new :email => params[:puffer_user][:email]
14
+ render 'new'
15
+ end
28
16
  end
29
17
 
30
18
  def destroy
31
- # current_user_session.destroy
32
- # redirect_to new_puffer_session_url
19
+ session.delete(:puffer_user_id)
20
+ redirect_to new_admin_session_url
33
21
  end
34
22
 
35
23
  end
@@ -1,8 +1,10 @@
1
1
  module Puffer
2
2
  class Base < ApplicationController
3
3
  unloadable
4
-
5
4
  pufferize!
5
+
6
+ before_filter :require_puffer_user
7
+
6
8
  define_fieldset :index, :form
7
9
  define_fieldset :show, :fallbacks => :index
8
10
  define_fieldset :create, :update, :fallbacks => :form
@@ -1,8 +1,9 @@
1
1
  class Puffer::DashboardBase < ApplicationController
2
2
  unloadable
3
-
4
3
  pufferize!
5
4
 
5
+ before_filter :require_puffer_user
6
+
6
7
  layout 'puffer_dashboard'
7
8
 
8
9
  def index
@@ -0,0 +1,21 @@
1
+ module Puffer
2
+ class PufferUsersBase < Puffer::Base
3
+
4
+ setup do
5
+ group :users
6
+ end
7
+
8
+ index do
9
+ field :email
10
+ field :roles
11
+ end
12
+
13
+ form do
14
+ field :email
15
+ field :password
16
+ field :password_confirmation
17
+ field :roles
18
+ end
19
+
20
+ end
21
+ end
@@ -1,7 +1,9 @@
1
1
  class Puffer::SessionsBase < ApplicationController
2
2
  unloadable
3
-
4
3
  pufferize!
4
+
5
+ before_filter :require_puffer_user, :only => :destroy
6
+
5
7
  define_fieldset :create
6
8
 
7
9
  layout 'puffer_sessions'
@@ -13,4 +15,22 @@ class Puffer::SessionsBase < ApplicationController
13
15
  field :password, :type => :password
14
16
  end
15
17
 
18
+ def new
19
+ # @record = UserSession.new
20
+ end
21
+
22
+ def create
23
+ # @record = UserSession.new params[:user_session]
24
+ # if @record.save
25
+ # redirect_back_or_default puffer_root_url
26
+ # else
27
+ # render 'new'
28
+ # end
29
+ end
30
+
31
+ def destroy
32
+ # current_user_session.destroy
33
+ # redirect_to new_puffer_session_url
34
+ end
35
+
16
36
  end
@@ -0,0 +1,34 @@
1
+ class Puffer::SessionsDeviseBase < Puffer::SessionsBase
2
+ # include Devise::Controllers::InternalHelpers
3
+
4
+ # GET /resource/sign_in
5
+ # def new
6
+ # @record = User.new
7
+ # end
8
+
9
+ # POST /resource/sign_in
10
+ # def create
11
+ # @record = warden.authenticate!(:scope => :user, :recall => "#{controller_path}#new")
12
+ # sign_in(user, @record)
13
+ # respond_with @record, :location => params[:return_to]
14
+ # end
15
+
16
+ # GET /resource/sign_out
17
+ # def destroy
18
+ # signed_in = signed_in?(resource_name)
19
+ # Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
20
+ # set_flash_message :notice, :signed_out if signed_in
21
+
22
+ # # We actually need to hardcode this, as Rails default responder doesn't
23
+ # # support returning empty response on GET request
24
+ # respond_to do |format|
25
+ # format.any(*navigational_formats) { redirect_to after_sign_out_path_for(resource_name) }
26
+ # format.all do
27
+ # method = "to_#{request_format}"
28
+ # text = {}.respond_to?(method) ? {}.send(method) : ""
29
+ # render :text => text, :status => :ok
30
+ # end
31
+ # end
32
+ # end
33
+
34
+ end
@@ -0,0 +1,24 @@
1
+ class Puffer::PufferUser < ActiveRecord::Base
2
+ self.abstract_class = true
3
+
4
+ attr_protected :password_digest
5
+
6
+ has_secure_password
7
+
8
+ validates :email, :uniqueness => true, :presence => true
9
+ validates :password, :presence => true, :length => {:minimum => 6}, :on => :create
10
+
11
+ def roles= value
12
+ value = value.split(',').map(&:strip).map(&:presence) if value.is_a?(String)
13
+ write_attribute(:roles, value.join(', '))
14
+ end
15
+
16
+ def roles_array
17
+ roles.split(',').map(&:strip).map(&:presence)
18
+ end
19
+
20
+ def has_role? role
21
+ roles_array.include?(role.to_s)
22
+ end
23
+
24
+ end
@@ -0,0 +1,3 @@
1
+ class PufferUser < Puffer::PufferUser
2
+
3
+ end
@@ -16,7 +16,7 @@
16
16
  <%= link_to t('puffer.logo'), admin_root_path %>
17
17
  </div>
18
18
  <%= yield :header %>
19
- <% if respond_to?(:current_user) && !current_user %>
19
+ <% if current_puffer_user %>
20
20
  <div class="logout">
21
21
  <%= link_to t('puffer.logout'), admin_session_url, :method => :delete %>
22
22
  </div>
@@ -1,4 +1,4 @@
1
- <%= form_for record, :url => puffer_session_path do |f| %>
1
+ <%= form_for record, :url => admin_session_path, :method => :post do |f| %>
2
2
  <ul class="form">
3
3
  <% create_fields.each do |field| -%>
4
4
  <li><%= f.puffer_field field %></li>
@@ -9,4 +9,3 @@
9
9
  <%= f.submit 'Login' %>
10
10
  </div>
11
11
  <% end %>
12
-
data/config/routes.rb CHANGED
@@ -1,8 +1,7 @@
1
- Puffer::Engine.routes.draw do
1
+ Rails.application.routes.draw do
2
2
 
3
3
  namespace :admin do
4
- root :to => 'dashboard#index'
5
- resource :session
4
+ resource :session, :only => [:new, :create, :destroy]
6
5
  end
7
6
 
8
7
  end
@@ -0,0 +1,11 @@
1
+ class CreatePufferUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :puffer_users do |t|
4
+ t.string :email
5
+ t.string :password_digest
6
+ t.string :roles
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,31 @@
1
+ module Puffer
2
+ module Controller
3
+ module Auth
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ helper_method :current_puffer_user
8
+ end
9
+
10
+ module InstanceMethods
11
+
12
+ def current_puffer_user
13
+ @current_puffer_user ||= super rescue PufferUser.find(session[:puffer_user_id]) if session[:puffer_user_id]
14
+ end
15
+
16
+ def require_puffer_user
17
+ unless has_puffer_access?(namespace)
18
+ redirect_to new_admin_session_url(:return_to => request.fullpath)
19
+ return false
20
+ end
21
+ end
22
+
23
+ def has_puffer_access? namespace
24
+ super rescue (current_puffer_user && current_puffer_user.has_role?(namespace))
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -6,12 +6,16 @@ module Puffer
6
6
  included do
7
7
  layout 'puffer'
8
8
  helper :puffer
9
- delegate :namespace, :model, :model_name, :to => 'self.class'
9
+ delegate :model, :model_name, :to => 'self.class'
10
10
  helper_method :namespace, :resource, :record, :records
11
11
  end
12
12
 
13
13
  module InstanceMethods
14
14
 
15
+ def namespace
16
+ params[:namespace] || self.class.namespace
17
+ end
18
+
15
19
  def resource
16
20
  @resource ||= Puffer::Resource.new params, self
17
21
  end
@@ -18,6 +18,7 @@ module Puffer
18
18
  include Puffer::Controller::Mutate
19
19
  include Puffer::Controller::Dsl
20
20
  include Puffer::Controller::Config
21
+ include Puffer::Controller::Auth
21
22
  end
22
23
  end
23
24
 
@@ -24,7 +24,7 @@ module Puffer
24
24
 
25
25
  included do
26
26
  initializer :"puffer.add_view_paths", :after => :add_view_paths do |app|
27
- Puffer::Component::Base.prepend_view_path paths["app/components"].existent
27
+ Puffer::Component::Base.prepend_view_path paths["app/components"].existent if paths["app/components"]
28
28
  end
29
29
  end
30
30
  end
@@ -25,7 +25,7 @@ module Puffer
25
25
 
26
26
  unless puffer[namespace]
27
27
  @scope[:module] = 'admin'
28
- root :to => 'dashboard#index'
28
+ root :to => 'dashboard#index', :namespace => namespace
29
29
  @scope[:module] = namespace
30
30
  end
31
31
 
data/puffer.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{puffer}
8
- s.version = "0.0.28"
8
+ s.version = "0.0.29"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{pyromaniac}]
12
- s.date = %q{2011-09-11}
12
+ s.date = %q{2011-09-12}
13
13
  s.description = %q{In Soviet Russia puffer admins you}
14
14
  s.email = %q{kinwizard@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -65,13 +65,18 @@ Gem::Specification.new do |s|
65
65
  "app/components/text/form.html.erb",
66
66
  "app/components/text_component.rb",
67
67
  "app/controllers/admin/dashboard_controller.rb",
68
+ "app/controllers/admin/puffer_users_controller.rb",
68
69
  "app/controllers/admin/sessions_controller.rb",
69
70
  "app/controllers/puffer/base.rb",
70
71
  "app/controllers/puffer/dashboard_base.rb",
72
+ "app/controllers/puffer/puffer_users_base.rb",
71
73
  "app/controllers/puffer/sessions_base.rb",
74
+ "app/controllers/puffer/sessions_devise_base.rb",
72
75
  "app/controllers/puffer/tree_base.rb",
73
76
  "app/helpers/puffer_helper.rb",
74
77
  "app/helpers/puffer_tree_helper.rb",
78
+ "app/models/puffer/puffer_user.rb",
79
+ "app/models/puffer_user.rb",
75
80
  "app/views/layouts/puffer.html.erb",
76
81
  "app/views/layouts/puffer_base.html.erb",
77
82
  "app/views/layouts/puffer_dashboard.html.erb",
@@ -89,6 +94,7 @@ Gem::Specification.new do |s|
89
94
  "app/views/puffer/tree_base/tree.html.erb",
90
95
  "config/locales/puffer.yml",
91
96
  "config/routes.rb",
97
+ "db/migrate/20110912095647_create_puffer_users.rb",
92
98
  "lib/generators/puffer/component/USAGE",
93
99
  "lib/generators/puffer/component/component_generator.rb",
94
100
  "lib/generators/puffer/component/templates/component.rb",
@@ -99,6 +105,7 @@ Gem::Specification.new do |s|
99
105
  "lib/puffer.rb",
100
106
  "lib/puffer/component.rb",
101
107
  "lib/puffer/controller/actions.rb",
108
+ "lib/puffer/controller/auth.rb",
102
109
  "lib/puffer/controller/config.rb",
103
110
  "lib/puffer/controller/dsl.rb",
104
111
  "lib/puffer/controller/mutate.rb",
@@ -137,7 +144,6 @@ Gem::Specification.new do |s|
137
144
  "spec/dummy/app/controllers/admin/news_controller.rb",
138
145
  "spec/dummy/app/controllers/admin/posts_controller.rb",
139
146
  "spec/dummy/app/controllers/admin/profiles_controller.rb",
140
- "spec/dummy/app/controllers/admin/sessions_controller.rb",
141
147
  "spec/dummy/app/controllers/admin/tagged_posts_controller.rb",
142
148
  "spec/dummy/app/controllers/admin/tags_controller.rb",
143
149
  "spec/dummy/app/controllers/admin/users_controller.rb",
@@ -165,11 +171,13 @@ Gem::Specification.new do |s|
165
171
  "spec/dummy/config/environments/production.rb",
166
172
  "spec/dummy/config/environments/test.rb",
167
173
  "spec/dummy/config/initializers/backtrace_silencers.rb",
174
+ "spec/dummy/config/initializers/devise.rb",
168
175
  "spec/dummy/config/initializers/inflections.rb",
169
176
  "spec/dummy/config/initializers/mime_types.rb",
170
177
  "spec/dummy/config/initializers/secret_token.rb",
171
178
  "spec/dummy/config/initializers/session_store.rb",
172
179
  "spec/dummy/config/initializers/wrap_parameters.rb",
180
+ "spec/dummy/config/locales/devise.en.yml",
173
181
  "spec/dummy/config/locales/en.yml",
174
182
  "spec/dummy/config/mongoid.yml",
175
183
  "spec/dummy/config/routes.rb",
@@ -182,6 +190,7 @@ Gem::Specification.new do |s|
182
190
  "spec/dummy/db/migrate/20101011160326_create_taggings.rb",
183
191
  "spec/dummy/db/migrate/20110107082706_create_friendships.rb",
184
192
  "spec/dummy/db/migrate/20110301072545_create_news.rb",
193
+ "spec/dummy/db/migrate/20110912114129_create_puffer_users.rb",
185
194
  "spec/dummy/db/schema.rb",
186
195
  "spec/dummy/db/seeds.rb",
187
196
  "spec/dummy/public/404.html",
@@ -221,6 +230,7 @@ Gem::Specification.new do |s|
221
230
  s.add_development_dependency(%q<sqlite3>, [">= 0"])
222
231
  s.add_development_dependency(%q<mongoid>, [">= 0"])
223
232
  s.add_development_dependency(%q<bson_ext>, [">= 0"])
233
+ s.add_development_dependency(%q<devise>, [">= 0"])
224
234
  s.add_development_dependency(%q<rspec-rails>, [">= 0"])
225
235
  s.add_development_dependency(%q<capybara>, [">= 0"])
226
236
  s.add_development_dependency(%q<database_cleaner>, [">= 0"])
@@ -238,6 +248,7 @@ Gem::Specification.new do |s|
238
248
  s.add_dependency(%q<sqlite3>, [">= 0"])
239
249
  s.add_dependency(%q<mongoid>, [">= 0"])
240
250
  s.add_dependency(%q<bson_ext>, [">= 0"])
251
+ s.add_dependency(%q<devise>, [">= 0"])
241
252
  s.add_dependency(%q<rspec-rails>, [">= 0"])
242
253
  s.add_dependency(%q<capybara>, [">= 0"])
243
254
  s.add_dependency(%q<database_cleaner>, [">= 0"])
@@ -256,6 +267,7 @@ Gem::Specification.new do |s|
256
267
  s.add_dependency(%q<sqlite3>, [">= 0"])
257
268
  s.add_dependency(%q<mongoid>, [">= 0"])
258
269
  s.add_dependency(%q<bson_ext>, [">= 0"])
270
+ s.add_dependency(%q<devise>, [">= 0"])
259
271
  s.add_dependency(%q<rspec-rails>, [">= 0"])
260
272
  s.add_dependency(%q<capybara>, [">= 0"])
261
273
  s.add_dependency(%q<database_cleaner>, [">= 0"])
@@ -5,6 +5,7 @@ require 'rails/all'
5
5
  Bundler.require
6
6
  require 'puffer'
7
7
  require 'nested_set'
8
+ require 'devise'
8
9
 
9
10
  module Dummy
10
11
  class Application < Rails::Application
@@ -0,0 +1,211 @@
1
+ # Use this hook to configure devise mailer, warden hooks and so forth. The first
2
+ # four configuration values can also be set straight in your models.
3
+ Devise.setup do |config|
4
+ # ==> Mailer Configuration
5
+ # Configure the e-mail address which will be shown in Devise::Mailer,
6
+ # note that it will be overwritten if you use your own mailer class with default "from" parameter.
7
+ config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"
8
+
9
+ # Configure the class responsible to send e-mails.
10
+ # config.mailer = "Devise::Mailer"
11
+
12
+ # ==> ORM configuration
13
+ # Load and configure the ORM. Supports :active_record (default) and
14
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
15
+ # available as additional gems.
16
+ require 'devise/orm/mongoid'
17
+
18
+ # ==> Configuration for any authentication mechanism
19
+ # Configure which keys are used when authenticating a user. The default is
20
+ # just :email. You can configure it to use [:username, :subdomain], so for
21
+ # authenticating a user, both parameters are required. Remember that those
22
+ # parameters are used only when authenticating and not when retrieving from
23
+ # session. If you need permissions, you should implement that in a before filter.
24
+ # You can also supply a hash where the value is a boolean determining whether
25
+ # or not authentication should be aborted when the value is not present.
26
+ # config.authentication_keys = [ :email ]
27
+
28
+ # Configure parameters from the request object used for authentication. Each entry
29
+ # given should be a request method and it will automatically be passed to the
30
+ # find_for_authentication method and considered in your model lookup. For instance,
31
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
32
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
33
+ # config.request_keys = []
34
+
35
+ # Configure which authentication keys should be case-insensitive.
36
+ # These keys will be downcased upon creating or modifying a user and when used
37
+ # to authenticate or find a user. Default is :email.
38
+ config.case_insensitive_keys = [ :email ]
39
+
40
+ # Configure which authentication keys should have whitespace stripped.
41
+ # These keys will have whitespace before and after removed upon creating or
42
+ # modifying a user and when used to authenticate or find a user. Default is :email.
43
+ config.strip_whitespace_keys = [ :email ]
44
+
45
+ # Tell if authentication through request.params is enabled. True by default.
46
+ # config.params_authenticatable = true
47
+
48
+ # Tell if authentication through HTTP Basic Auth is enabled. False by default.
49
+ # config.http_authenticatable = false
50
+
51
+ # If http headers should be returned for AJAX requests. True by default.
52
+ # config.http_authenticatable_on_xhr = true
53
+
54
+ # The realm used in Http Basic Authentication. "Application" by default.
55
+ # config.http_authentication_realm = "Application"
56
+
57
+ # It will change confirmation, password recovery and other workflows
58
+ # to behave the same regardless if the e-mail provided was right or wrong.
59
+ # Does not affect registerable.
60
+ # config.paranoid = true
61
+
62
+ # ==> Configuration for :database_authenticatable
63
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
64
+ # using other encryptors, it sets how many times you want the password re-encrypted.
65
+ #
66
+ # Limiting the stretches to just one in testing will increase the performance of
67
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
68
+ # a value less than 10 in other environments.
69
+ config.stretches = Rails.env.test? ? 1 : 10
70
+
71
+ # Setup a pepper to generate the encrypted password.
72
+ # config.pepper = "80976e8142b5962f4ac9198f4b805704bec95eee4fad0a209d6996c92e2e5552b134d9c67ba7e53af6b0f3b8a97f929d2aa3195bc3842faeb3b6435703855e8d"
73
+
74
+ # ==> Configuration for :confirmable
75
+ # The time you want to give your user to confirm his account. During this time
76
+ # he will be able to access your application without confirming. Default is 0.days
77
+ # When confirm_within is zero, the user won't be able to sign in without confirming.
78
+ # You can use this to let your user access some features of your application
79
+ # without confirming the account, but blocking it after a certain period
80
+ # (ie 2 days).
81
+ # config.confirm_within = 2.days
82
+
83
+ # Defines which key will be used when confirming an account
84
+ # config.confirmation_keys = [ :email ]
85
+
86
+ # ==> Configuration for :rememberable
87
+ # The time the user will be remembered without asking for credentials again.
88
+ # config.remember_for = 2.weeks
89
+
90
+ # If true, a valid remember token can be re-used between multiple browsers.
91
+ # config.remember_across_browsers = true
92
+
93
+ # If true, extends the user's remember period when remembered via cookie.
94
+ # config.extend_remember_period = false
95
+
96
+ # If true, uses the password salt as remember token. This should be turned
97
+ # to false if you are not using database authenticatable.
98
+ config.use_salt_as_remember_token = true
99
+
100
+ # Options to be passed to the created cookie. For instance, you can set
101
+ # :secure => true in order to force SSL only cookies.
102
+ # config.cookie_options = {}
103
+
104
+ # ==> Configuration for :validatable
105
+ # Range for password length. Default is 6..128.
106
+ # config.password_length = 6..128
107
+
108
+ # Email regex used to validate email formats. It simply asserts that
109
+ # an one (and only one) @ exists in the given string. This is mainly
110
+ # to give user feedback and not to assert the e-mail validity.
111
+ # config.email_regexp = /\A[^@]+@[^@]+\z/
112
+
113
+ # ==> Configuration for :timeoutable
114
+ # The time you want to timeout the user session without activity. After this
115
+ # time the user will be asked for credentials again. Default is 30 minutes.
116
+ # config.timeout_in = 30.minutes
117
+
118
+ # ==> Configuration for :lockable
119
+ # Defines which strategy will be used to lock an account.
120
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
121
+ # :none = No lock strategy. You should handle locking by yourself.
122
+ # config.lock_strategy = :failed_attempts
123
+
124
+ # Defines which key will be used when locking and unlocking an account
125
+ # config.unlock_keys = [ :email ]
126
+
127
+ # Defines which strategy will be used to unlock an account.
128
+ # :email = Sends an unlock link to the user email
129
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
130
+ # :both = Enables both strategies
131
+ # :none = No unlock strategy. You should handle unlocking by yourself.
132
+ # config.unlock_strategy = :both
133
+
134
+ # Number of authentication tries before locking an account if lock_strategy
135
+ # is failed attempts.
136
+ # config.maximum_attempts = 20
137
+
138
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
139
+ # config.unlock_in = 1.hour
140
+
141
+ # ==> Configuration for :recoverable
142
+ #
143
+ # Defines which key will be used when recovering the password for an account
144
+ # config.reset_password_keys = [ :email ]
145
+
146
+ # Time interval you can reset your password with a reset password key.
147
+ # Don't put a too small interval or your users won't have the time to
148
+ # change their passwords.
149
+ config.reset_password_within = 2.hours
150
+
151
+ # ==> Configuration for :encryptable
152
+ # Allow you to use another encryption algorithm besides bcrypt (default). You can use
153
+ # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
154
+ # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
155
+ # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
156
+ # REST_AUTH_SITE_KEY to pepper)
157
+ # config.encryptor = :sha512
158
+
159
+ # ==> Configuration for :token_authenticatable
160
+ # Defines name of the authentication token params key
161
+ # config.token_authentication_key = :auth_token
162
+
163
+ # If true, authentication through token does not store user in session and needs
164
+ # to be supplied on each request. Useful if you are using the token as API token.
165
+ # config.stateless_token = false
166
+
167
+ # ==> Scopes configuration
168
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
169
+ # "users/sessions/new". It's turned off by default because it's slower if you
170
+ # are using only default views.
171
+ # config.scoped_views = false
172
+
173
+ # Configure the default scope given to Warden. By default it's the first
174
+ # devise role declared in your routes (usually :user).
175
+ # config.default_scope = :user
176
+
177
+ # Configure sign_out behavior.
178
+ # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
179
+ # The default is true, which means any logout action will sign out all active scopes.
180
+ # config.sign_out_all_scopes = true
181
+
182
+ # ==> Navigation configuration
183
+ # Lists the formats that should be treated as navigational. Formats like
184
+ # :html, should redirect to the sign in page when the user does not have
185
+ # access, but formats like :xml or :json, should return 401.
186
+ #
187
+ # If you have any extra navigational formats, like :iphone or :mobile, you
188
+ # should add them to the navigational formats lists.
189
+ #
190
+ # The :"*/*" and "*/*" formats below is required to match Internet
191
+ # Explorer requests.
192
+ # config.navigational_formats = [:"*/*", "*/*", :html]
193
+
194
+ # The default HTTP method used to sign out a resource. Default is :delete.
195
+ config.sign_out_via = :delete
196
+
197
+ # ==> OmniAuth
198
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
199
+ # up on your models and hooks.
200
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
201
+
202
+ # ==> Warden configuration
203
+ # If you want to use other strategies, that are not supported by Devise, or
204
+ # change the failure app, you can configure them inside the config.warden block.
205
+ #
206
+ # config.warden do |manager|
207
+ # manager.failure_app = AnotherApp
208
+ # manager.intercept_401 = false
209
+ # manager.default_strategies(:scope => :user).unshift :some_external_strategy
210
+ # end
211
+ end
@@ -0,0 +1,58 @@
1
+ # Additional translations at http://github.com/plataformatec/devise/wiki/I18n
2
+
3
+ en:
4
+ errors:
5
+ messages:
6
+ expired: "has expired, please request a new one"
7
+ not_found: "not found"
8
+ already_confirmed: "was already confirmed, please try signing in"
9
+ not_locked: "was not locked"
10
+ not_saved:
11
+ one: "1 error prohibited this %{resource} from being saved:"
12
+ other: "%{count} errors prohibited this %{resource} from being saved:"
13
+
14
+ devise:
15
+ failure:
16
+ already_authenticated: 'You are already signed in.'
17
+ unauthenticated: 'You need to sign in or sign up before continuing.'
18
+ unconfirmed: 'You have to confirm your account before continuing.'
19
+ locked: 'Your account is locked.'
20
+ invalid: 'Invalid email or password.'
21
+ invalid_token: 'Invalid authentication token.'
22
+ timeout: 'Your session expired, please sign in again to continue.'
23
+ inactive: 'Your account was not activated yet.'
24
+ sessions:
25
+ signed_in: 'Signed in successfully.'
26
+ signed_out: 'Signed out successfully.'
27
+ passwords:
28
+ send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
29
+ updated: 'Your password was changed successfully. You are now signed in.'
30
+ updated_not_active: 'Your password was changed successfully.'
31
+ send_paranoid_instructions: "If your e-mail exists on our database, you will receive a password recovery link on your e-mail"
32
+ confirmations:
33
+ send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
34
+ send_paranoid_instructions: 'If your e-mail exists on our database, you will receive an email with instructions about how to confirm your account in a few minutes.'
35
+ confirmed: 'Your account was successfully confirmed. You are now signed in.'
36
+ registrations:
37
+ signed_up: 'Welcome! You have signed up successfully.'
38
+ inactive_signed_up: 'You have signed up successfully. However, we could not sign you in because your account is %{reason}.'
39
+ updated: 'You updated your account successfully.'
40
+ destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
41
+ reasons:
42
+ inactive: 'inactive'
43
+ unconfirmed: 'unconfirmed'
44
+ locked: 'locked'
45
+ unlocks:
46
+ send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
47
+ unlocked: 'Your account was successfully unlocked. You are now signed in.'
48
+ send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.'
49
+ omniauth_callbacks:
50
+ success: 'Successfully authorized from %{kind} account.'
51
+ failure: 'Could not authorize you from %{kind} because "%{reason}".'
52
+ mailer:
53
+ confirmation_instructions:
54
+ subject: 'Confirmation instructions'
55
+ reset_password_instructions:
56
+ subject: 'Reset password instructions'
57
+ unlock_instructions:
58
+ subject: 'Unlock Instructions'
@@ -26,6 +26,7 @@ Dummy::Application.routes.draw do
26
26
  resources :posts
27
27
  end
28
28
  resources :news
29
+ resources :puffer_users
29
30
  end
30
31
 
31
32
  namespace :orms do
@@ -0,0 +1,11 @@
1
+ class CreatePufferUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :puffer_users do |t|
4
+ t.string :email
5
+ t.string :password_digest
6
+ t.string :roles
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended to check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(:version => 20110301072545) do
14
+ ActiveRecord::Schema.define(:version => 20110912114129) do
15
15
 
16
16
  create_table "categories", :force => true do |t|
17
17
  t.string "title"
@@ -66,6 +66,14 @@ ActiveRecord::Schema.define(:version => 20110301072545) do
66
66
  t.datetime "updated_at"
67
67
  end
68
68
 
69
+ create_table "puffer_users", :force => true do |t|
70
+ t.string "email"
71
+ t.string "password_digest"
72
+ t.string "roles"
73
+ t.datetime "created_at"
74
+ t.datetime "updated_at"
75
+ end
76
+
69
77
  create_table "taggings", :force => true do |t|
70
78
  t.string "name"
71
79
  t.integer "tag_id"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puffer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.28
4
+ version: 0.0.29
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-11 00:00:00.000000000Z
12
+ date: 2011-09-12 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &10916560 !ruby/object:Gem::Requirement
16
+ requirement: &13086640 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.1.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *10916560
24
+ version_requirements: *13086640
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: kaminari
27
- requirement: &10916000 !ruby/object:Gem::Requirement
27
+ requirement: &13086020 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *10916000
35
+ version_requirements: *13086020
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: orm_adapter
38
- requirement: &10915480 !ruby/object:Gem::Requirement
38
+ requirement: &13085220 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *10915480
46
+ version_requirements: *13085220
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sqlite3
49
- requirement: &10914960 !ruby/object:Gem::Requirement
49
+ requirement: &13084320 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *10914960
57
+ version_requirements: *13084320
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: mongoid
60
- requirement: &10914380 !ruby/object:Gem::Requirement
60
+ requirement: &13083160 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *10914380
68
+ version_requirements: *13083160
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bson_ext
71
- requirement: &10913880 !ruby/object:Gem::Requirement
71
+ requirement: &13081880 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,21 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *10913880
79
+ version_requirements: *13081880
80
+ - !ruby/object:Gem::Dependency
81
+ name: devise
82
+ requirement: &13077780 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *13077780
80
91
  - !ruby/object:Gem::Dependency
81
92
  name: rspec-rails
82
- requirement: &10913380 !ruby/object:Gem::Requirement
93
+ requirement: &13076740 !ruby/object:Gem::Requirement
83
94
  none: false
84
95
  requirements:
85
96
  - - ! '>='
@@ -87,10 +98,10 @@ dependencies:
87
98
  version: '0'
88
99
  type: :development
89
100
  prerelease: false
90
- version_requirements: *10913380
101
+ version_requirements: *13076740
91
102
  - !ruby/object:Gem::Dependency
92
103
  name: capybara
93
- requirement: &10912880 !ruby/object:Gem::Requirement
104
+ requirement: &13075980 !ruby/object:Gem::Requirement
94
105
  none: false
95
106
  requirements:
96
107
  - - ! '>='
@@ -98,10 +109,10 @@ dependencies:
98
109
  version: '0'
99
110
  type: :development
100
111
  prerelease: false
101
- version_requirements: *10912880
112
+ version_requirements: *13075980
102
113
  - !ruby/object:Gem::Dependency
103
114
  name: database_cleaner
104
- requirement: &10912260 !ruby/object:Gem::Requirement
115
+ requirement: &13075140 !ruby/object:Gem::Requirement
105
116
  none: false
106
117
  requirements:
107
118
  - - ! '>='
@@ -109,10 +120,10 @@ dependencies:
109
120
  version: '0'
110
121
  type: :development
111
122
  prerelease: false
112
- version_requirements: *10912260
123
+ version_requirements: *13075140
113
124
  - !ruby/object:Gem::Dependency
114
125
  name: guard
115
- requirement: &10911680 !ruby/object:Gem::Requirement
126
+ requirement: &13074380 !ruby/object:Gem::Requirement
116
127
  none: false
117
128
  requirements:
118
129
  - - ! '>='
@@ -120,10 +131,10 @@ dependencies:
120
131
  version: '0'
121
132
  type: :development
122
133
  prerelease: false
123
- version_requirements: *10911680
134
+ version_requirements: *13074380
124
135
  - !ruby/object:Gem::Dependency
125
136
  name: libnotify
126
- requirement: &10911140 !ruby/object:Gem::Requirement
137
+ requirement: &13073500 !ruby/object:Gem::Requirement
127
138
  none: false
128
139
  requirements:
129
140
  - - ! '>='
@@ -131,10 +142,10 @@ dependencies:
131
142
  version: '0'
132
143
  type: :development
133
144
  prerelease: false
134
- version_requirements: *10911140
145
+ version_requirements: *13073500
135
146
  - !ruby/object:Gem::Dependency
136
147
  name: guard-rspec
137
- requirement: &10910620 !ruby/object:Gem::Requirement
148
+ requirement: &13072780 !ruby/object:Gem::Requirement
138
149
  none: false
139
150
  requirements:
140
151
  - - ! '>='
@@ -142,10 +153,10 @@ dependencies:
142
153
  version: '0'
143
154
  type: :development
144
155
  prerelease: false
145
- version_requirements: *10910620
156
+ version_requirements: *13072780
146
157
  - !ruby/object:Gem::Dependency
147
158
  name: forgery
148
- requirement: &10910100 !ruby/object:Gem::Requirement
159
+ requirement: &13072080 !ruby/object:Gem::Requirement
149
160
  none: false
150
161
  requirements:
151
162
  - - ! '>='
@@ -153,10 +164,10 @@ dependencies:
153
164
  version: '0'
154
165
  type: :development
155
166
  prerelease: false
156
- version_requirements: *10910100
167
+ version_requirements: *13072080
157
168
  - !ruby/object:Gem::Dependency
158
169
  name: fabrication
159
- requirement: &10909540 !ruby/object:Gem::Requirement
170
+ requirement: &13071220 !ruby/object:Gem::Requirement
160
171
  none: false
161
172
  requirements:
162
173
  - - ! '>='
@@ -164,10 +175,10 @@ dependencies:
164
175
  version: '0'
165
176
  type: :development
166
177
  prerelease: false
167
- version_requirements: *10909540
178
+ version_requirements: *13071220
168
179
  - !ruby/object:Gem::Dependency
169
180
  name: jeweler
170
- requirement: &10908960 !ruby/object:Gem::Requirement
181
+ requirement: &13070440 !ruby/object:Gem::Requirement
171
182
  none: false
172
183
  requirements:
173
184
  - - ! '>='
@@ -175,10 +186,10 @@ dependencies:
175
186
  version: '0'
176
187
  type: :development
177
188
  prerelease: false
178
- version_requirements: *10908960
189
+ version_requirements: *13070440
179
190
  - !ruby/object:Gem::Dependency
180
191
  name: nested_set
181
- requirement: &10908460 !ruby/object:Gem::Requirement
192
+ requirement: &13067140 !ruby/object:Gem::Requirement
182
193
  none: false
183
194
  requirements:
184
195
  - - ! '>='
@@ -186,7 +197,7 @@ dependencies:
186
197
  version: '0'
187
198
  type: :development
188
199
  prerelease: false
189
- version_requirements: *10908460
200
+ version_requirements: *13067140
190
201
  description: In Soviet Russia puffer admins you
191
202
  email: kinwizard@gmail.com
192
203
  executables: []
@@ -243,13 +254,18 @@ files:
243
254
  - app/components/text/form.html.erb
244
255
  - app/components/text_component.rb
245
256
  - app/controllers/admin/dashboard_controller.rb
257
+ - app/controllers/admin/puffer_users_controller.rb
246
258
  - app/controllers/admin/sessions_controller.rb
247
259
  - app/controllers/puffer/base.rb
248
260
  - app/controllers/puffer/dashboard_base.rb
261
+ - app/controllers/puffer/puffer_users_base.rb
249
262
  - app/controllers/puffer/sessions_base.rb
263
+ - app/controllers/puffer/sessions_devise_base.rb
250
264
  - app/controllers/puffer/tree_base.rb
251
265
  - app/helpers/puffer_helper.rb
252
266
  - app/helpers/puffer_tree_helper.rb
267
+ - app/models/puffer/puffer_user.rb
268
+ - app/models/puffer_user.rb
253
269
  - app/views/layouts/puffer.html.erb
254
270
  - app/views/layouts/puffer_base.html.erb
255
271
  - app/views/layouts/puffer_dashboard.html.erb
@@ -267,6 +283,7 @@ files:
267
283
  - app/views/puffer/tree_base/tree.html.erb
268
284
  - config/locales/puffer.yml
269
285
  - config/routes.rb
286
+ - db/migrate/20110912095647_create_puffer_users.rb
270
287
  - lib/generators/puffer/component/USAGE
271
288
  - lib/generators/puffer/component/component_generator.rb
272
289
  - lib/generators/puffer/component/templates/component.rb
@@ -277,6 +294,7 @@ files:
277
294
  - lib/puffer.rb
278
295
  - lib/puffer/component.rb
279
296
  - lib/puffer/controller/actions.rb
297
+ - lib/puffer/controller/auth.rb
280
298
  - lib/puffer/controller/config.rb
281
299
  - lib/puffer/controller/dsl.rb
282
300
  - lib/puffer/controller/mutate.rb
@@ -315,7 +333,6 @@ files:
315
333
  - spec/dummy/app/controllers/admin/news_controller.rb
316
334
  - spec/dummy/app/controllers/admin/posts_controller.rb
317
335
  - spec/dummy/app/controllers/admin/profiles_controller.rb
318
- - spec/dummy/app/controllers/admin/sessions_controller.rb
319
336
  - spec/dummy/app/controllers/admin/tagged_posts_controller.rb
320
337
  - spec/dummy/app/controllers/admin/tags_controller.rb
321
338
  - spec/dummy/app/controllers/admin/users_controller.rb
@@ -343,11 +360,13 @@ files:
343
360
  - spec/dummy/config/environments/production.rb
344
361
  - spec/dummy/config/environments/test.rb
345
362
  - spec/dummy/config/initializers/backtrace_silencers.rb
363
+ - spec/dummy/config/initializers/devise.rb
346
364
  - spec/dummy/config/initializers/inflections.rb
347
365
  - spec/dummy/config/initializers/mime_types.rb
348
366
  - spec/dummy/config/initializers/secret_token.rb
349
367
  - spec/dummy/config/initializers/session_store.rb
350
368
  - spec/dummy/config/initializers/wrap_parameters.rb
369
+ - spec/dummy/config/locales/devise.en.yml
351
370
  - spec/dummy/config/locales/en.yml
352
371
  - spec/dummy/config/mongoid.yml
353
372
  - spec/dummy/config/routes.rb
@@ -360,6 +379,7 @@ files:
360
379
  - spec/dummy/db/migrate/20101011160326_create_taggings.rb
361
380
  - spec/dummy/db/migrate/20110107082706_create_friendships.rb
362
381
  - spec/dummy/db/migrate/20110301072545_create_news.rb
382
+ - spec/dummy/db/migrate/20110912114129_create_puffer_users.rb
363
383
  - spec/dummy/db/schema.rb
364
384
  - spec/dummy/db/seeds.rb
365
385
  - spec/dummy/public/404.html
@@ -397,7 +417,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
397
417
  version: '0'
398
418
  segments:
399
419
  - 0
400
- hash: 2497691897434957664
420
+ hash: 2115184078820805402
401
421
  required_rubygems_version: !ruby/object:Gem::Requirement
402
422
  none: false
403
423
  requirements:
@@ -1,16 +0,0 @@
1
- class Admin::SessionsController < Puffer::SessionsBase
2
-
3
- def new
4
- @record = User.new
5
- end
6
-
7
- def create
8
- record = User.new
9
- respond_with record
10
- end
11
-
12
- def destroy
13
-
14
- end
15
-
16
- end