when CAS is switched app functions as normal but does not use any other auth methods.

This commit is contained in:
Erik Ordway 2009-11-24 13:09:29 -08:00 committed by Eric Allen
parent 00d06b7a00
commit f259924a85
5 changed files with 31 additions and 17 deletions

View file

@ -55,13 +55,14 @@ class LoginController < ApplicationController
@user.forget_me if logged_in?
cookies.delete :auth_token
session['user_id'] = nil
reset_session
if ( SITE_CONFIG['authentication_schemes'].include? 'cas')
CASClient::Frameworks::Rails::Filter.logout(self)
end
reset_session
else
notify :notice, "You have been logged out of Tracks."
redirect_to_login
end
end
def check_expiry
# Gets called by periodically_call_remote to check whether

View file

@ -66,6 +66,11 @@ class UsersController < ApplicationController
end
user = User.new(params['user'])
if Tracks::Config.auth_schemes.include?('cas')
user.auth_type = "cas" #since CAS will be doing all the auth we may as well set it for everyone when CAS in enabled
end
unless user.valid?
session['new_user'] = user
redirect_to :action => 'new'
@ -74,11 +79,9 @@ class UsersController < ApplicationController
first_user_signing_up = User.no_users_yet?
user.is_admin = true if first_user_signing_up
if Tracks::Config.auth_schemes.include?('cas')
user.auth_type = "cas" #since CAS will be doing all the auth we may as well set it for everyone when CAS in enabled
end
if user.save
@user = User.authenticate(user.login, params['user']['password'])
@user.create_preference
@ -99,6 +102,9 @@ class UsersController < ApplicationController
return
end
user = User.new(params[:request])
if Tracks::Config.auth_schemes.include?('cas')
user.auth_type = "cas" #since CAS will be doing all the auth we may as well set it for everyone when CAS in enabled
end
user.password_confirmation = params[:request][:password]
if user.save
render :text => "User created.", :status => 200

View file

@ -61,8 +61,14 @@
<table>
<tr>
<td>
<% if @username %>
<% if @username && @user%>
<p>Hello, <%= @username %>! You are authenticated.</p>
<% elsif @username %>
<p>Hello, <%= @username %>! You do not have an account on Tracks.
<%if SITE_CONFIG['open_signups']%>
If you like to request on please go here to <%= link_to "Request Account" , signup_url %>
<%end%>
</p>
<% else %>
<p>You are not yet authenticated. <%= link_to("Login", @login_url) %>
<% end %>

View file

@ -8,20 +8,21 @@
<h3><%= @heading -%></h3>
<table>
<%if Tracks::Config.auth_schemes.include?('cas')%>
<tr>
<td><label for="user_login">With your CAS username:</label></td>
<td> "<%= session[:cas_user]%>" </td>
</tr>
<tr style="display:none">
<td><%= session[:cas_user]%>" <%= text_field "user", "login", :size => 20, :value => "fakebecauseweusecas" , :readonly => true %> </td>
<td><%= password_field "user", "password", :size => 20 , :value => "fakebecauseweusecas" %></td>
<td><%= password_field "user", "password_confirmation", :size => 20, :value => "fakebecauseweusecas" %></td>
</tr>
<%else%>
<tr>
<td><label for="user_login">Desired login:</label></td>
<td> <%= text_field "user", "login", :size => 20 %></td>
</tr>
<%if Tracks::Config.auth_schemes.include?('cas')%>
<tr style="display:none">
<td><label for="user_password">Choose password:</label></td>
<td><%= password_field "user", "password", :size => 20 , :value => "fakebecauseweusecas" %></td>
</tr>
<tr style="display:none">
<td><label for="user_password_confirmation">Confirm password:</label></td>
<td><%= password_field "user", "password_confirmation", :size => 20, :value => "fakebecauseweusecas" %></td>
</tr>
<%else%>
<tr>
<td><label for="user_password">Choose password:</label></td>
<td><%= password_field "user", "password", :size => 20 %></td>