<br><br><div class="gmail_quote">On Mon, Feb 25, 2008 at 6:24 PM, Aria Stewart <<a href="mailto:aredridel@nbtsc.org">aredridel@nbtsc.org</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><br>
On Feb 25, 2008, at 2:21 PM, Albert Ng wrote:<br>
<br>
> I'll keep that in mind.<br>
><br>
> As an aside, using this gem, how would I go about changing the user<br>
> without closing the browser or raising «Unauthorized»? That last<br>
> pops up a log-in window that can't authorize (have to press escape).<br>
<br>
</div>You can't. Browsers really really really should include a logout<br>
button, and they don't. File bugs with me!<br>
<div><div></div></div></blockquote><div>:)<br><br>After cursing at @state, wondering why it wasn't saving before I «raise Unauthorized» (for 3 hours *rolleyes*) , I've finally gotten the expected behavior by creating a «Loginstate» table that belongs to «User», calling save explicitly, and working some logic with that.<br>
<br>It's horribly expensive on the database, but it's ok for my purposes, because the app is only accessible locally.<br><br>Another thing is that I changed password_for_user to record_for_user, as I'm using @user for an AR record, and the gem kept turning it into a string :P<br>
<br>P.S. <a href="http://code.whytheluckystiff.net/camping/ticket/129">http://code.whytheluckystiff.net/camping/ticket/129</a> is very annoying, they changed mongrel/camping again (for the worse)<br><br>Module Ctd:Models<br>
class Loginstate < Base<br> belongs_to :users<br> end<br> <br> ---<br><br> create_table :ctd_loginstates do |t|<br> t.column :user_id, :integer, :null => false<br> t.column :reauthenticate, :boolean, :default => false<br>
end<br> user.create_loginstate<br><br>---<br>Module Ctd:Controlers<br> class CloseSession<br> def get<br> authenticate<br> @user.loginstate.reauthenticate = true<br> @user.loginstate.save<br>
redirect R(Index)<br> end<br> end<br>---<br>module Ctd<br> include Camping::DigestAuth<br> REALM = "ctd"<br> <br> module_function<br> <br> def record_for_user(username)<br> include Ctd::Models<br>
user = User.find( :first, :conditions => ['username = ?', username])<br> user = User.find( :first, :conditions => ['username = ?', 'dummy']) unless user<br> if user.loginstate.reauthenticate == true<br>
user.loginstate.reauthenticate = false<br> user.loginstate.save<br> raise Unauthorized<br> end if user<br> return user<br> end<br>end<br></div></div>