rubycas / rubycas-server

Provides single sign-on authentication for web applications, implementing the server-end of Jasig's CAS protocol.
http://rubycas.github.com
Other
628 stars 270 forks source link

Add convenience variables for custom views. #138

Closed adamcrown closed 11 years ago

adamcrown commented 11 years ago

It can be very difficult to get the current users username or even tell if the user is authenticated or not from within a custom view. I've added @authenticated and @authenticated_username instance variables to hopefully simplify custom view creation.

voke commented 11 years ago

I think this belongs in view helpers rather than instance variables.

adamcrown commented 11 years ago

I'd be happy to create helpers and it's probably a good idea since it will likely be more future-proof that way. But they'll probably just wind up being wrappers around the instance variables. It would be nice to make them more loosely coupled but I think you'd need to pull the session ticket not only from the cookie but also from the Set-Cookie header on post, which just seems messy.

adamcrown commented 11 years ago

So I've added a authenticated? and authenticated_user helpers.

But looking through the code, these are the only helpers being used, up to now everything has been exposed through instance variables. So there are probably a lot of places where instance variables should be swapped out for helpers. Specifically @theme, @organization, @uri_path, @infoline, @form_action and @message. And possibly @lt, @service, @success, @extra_attributes, @pgtiou and @pt. I didn't want to make these changes here because it's outside the scope of this pull request but it something that should probably be discussed for the future. Plus, decisions will have to be made about backward compatibility.