fullstack-admin 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -16,7 +16,6 @@ gem "plupload-rails"
16
16
  gem "has-attached", '~> 0.2.4'
17
17
 
18
18
  gem 'bootstrap-datepicker-rails'
19
- gem 'sorcery'
20
19
 
21
20
  group :development do
22
21
  gem "jeweler"
data/Gemfile.lock CHANGED
@@ -85,8 +85,6 @@ GEM
85
85
  facebox-rails (0.1.2)
86
86
  railties (~> 3.0)
87
87
  thor (~> 0.14)
88
- faraday (0.8.4)
89
- multipart-post (~> 1.1)
90
88
  flash_cookie_session (1.1.3)
91
89
  rails (~> 3.0)
92
90
  formtastic (2.2.1)
@@ -131,7 +129,6 @@ GEM
131
129
  httparty (0.9.0)
132
130
  multi_json (~> 1.0)
133
131
  multi_xml
134
- httpauth (0.2.0)
135
132
  i18n (0.6.0)
136
133
  jeweler (1.8.4)
137
134
  bundler (~> 1.0)
@@ -166,14 +163,8 @@ GEM
166
163
  rails
167
164
  multi_json (1.3.6)
168
165
  multi_xml (0.5.1)
169
- multipart-post (1.1.5)
170
166
  net-ssh (2.5.2)
171
167
  nokogiri (1.5.5)
172
- oauth (0.4.7)
173
- oauth2 (0.6.1)
174
- faraday (~> 0.7)
175
- httpauth (~> 0.1)
176
- multi_json (~> 1.3)
177
168
  orm_adapter (0.4.0)
178
169
  paperclip (3.2.0)
179
170
  activemodel (>= 3.0.0)
@@ -229,10 +220,6 @@ GEM
229
220
  remotipart (1.0.2)
230
221
  resource-presentation-helpers (0.1.1)
231
222
  rails
232
- sorcery (0.7.13)
233
- bcrypt-ruby (~> 3.0.0)
234
- oauth (~> 0.4.4)
235
- oauth2 (~> 0.6.0)
236
223
  sprockets (2.1.3)
237
224
  hike (~> 1.2)
238
225
  rack (~> 1.0)
@@ -267,4 +254,3 @@ DEPENDENCIES
267
254
  meta_search
268
255
  plupload-rails
269
256
  rails (~> 3.2)
270
- sorcery
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -1,15 +1,9 @@
1
1
  class Admin::BaseController < ApplicationController
2
- before_filter :require_login
2
+ before_filter :authenticate_administrator!
3
3
  before_filter :fetch_current_resource
4
4
 
5
5
  layout 'admin'
6
-
7
- protected
8
-
9
- def not_authenticated
10
- redirect_to new_admin_session_url, :alert => "First login to access this page."
11
- end
12
-
6
+
13
7
  class << self
14
8
  def responder
15
9
  ::Admin::Responder
@@ -28,7 +22,7 @@ class Admin::BaseController < ApplicationController
28
22
 
29
23
 
30
24
  def subject
31
- @subject ||= ::Admin::SubjectModelAdapter.new(current_user)
25
+ @subject ||= ::Admin::SubjectModelAdapter.new(current_administrator)
32
26
  end
33
27
 
34
28
  def current_resource_class
@@ -1,27 +1,10 @@
1
- class Admin::SessionsController < ApplicationController
1
+ class Admin::SessionsController < Devise::SessionsController
2
2
  layout 'login'
3
3
 
4
4
  def new
5
- @user = Superuser.new
5
+ super
6
6
  end
7
7
 
8
- def create
9
- respond_to do |format|
10
- if @user = login(params[:username],params[:password])
11
- format.html { redirect_back_or_to("/", :notice => I18n.t("signed_in", :scope => "fullstack.admin", :default => 'Signed in successfully.')) }
12
- format.xml { render :xml => @user, :status => :created, :location => @user }
13
- else
14
- format.html { flash.now[:alert] = I18n.t("login_failed", :scope => "fullstack.admin", :default => 'Login failed.'); render :action => "new" }
15
- format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
16
- end
17
- end
18
- end
19
-
20
- def destroy
21
- logout
22
- redirect_to("/", :notice => I18n.t("signed_out", :scope => "fullstack.admin", :default => 'Signed out successfully.'))
23
- end
24
-
25
8
  end
26
9
 
27
10
 
@@ -0,0 +1,28 @@
1
+ class Administrator < ActiveRecord::Base
2
+
3
+ ## Database authenticatable
4
+ field :username, :null => false, :default => "", :index => { :unique => true }
5
+ field :email
6
+ field :encrypted_password, :null => false, :default => ""
7
+ timestamps
8
+
9
+ ## Trackable
10
+ field :sign_in_count, :as => :integer, :default => 0
11
+ field :current_sign_in_at, :as => :datetime
12
+ field :last_sign_in_at, :as => :datetime
13
+ field :current_sign_in_ip
14
+ field :last_sign_in_ip
15
+
16
+ ## Lockable
17
+ field :failed_attempts, :integer, :default => 0
18
+ field :unlock_token
19
+ field :locked_at, :datetime
20
+
21
+ devise :database_authenticatable, :validatable, :lockable, :trackable, :authentication_keys => [:username]
22
+ attr_accessible :username, :email, :password, :password_confirmation
23
+
24
+ def has_role?(role)
25
+ %w(administrator logged_in).include?( role.try(:to_s) ) ? true : false
26
+ end
27
+
28
+ end
@@ -9,7 +9,7 @@
9
9
  </li>
10
10
 
11
11
  <%= dropdown_nav_item t('fullstack.admin.account', :default => "Account"), :icon => "user", :"icon_color" => :white do %>
12
- <%= nav_item t('fullstack.admin.logout', :default => "Logout"), admin_sessions_path, :method => :delete %>
12
+ <%= nav_item t('fullstack.admin.logout', :default => "Logout"), destroy_administrator_session_path, :method => :delete %>
13
13
  <% end %>
14
14
  <% end %>
15
15
 
@@ -1,4 +1,8 @@
1
- <%= form_tag admin_sessions_path, :method => :post, :class => "login-box" do %>
1
+ <% if resource.errors.any? %>
2
+ <%= resource.errors.inspect %>
3
+ <% end %>
4
+
5
+ <%= form_for( resource, :as => resource_name, :url => session_path(resource_name), :html => {:class => "login-box"} ) do |f| %>
2
6
  <div class="login-box-header">
3
7
  Login
4
8
  </div>
@@ -18,12 +22,12 @@
18
22
 
19
23
  <div class="input-prepend">
20
24
  <span class="add-on"><i class="icon-user"></i></span>
21
- <%= text_field_tag :username, nil, :placeholder => I18n.t("username", :scope => "helpers.label", :default => "Username") %>
25
+ <%= f.text_field :username, :placeholder => I18n.t("username", :scope => "helpers.label", :default => "Username") %>
22
26
  </div>
23
27
 
24
28
  <div class="input-prepend">
25
29
  <span class="add-on"><i class="icon-lock"></i></span>
26
- <%= password_field_tag :password, nil, :placeholder => I18n.t("password", :scope => "helpers.label", :default => "Password") %>
30
+ <%= f.password_field :password, :placeholder => I18n.t("password", :scope => "helpers.label", :default => "Password") %>
27
31
  </div>
28
32
  </div>
29
33
 
data/config/routes.rb CHANGED
@@ -1,12 +1,11 @@
1
1
  Rails.application.routes.draw do
2
2
 
3
3
  mount Ckeditor::Engine => '/ckeditor'
4
-
4
+
5
+ devise_for :administrators, :controllers => { :sessions => "admin/sessions" }
5
6
  namespace :admin do
6
- resources :sessions, :only => [:new, :create] do
7
- match :destroy, :via => :delete, :on => :collection
8
- end
9
-
7
+
8
+
10
9
  resources :positionables, :only => [:index] do
11
10
  post :sort, :on => :collection
12
11
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "fullstack-admin"
8
- s.version = "0.2.2"
8
+ s.version = "0.2.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["mcasimir"]
12
- s.date = "2012-11-05"
12
+ s.date = "2012-11-06"
13
13
  s.description = "Administration interface framework for fullstack"
14
14
  s.email = "maurizio.cas@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -969,6 +969,7 @@ Gem::Specification.new do |s|
969
969
  "app/inputs/taglist_input.rb",
970
970
  "app/inputs/tags_input.rb",
971
971
  "app/inputs/text_input.rb",
972
+ "app/models/administrator.rb",
972
973
  "app/models/authenticatable.rb",
973
974
  "app/models/ckeditor/asset.rb",
974
975
  "app/models/ckeditor/attachment_file.rb",
@@ -979,7 +980,6 @@ Gem::Specification.new do |s|
979
980
  "app/models/registerable.rb",
980
981
  "app/models/rememberable.rb",
981
982
  "app/models/roleable.rb",
982
- "app/models/superuser.rb",
983
983
  "app/models/suspendable.rb",
984
984
  "app/models/trackable.rb",
985
985
  "app/views/admin/_nav.html.erb",
@@ -1092,7 +1092,6 @@ Gem::Specification.new do |s|
1092
1092
  s.add_runtime_dependency(%q<plupload-rails>, [">= 0"])
1093
1093
  s.add_runtime_dependency(%q<has-attached>, ["~> 0.2.4"])
1094
1094
  s.add_runtime_dependency(%q<bootstrap-datepicker-rails>, [">= 0"])
1095
- s.add_runtime_dependency(%q<sorcery>, [">= 0"])
1096
1095
  s.add_development_dependency(%q<jeweler>, [">= 0"])
1097
1096
  else
1098
1097
  s.add_dependency(%q<rails>, ["~> 3.2"])
@@ -1106,7 +1105,6 @@ Gem::Specification.new do |s|
1106
1105
  s.add_dependency(%q<plupload-rails>, [">= 0"])
1107
1106
  s.add_dependency(%q<has-attached>, ["~> 0.2.4"])
1108
1107
  s.add_dependency(%q<bootstrap-datepicker-rails>, [">= 0"])
1109
- s.add_dependency(%q<sorcery>, [">= 0"])
1110
1108
  s.add_dependency(%q<jeweler>, [">= 0"])
1111
1109
  end
1112
1110
  else
@@ -1121,7 +1119,6 @@ Gem::Specification.new do |s|
1121
1119
  s.add_dependency(%q<plupload-rails>, [">= 0"])
1122
1120
  s.add_dependency(%q<has-attached>, ["~> 0.2.4"])
1123
1121
  s.add_dependency(%q<bootstrap-datepicker-rails>, [">= 0"])
1124
- s.add_dependency(%q<sorcery>, [">= 0"])
1125
1122
  s.add_dependency(%q<jeweler>, [">= 0"])
1126
1123
  end
1127
1124
  end
@@ -33,7 +33,6 @@ require "plupload-rails"
33
33
  require "fullstack"
34
34
  require "bootstrap-datepicker-rails"
35
35
  require "fullstack"
36
- require 'sorcery'
37
36
 
38
37
  require 'fullstack/admin/engine'
39
38
  require 'fullstack/admin/resources'
@@ -33,19 +33,17 @@ eos
33
33
 
34
34
 
35
35
  def users
36
- generate "sorcery:install remember_me activity_logging brute_force_protection --model Superuser"
36
+ generate "migration:from administrator"
37
37
  generate "migration:from user"
38
38
  append_to_file "db/seeds.rb" do
39
39
  <<-eos
40
40
 
41
41
  if Rails.env.development?
42
- user = Superuser.new( :email => "admin@example.com",
43
- :password => "password" )
44
-
45
- user.skip_confirmation! if user.respond_to?(:skip_confirmation!)
46
- user.save!
47
- user.confirm! if user.respond_to?(:confirm)
48
- user.has_role!(:administrator) if user.respond_to?(:has_role!)
42
+ user = Administrator.create!(
43
+ :username => "admin",
44
+ :email => "admin@example.com",
45
+ :password => "password"
46
+ )
49
47
  end
50
48
 
51
49
  eos
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fullstack-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-05 00:00:00.000000000 Z
12
+ date: 2012-11-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -187,22 +187,6 @@ dependencies:
187
187
  - - ! '>='
188
188
  - !ruby/object:Gem::Version
189
189
  version: '0'
190
- - !ruby/object:Gem::Dependency
191
- name: sorcery
192
- requirement: !ruby/object:Gem::Requirement
193
- none: false
194
- requirements:
195
- - - ! '>='
196
- - !ruby/object:Gem::Version
197
- version: '0'
198
- type: :runtime
199
- prerelease: false
200
- version_requirements: !ruby/object:Gem::Requirement
201
- none: false
202
- requirements:
203
- - - ! '>='
204
- - !ruby/object:Gem::Version
205
- version: '0'
206
190
  - !ruby/object:Gem::Dependency
207
191
  name: jeweler
208
192
  requirement: !ruby/object:Gem::Requirement
@@ -1179,6 +1163,7 @@ files:
1179
1163
  - app/inputs/taglist_input.rb
1180
1164
  - app/inputs/tags_input.rb
1181
1165
  - app/inputs/text_input.rb
1166
+ - app/models/administrator.rb
1182
1167
  - app/models/authenticatable.rb
1183
1168
  - app/models/ckeditor/asset.rb
1184
1169
  - app/models/ckeditor/attachment_file.rb
@@ -1189,7 +1174,6 @@ files:
1189
1174
  - app/models/registerable.rb
1190
1175
  - app/models/rememberable.rb
1191
1176
  - app/models/roleable.rb
1192
- - app/models/superuser.rb
1193
1177
  - app/models/suspendable.rb
1194
1178
  - app/models/trackable.rb
1195
1179
  - app/views/admin/_nav.html.erb
@@ -1295,7 +1279,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
1295
1279
  version: '0'
1296
1280
  segments:
1297
1281
  - 0
1298
- hash: 445393833660587370
1282
+ hash: -821323276577765542
1299
1283
  required_rubygems_version: !ruby/object:Gem::Requirement
1300
1284
  none: false
1301
1285
  requirements:
@@ -1,6 +0,0 @@
1
- class Superuser < ActiveRecord::Base
2
- authenticates_with_sorcery!
3
- def has_role?(r)
4
- true
5
- end
6
- end