Skip to content
Browse files

single password logins now working correctly. add basic scaffold for …

…amin/settings controller
  • Loading branch information...
1 parent a86c05a commit ed1e7bd5853e917e8156cb3f1944196baaa10d70 @timriley committed
View
6 app/controllers/admin/logins_controller.rb
@@ -1,10 +1,12 @@
-class Admin::LoginsController < ApplicationController
+class Admin::LoginsController < Admin::AdminController
+ skip_before_filter :login_required, :only => [:new, :create]
+
def new
end
def create
if Settings.instance.crypted_password?(params[:password])
- session[:logged_in] == true
+ session[:logged_in] = true
redirect_back_or_default('/')
flash[:notice] = "Logged in successfully"
else
View
9 app/controllers/admin/settings_controller.rb
@@ -0,0 +1,9 @@
+class Admin::SettingsController < Admin::AdminController
+ def edit
+ @settings = Settings.instance
+ end
+
+ def update
+ @settings = Settings.instance
+ end
+end
View
2 app/helpers/admin/logins_helper.rb
@@ -1,2 +1,2 @@
-module LoginsHelper
+module Admin::LoginsHelper
end
View
2 app/helpers/admin/settings_helper.rb
@@ -0,0 +1,2 @@
+module Admin::SettingsHelper
+end
View
10 app/views/admin/logins/new.haml
@@ -0,0 +1,10 @@
+%p= flash[:notice]
+
+- form_tag admin_login_path do
+ #login
+ %p
+ %label{:for => 'password'} Password
+ %br
+ = password_field_tag :password
+ %p.button
+ = submit_tag 'Log in'
View
1 app/views/admin/settings/edit.haml
@@ -0,0 +1 @@
+hey there
View
7 config/routes.rb
@@ -1,4 +1,11 @@
ActionController::Routing::Routes.draw do |map|
map.resources :photos
map.root :controller => 'photos', :action => 'show'
+
+ map.namespace :admin do |admin|
+ admin.resource :settings
+ admin.resource :login
+ admin.logout '/logout', :controller => 'logins', :action => 'destroy'
+ admin.root :controller => 'settings', :action => 'edit'
+ end
end
View
10 spec/controllers/admin/settings_controller_spec.rb
@@ -0,0 +1,10 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe Admin::SettingsController do
+
+ #Delete this example and add some real ones
+ it "should use Admin::SettingsController" do
+ controller.should be_an_instance_of(Admin::SettingsController)
+ end
+
+end
View
11 spec/helpers/admin/settings_helper_spec.rb
@@ -0,0 +1,11 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe Admin::SettingsHelper do
+
+ #Delete this example and add some real ones or delete this file
+ it "should include the Admin::SettingsHelper" do
+ included_modules = self.metaclass.send :included_modules
+ included_modules.should include(Admin::SettingsHelper)
+ end
+
+end

0 comments on commit ed1e7bd

Please sign in to comment.
Something went wrong with that request. Please try again.