diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e1ed9cc3..85e3491e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -35,7 +35,7 @@ class ApplicationController < ActionController::Base # has an SSO session open. before_filter CASClient::Frameworks::Rails::GatewayFilter, :only => :login - # This requires the user to be authenticated for viewing allother pages. + # This requires the user to be authenticated for viewing all other pages. before_filter CASClient::Frameworks::Rails::Filter, :except => :login end before_filter :set_session_expiration diff --git a/app/controllers/login_controller.rb b/app/controllers/login_controller.rb index 89186d3d..53d57196 100644 --- a/app/controllers/login_controller.rb +++ b/app/controllers/login_controller.rb @@ -55,12 +55,13 @@ 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) + else + notify :notice, "You have been logged out of Tracks." + redirect_to_login end - reset_session - notify :notice, "You have been logged out of Tracks." - redirect_to_login end def check_expiry diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 61c7c331..45caef51 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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 @@ -208,4 +214,4 @@ class UsersController < ApplicationController return true end -end \ No newline at end of file +end diff --git a/app/views/login/login.html.erb b/app/views/login/login.html.erb index 5c62c5a7..5a565893 100644 --- a/app/views/login/login.html.erb +++ b/app/views/login/login.html.erb @@ -60,9 +60,15 @@
-
- <% if @username %> + + <% if @username && @user%>

Hello, <%= @username %>! You are authenticated.

+ <% elsif @username %> +

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%> +

<% else %>

You are not yet authenticated. <%= link_to("Login", @login_url) %> <% end %> diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index 592945b0..41d512b4 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -8,20 +8,21 @@

<%= @heading -%>

- - - - <%if Tracks::Config.auth_schemes.include?('cas')%> - - - + + + - + + <%else%> + + + +
<%= text_field "user", "login", :size => 20 %>
<%= password_field "user", "password", :size => 20 , :value => "fakebecauseweusecas" %>
"<%= session[:cas_user]%>"
<%= session[:cas_user]%>" <%= text_field "user", "login", :size => 20, :value => "fakebecauseweusecas" , :readonly => true %> <%= password_field "user", "password", :size => 20 , :value => "fakebecauseweusecas" %> <%= password_field "user", "password_confirmation", :size => 20, :value => "fakebecauseweusecas" %>
<%= text_field "user", "login", :size => 20 %>
<%= password_field "user", "password", :size => 20 %>