diff --git a/app/controllers/admin/assets_controller.rb b/app/controllers/admin/assets_controller.rb index 61ef4d9b..74879184 100644 --- a/app/controllers/admin/assets_controller.rb +++ b/app/controllers/admin/assets_controller.rb @@ -1,6 +1,7 @@ class Admin::AssetsController < ApplicationController layout "admin" + before_filter :authenticate_user! def show @asset = Asset.find(params[:id]) diff --git a/app/controllers/admin/components_controller.rb b/app/controllers/admin/components_controller.rb index fda62c9a..07abc711 100644 --- a/app/controllers/admin/components_controller.rb +++ b/app/controllers/admin/components_controller.rb @@ -1,6 +1,7 @@ class Admin::ComponentsController < ApplicationController layout "admin" + before_filter :authenticate_user! before_filter :find_parent_item def show diff --git a/app/controllers/admin/items_controller.rb b/app/controllers/admin/items_controller.rb index ad472502..72cb995c 100644 --- a/app/controllers/admin/items_controller.rb +++ b/app/controllers/admin/items_controller.rb @@ -1,6 +1,9 @@ class Admin::ItemsController < ApplicationController layout "admin" + + before_filter :authenticate_user! + before_filter :find_parent_item before_filter :find_snippets, :only => :index diff --git a/app/controllers/admin/layouts_controller.rb b/app/controllers/admin/layouts_controller.rb index 67cfda2b..f9ff6311 100644 --- a/app/controllers/admin/layouts_controller.rb +++ b/app/controllers/admin/layouts_controller.rb @@ -1,6 +1,7 @@ class Admin::LayoutsController < ApplicationController layout "admin" + before_filter :authenticate_user! def index @layouts = Layout.all diff --git a/app/controllers/admin/links_controller.rb b/app/controllers/admin/links_controller.rb index 71ac9f3b..b3ae0b78 100644 --- a/app/controllers/admin/links_controller.rb +++ b/app/controllers/admin/links_controller.rb @@ -1,6 +1,7 @@ class Admin::LinksController < ApplicationController layout "admin" + before_filter :authenticate_user! before_filter :find_parent_item def show diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index 5ac4bf71..179f775b 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -1,6 +1,7 @@ class Admin::PagesController < ApplicationController layout "admin" + before_filter :authenticate_user! before_filter :find_parent_item def show diff --git a/app/controllers/admin/snippets_controller.rb b/app/controllers/admin/snippets_controller.rb index 2f8ad933..57a2f09e 100644 --- a/app/controllers/admin/snippets_controller.rb +++ b/app/controllers/admin/snippets_controller.rb @@ -1,6 +1,7 @@ class Admin::SnippetsController < ApplicationController layout "admin" + before_filter :authenticate_user! before_filter :find_parent_item def show diff --git a/app/controllers/panel/users_controller.rb b/app/controllers/panel/users_controller.rb new file mode 100644 index 00000000..1a0123b2 --- /dev/null +++ b/app/controllers/panel/users_controller.rb @@ -0,0 +1,47 @@ +class Panel::UsersController < ApplicationController + + layout "panel" + before_filter :authenticate_user! + + def index + @users = User.all + end + + def show + @user = User.find(params[:id]) + end + + def new + @user = User.new + end + + def create + @user = User.new(params[:user]) + if @user.save + redirect_to :action => :index + else + render :action => :new + end + end + + def edit + @user = User.find(params[:id]) + end + + def update + @user = User.find(params[:id]) + if @user.update_attributes(params[:user]) + redirect_to :action => :index + else + render :action => :edit + end + end + + def destroy + @user = User.find(params[:id]) + @user.destroy + + redirect_to :action => :index + end + +end diff --git a/app/models/item.rb b/app/models/item.rb index eb63113c..d9091c31 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -47,7 +47,7 @@ class Item def setup_default_value if self.position.blank? - max_page = Page.find(:last, :order => 'position') + max_page = Page.last(:order => 'position') self.position = (max_page)? max_page.position.to_i + 1 : 1 end diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 00000000..5ce3f0d8 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,6 @@ +class User + include MongoMapper::Document + + devise :authenticatable, :recoverable, :rememberable, :trackable + +end \ No newline at end of file diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index 063430ad..7f2ea76c 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -16,7 +16,7 @@