Skip to content

Commit

Permalink
Add OmniAuth "developer" provider in development mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
hmans committed Mar 8, 2012
1 parent 733987b commit d7de612
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -12,6 +12,7 @@ Changes:
* Most of your blog's configuration is now stored in MongoDB and can be modified from the new "Configuration" page in your the admin panel.
* When logged in as an admin, you will be shown a small admin actions panel in the upper right corner of your browser, allowing you to quickly edit posts, jump to the admin section, or log out.
* Schnitzelpress now has a light-weight, custom-built asset pipeline that serves all Javascripts and Stylesheets as one single file each, compressed and ready for hardcore caching.
* When running Schnitzelpress locally (aka: development mode), you can use a simple developer-only login provider to log into your blog for testing purposes.
* Post with dates now use double-digit days and months in their canonical URLs. (Your existing posts will forward to the new canonical URLs automatically.)
* Various performance improvements.

Expand Down
1 change: 1 addition & 0 deletions lib/schnitzelpress/actions/auth.rb
Expand Up @@ -8,6 +8,7 @@ module Auth

included do
use OmniAuth::Strategies::BrowserID
use OmniAuth::Strategies::Developer if Schnitzelpress.env.development?

post '/auth/:provider/callback' do
auth = request.env['omniauth.auth']
Expand Down
5 changes: 1 addition & 4 deletions lib/schnitzelpress/helpers.rb
Expand Up @@ -48,10 +48,7 @@ def user_logged_in?
end

def admin_logged_in?
user_logged_in? && session[:auth] == {
:provider => "browser_id",
:uid => config.author_email
}
user_logged_in? && (session[:auth][:uid] == config.author_email)
end

def admin_only!
Expand Down
6 changes: 6 additions & 0 deletions lib/views/login.haml
Expand Up @@ -9,3 +9,9 @@

%form{:method => 'post', :action => '/auth/browser_id/callback', :noValidate => 'noValidate'}
%input{:type => 'hidden', :name => 'assertion'}

- if Schnitzelpress.env.development?
%hr
%p
Since you're running Schnitzelpress in development mode, you can also use
the <a href="/auth/developer">development login provider</a>.

0 comments on commit d7de612

Please sign in to comment.