Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher M. Hobbs committed Aug 29, 2011
2 parents ea3e613 + 88cf335 commit c6f3dc5
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 10 deletions.
8 changes: 4 additions & 4 deletions lib/models/abstract_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
require Pathname(__FILE__).dirname.expand_path.to_s + "/sequel_user.rb"
require Pathname(__FILE__).dirname.expand_path.to_s + "/sequel_adapter.rb"
elsif Object.const_defined?("Mongoid")
require Pathname(__FILE__).dirname.expand_path.to_s + "mongoid_user.rb"
require Pathname(__FILE__).dirname.expand_path.to_s + "mongoid_adapter.rb"
require Pathname(__FILE__).dirname.expand_path.to_s + "/mongoid_user.rb"
require Pathname(__FILE__).dirname.expand_path.to_s + "/mongoid_adapter.rb"
elsif Object.const_defined?("ActiveRecord")
require Pathname(__FILE__).dirname.expand_path.to_s + "activerecord_user.rb"
require Pathname(__FILE__).dirname.expand_path.to_s + "ar_adapter.rb"
require Pathname(__FILE__).dirname.expand_path.to_s + "/activerecord_user.rb"
require Pathname(__FILE__).dirname.expand_path.to_s + "/ar_adapter.rb"
end

class User
Expand Down
8 changes: 4 additions & 4 deletions lib/sinatra-authentication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def self.registered(app)
end
else
if Rack.const_defined?('Flash')
flash[:notice] = "The email or password you entered is incorrect."
flash[:error] = "The email or password you entered is incorrect."
end
redirect '/login'
end
Expand Down Expand Up @@ -98,7 +98,7 @@ def self.registered(app)
redirect '/'
else
if Rack.const_defined?('Flash')
flash[:notice] = "There were some problems creating your account: #{@user.errors}."
flash[:error] = "There were some problems creating your account: #{@user.errors}."
end
redirect '/signup?' + hash_to_query_string(params['user'])
end
Expand Down Expand Up @@ -129,7 +129,7 @@ def self.registered(app)
redirect '/'
else
if Rack.const_defined?('Flash')
flash[:notice] = "Whoops, looks like there were some problems with your updates: #{user.errors}."
flash[:error] = "Whoops, looks like there were some problems with your updates: #{user.errors}."
end
redirect "/users/#{user.id}/edit?" + hash_to_query_string(user_attributes)
end
Expand All @@ -145,7 +145,7 @@ def self.registered(app)
end
else
if Rack.const_defined?('Flash')
flash[:notice] = "Deletion failed."
flash[:error] = "Deletion failed."
end
end
redirect '/'
Expand Down
2 changes: 2 additions & 0 deletions lib/views/edit.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#sinatra_authentication
- if Rack.const_defined?('Flash') && flash[:notice]
#sinatra_authentication_flash= flash[:notice]
- if Rack.const_defined?('Flash') && flash[:error]
#sinatra_authentication_flash= flash[:error]
%h1
Edit
- if @user.id == current_user.id
Expand Down
2 changes: 2 additions & 0 deletions lib/views/login.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#sinatra_authentication
- if Rack.const_defined?('Flash') && flash[:notice]
#sinatra_authentication_flash= flash[:notice]
- if Rack.const_defined?('Flash') && flash[:error]
#sinatra_authentication_flash= flash[:error]
%h1.page_title Login
%form{:action => "/login", :method => "post"}
.field
Expand Down
2 changes: 2 additions & 0 deletions lib/views/signup.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#sinatra_authentication
- if Rack.const_defined?('Flash') && flash[:notice]
#sinatra_authentication_flash= flash[:notice]
- if Rack.const_defined?('Flash') && flash[:error]
#sinatra_authentication_flash= flash[:error]
%h1.page_title Sign Up
%form{:action => "/signup", :method => "post"}
.field
Expand Down
3 changes: 2 additions & 1 deletion readme.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ Flash messages are implemented using rack-flash. To set them up add this to your
#be sure and do this after after 'use Rack:Session:Cookie...'
use Rack::Flash

And then sinatra-authentication related flash messages will be made available through flash[:notice]
And then sinatra-authentication related flash messages will be made available through flash[:notice] (successes) and flash[:error] (failures)

-# somewhere in a haml view:
= flash[:notice]
= flash[:error]

## HELPER METHODS:

Expand Down
2 changes: 1 addition & 1 deletion spec/unit/mongoid_model_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
require File.join(File.dirname(__FILE__), '../../test/lib/mongoid_app')
require File.join(File.dirname(__FILE__), '../../test/lib/helper')
require File.join(File.dirname(__FILE__), 'user_specs')
require File.join(File.dirname(__FILE__), '/user_specs')

0 comments on commit c6f3dc5

Please sign in to comment.