Skip to content

Commit

Permalink
fixing openid account
Browse files Browse the repository at this point in the history
  • Loading branch information
manveru committed Oct 29, 2008
1 parent f3f5e6b commit eed628b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
29 changes: 21 additions & 8 deletions controller/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ def login
end

return unless request.post?
@oid = session[:openid_identity]
@url = request[:url] || @oid

openid = request[:openid].to_s.strip

if $rapaste[:users].include?(openid)
session[:openid] = openid
redirect Rs(:after_login)
if @oid
openid_finalize
elsif request.post?
openid_begin
else
flash[:bad] = flash[:error] || "Bleep"
end

redirect_referrer
end

# This method is simply to check whether we really did login and the browser
Expand All @@ -27,9 +28,21 @@ def login
# site.
def after_login
if logged_in?
answer R(ProfileController, user.login)
answer R(SpamController, :list_pending)
else
redirect Rs(:login, :fail => :session)
end
end

private

def openid_finalize
if $rapaste[:users].include?(@oid)
session[:user] = @oid
flash[:good] = flash[:success]
redirect R(SpamController, :list_pending)
else
flash[:bad] = "None of our users belongs to this OpenID"
end
end
end
2 changes: 1 addition & 1 deletion controller/spam.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class SpamController < Ramaze::Controller
layout '/layout'

before_all do
redirect_referrer unless session[:openid]
redirect_referrer unless $rapaste[:users].include?(session[:openid_identity])
end

def list_pending
Expand Down
2 changes: 1 addition & 1 deletion view/css/screen.sass
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ pre
:text-align center
fieldset
:border 1px solid #eee
:background #fff
// :background #fff
legend
:font-size 1.5em
label
Expand Down
7 changes: 5 additions & 2 deletions view/layout.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
!!! XML
!!!
!!!

%html
%head
Expand All @@ -19,7 +19,10 @@
%input{:type => :text, :name => :substring}
%a{:href => '/'} New
%a{:href => '/list'} List
%a{:href => R(AccountController, :login)} Login
- if session[:user]
%a{:href => R(AccountController, :logout)} Logout
- else
%a{:href => R(AccountController, :login)} Login
#flash= flashbox
#content= @content
#footer
Expand Down

0 comments on commit eed628b

Please sign in to comment.