Permalink
Browse files

Added devise users

  • Loading branch information...
1 parent c43e494 commit cca2d9dae73cc1b295d86b6dc439c0e9b5d2a9c7 @mmorin committed Feb 13, 2013
View
@@ -5,4 +5,4 @@ You are allowed to:
2. Remove generators
3. Add installed generators
To add new installed generators automatically delete this file and reload the project.
---><GeneratorsGroup><Generator name="assets" /><Generator name="coffee:assets" /><Generator name="controller" /><Generator name="generator" /><Generator name="helper" /><Generator name="integration_test" /><Generator name="jquery:install" /><Generator name="js:assets" /><Generator name="mailer" /><Generator name="migration" /><Generator name="model" /><Generator name="observer" /><Generator name="performance_test" /><Generator name="resource" /><Generator name="scaffold" /><Generator name="scaffold_controller" /><Generator name="session_migration" /><Generator name="task" /><Generator name="test_unit:controller" /><Generator name="test_unit:helper" /><Generator name="test_unit:integration" /><Generator name="test_unit:mailer" /><Generator name="test_unit:model" /><Generator name="test_unit:observer" /><Generator name="test_unit:performance" /><Generator name="test_unit:plugin" /><Generator name="test_unit:scaffold" /></GeneratorsGroup></Settings>
+--><GeneratorsGroup><Generator name="active_record:devise" /><Generator name="assets" /><Generator name="coffee:assets" /><Generator name="controller" /><Generator name="devise" /><Generator name="devise:install" /><Generator name="devise:views" /><Generator name="generator" /><Generator name="helper" /><Generator name="integration_test" /><Generator name="jquery:install" /><Generator name="js:assets" /><Generator name="mailer" /><Generator name="migration" /><Generator name="model" /><Generator name="mongoid:devise" /><Generator name="observer" /><Generator name="performance_test" /><Generator name="resource" /><Generator name="scaffold" /><Generator name="scaffold_controller" /><Generator name="session_migration" /><Generator name="task" /><Generator name="test_unit:controller" /><Generator name="test_unit:helper" /><Generator name="test_unit:integration" /><Generator name="test_unit:mailer" /><Generator name="test_unit:model" /><Generator name="test_unit:observer" /><Generator name="test_unit:performance" /><Generator name="test_unit:plugin" /><Generator name="test_unit:scaffold" /></GeneratorsGroup></Settings>
View
@@ -24,11 +24,13 @@
<orderEntry type="library" scope="PROVIDED" name="activeresource (v3.2.11, RVM: ruby-1.9.3-p374) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activesupport (v3.2.11, RVM: ruby-1.9.3-p374) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="arel (v3.0.2, RVM: ruby-1.9.3-p374) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="bcrypt-ruby (v3.0.1, RVM: ruby-1.9.3-p374) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="builder (v3.0.4, RVM: ruby-1.9.3-p374) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.2.3, RVM: ruby-1.9.3-p374) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="coffee-rails (v3.2.2, RVM: ruby-1.9.3-p374) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="coffee-script (v2.2.0, RVM: ruby-1.9.3-p374) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="coffee-script-source (v1.4.0, RVM: ruby-1.9.3-p374) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="devise (v2.2.3, RVM: ruby-1.9.3-p374) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="erubis (v2.7.0, RVM: ruby-1.9.3-p374) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="execjs (v1.4.0, RVM: ruby-1.9.3-p374) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="hike (v1.2.1, RVM: ruby-1.9.3-p374) [gem]" level="application" />
@@ -39,6 +41,7 @@
<orderEntry type="library" scope="PROVIDED" name="mail (v2.4.4, RVM: ruby-1.9.3-p374) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="mime-types (v1.21, RVM: ruby-1.9.3-p374) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="multi_json (v1.5.1, RVM: ruby-1.9.3-p374) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="orm_adapter (v0.4.0, RVM: ruby-1.9.3-p374) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="polyglot (v0.3.3, RVM: ruby-1.9.3-p374) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rack (v1.4.5, RVM: ruby-1.9.3-p374) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rack-cache (v1.2, RVM: ruby-1.9.3-p374) [gem]" level="application" />
@@ -57,6 +60,7 @@
<orderEntry type="library" scope="PROVIDED" name="treetop (v1.4.12, RVM: ruby-1.9.3-p374) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="tzinfo (v0.3.35, RVM: ruby-1.9.3-p374) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="uglifier (v1.3.0, RVM: ruby-1.9.3-p374) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="warden (v1.2.1, RVM: ruby-1.9.3-p374) [gem]" level="application" />
</component>
<component name="RModuleSettingsStorage">
<LOAD_PATH number="0" />
View
@@ -6,7 +6,7 @@ gem 'rails', '3.2.11'
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
-
+gem 'devise'
# Gems used only for assets and not required
# in production environments by default.
View
@@ -29,6 +29,7 @@ GEM
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
+ bcrypt-ruby (3.0.1)
builder (3.0.4)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
@@ -37,6 +38,11 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.4.0)
+ devise (2.2.3)
+ bcrypt-ruby (~> 3.0)
+ orm_adapter (~> 0.1)
+ railties (~> 3.1)
+ warden (~> 1.2.1)
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
@@ -53,6 +59,7 @@ GEM
treetop (~> 1.4.8)
mime-types (1.21)
multi_json (1.5.1)
+ orm_adapter (0.4.0)
polyglot (0.3.3)
rack (1.4.5)
rack-cache (1.2)
@@ -99,12 +106,15 @@ GEM
uglifier (1.3.0)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
+ warden (1.2.1)
+ rack (>= 1.0)
PLATFORMS
ruby
DEPENDENCIES
coffee-rails (~> 3.2.1)
+ devise
jquery-rails
rails (= 3.2.11)
sass-rails (~> 3.2.3)
@@ -1,3 +1,16 @@
class ApplicationController < ActionController::Base
protect_from_forgery
+
+ protected
+ def authorize_blogger!
+ if user_signed_in? && current_user.is_blogger
+ return
+ elsif user_signed_in?
+ flash[:notice] = 'You must be an authorized blogger to do that'
+ redirect_to :root
+ else
+ flash[:notice] = 'You need to sign in first'
+ redirect_to new_user_session_path
+ end
+ end
end
@@ -1,4 +1,6 @@
class PostsController < ApplicationController
+ before_filter :authorize_blogger!, :except => [:index, :show]
+
# GET /posts
# GET /posts.json
def index
View
@@ -0,0 +1,11 @@
+class User < ActiveRecord::Base
+ # Include default devise modules. Others available are:
+ # :token_authenticatable, :confirmable,
+ # :lockable, :timeoutable and :omniauthable
+ devise :database_authenticatable, :registerable,
+ :rememberable, :trackable, :validatable
+
+ # Setup accessible (or protected) attributes for your model
+ attr_accessible :email, :password, :password_confirmation, :remember_me
+ # attr_accessible :title, :body
+end
@@ -0,0 +1,9 @@
+<%- if user_signed_in? %>
+ <p>Hello <%= current_user.email %><br />
+ <%= link_to 'Sign out', destroy_user_session_path, :method => :delete %></p>
+<%- else %>
+ <p>
+ <%= link_to 'Register', new_user_registration_path %> |
+ <%= link_to 'Sign in', new_user_session_path %>
+ </p>
+<%- end %>
@@ -24,7 +24,7 @@
</div>
<div id="secondaryContent">
-
+ <%= render 'common/session' %>
</div>
<div id="footer">
View
@@ -58,6 +58,7 @@ class Application < Rails::Application
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
# parameters by using an attr_accessible or attr_protected declaration.
config.active_record.whitelist_attributes = true
+ config.assets.initialize_on_precompile = false
# Enable the asset pipeline
config.assets.enabled = true
Oops, something went wrong.

0 comments on commit cca2d9d

Please sign in to comment.