Index: openacs-4/packages/acs-subsite/www/register/display-message.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/register/display-message.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-subsite/www/register/display-message.adp 29 Aug 2003 12:26:42 -0000 1.1 @@ -0,0 +1,10 @@ + + @page_title@ + @context;noquote@ + +

@message;noquote@

+ + + &rauo; @continue_label@ + + Index: openacs-4/packages/acs-subsite/www/register/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/register/index.adp,v diff -u -r1.7 -r1.8 --- openacs-4/packages/acs-subsite/www/register/index.adp 15 Aug 2003 21:18:12 -0000 1.7 +++ openacs-4/packages/acs-subsite/www/register/index.adp 29 Aug 2003 12:26:42 -0000 1.8 @@ -1,44 +1,11 @@ #acs-subsite.Log_In# -login.email -#acs-subsite.to# @system_name;noquote@ -#acs-subsite.Log_In# +login.username +{#acs-subsite.Log_In#} -

#acs-subsite.Current_users# #acs-subsite.lt_Please_enter_your_ema#

-

#acs-subsite.New_users# #acs-subsite.lt_welcome_please_register#

+ -
-@export_vars;noquote@ - - - - - - - - - - - + + Forgot your password? - -
#acs-subsite.Your_email_address#
#acs-subsite.Your_password#
- - - - - - - #acs-subsite.lt_Remember_this_address# - (#acs-subsite.help#)
- -
- - -

#acs-subsite.lt_Have_you_a_hrefemail-#

-
- -

#acs-subsite.lt_no_cookies#

-

#acs-subsite.lt_enable_cookies#

- Index: openacs-4/packages/acs-subsite/www/register/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/register/index.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-subsite/www/register/index.tcl 15 Aug 2003 21:18:12 -0000 1.4 +++ openacs-4/packages/acs-subsite/www/register/index.tcl 29 Aug 2003 12:26:42 -0000 1.5 @@ -2,31 +2,37 @@ Prompt the user for email and password. @cvs-id $Id$ } { - { email "" } return_url:optional -} -properties { - system_name:onevalue - export_vars:onevalue - email:onevalue - old_login_process:onevalue - allow_persistent_login_p:onevalue - persistent_login_p:onevalue - subsite_url:onevalue } -set old_login_process [parameter::get -parameter SeparateEmailPasswordPagesP -default 0] -set allow_persistent_login_p [parameter::get -parameter AllowPersistentLoginP -default 1] -set persistent_login_p [parameter::get -parameter AllowPersistentLoginP -default 1] -set subsite_url [subsite::get_element -element url] -set email_forgotten_password_p [parameter::get -parameter EmailForgottenPasswordP -default 1] +# TODO: Move this entire thing to an includeable template and make sure it'll still work -if {![info exists return_url]} { - set return_url [ad_pvt_home] +# TODO: Forgotten passwords + + + +# Persistent login +# The logic is: +# 1. Allowed if allowed both site-wide (on acs-kernel) and on the subsite +# 2. Default setting is in acs-kernel + +set allow_persistent_login_p [parameter::get -parameter AllowPersistentLoginP -package_id [ad_acs_kernel_id] -default 1] +if { $allow_persistent_login_p } { + set allow_persistent_login_p [parameter::get -parameter AllowPersistentLoginP -default 1] } +if { $allow_persistent_login_p } { + set default_persistent_login_p [parameter::get -parameter DefaultPersistentLoginP -package_id [ad_acs_kernel_id] -default 1] +} + +set subsite_url [subsite::get_element -element url] set system_name [ad_system_name] +if { ![exists_and_not_null return_url] } { + set return_url [ad_pvt_home] +} + # One common problem with login is that people can hit the back button # after a user logs out and relogin by using the cached password in # the browser. We generate a unique hashed timestamp so that users @@ -37,6 +43,118 @@ set token [sec_get_token $token_id] set hash [ns_sha1 "$time$token_id$token"] -set export_vars [export_vars -form {return_url time token_id hash}] -ad_return_template +# TODO: Move this into a library proc +set authority_options [db_list_of_lists select_authorities { + select pretty_name, authority_id + from auth_authorities + where enabled_p = 't' + and auth_impl_id is not null + order by sort_order +}] + +# TODO: Not implemented +set forgotten_pwd_url [auth::password::get_forgotten_url] + +ad_form -name login -form { + {return_url:text(hidden)} + {time:text(hidden)} + {token_id:text(hidden)} + {hash:text(hidden)} +} + +if { [llength $authority_options] > 1 } { + ad_form -extend -name login -form { + {authority_id:integer(select) + {label "Authority"} + {options $authority_options} + } + } +} + +ad_form -extend -name login -form { + {username:text + {label "Username"} + } + {password:text(password) + {label "Password"} + } +} + +if { $allow_persistent_login_p } { + ad_form -extend -name login -form { + {persistent_p:text(checkbox) + {label ""} + {options { { "Remember my login on this computer" "t" } }} + {value {[ad_decode $default_persistent_login_p 1 "t" ""]}} + } + } +} + +ad_form -extend -name login -on_request { + # Populate fields +} -on_submit { + if { ![exists_and_not_null authority_id] } { + # Will be defaulted to local authority + set authority_id {} + } + + if { ![exists_and_not_null persistent_p] } { + set persistent_p "f" + } + + array set auth_info [auth::authenticate \ + -authority_id $authority_id \ + -username $username \ + -password $password \ + -persistent=[expr $allow_persistent_login_p && [template::util::is_true $persistent_p]]] + + # Handle authentication problems + switch $auth_info(auth_status) { + ok { + # Continue below + } + bad_password { + form set_error login password $auth_info(auth_message) + break + } + default { + form set_error login username $auth_info(auth_message) + break + } + } + + + # Handle account status + switch $auth_info(account_status) { + ok { + # Continue below + } + default { + # Display the message on a separate page + set page_title "Login denied" + set context [list [list "." [_ acs-subsite.Log_In]] "Login denied"] + set message $auth_info(account_message) + ad_return_template "display-message" + break + } + } +} -after_submit { + + # We're logged in + + # Handle account_message + if { [exists_and_not_null auth_info(account_message)] } { + set page_title "Logged In" + set context [list [list "." [_ acs-subsite.Log_In]] "Logged in"] + set message $auth_info(account_message) + set continue_url $return_url + set continue_label "Continue working with [ad_system_name]" + ad_return_template "display-message" + return + } else { + # No message + ad_returnredirect $return_url + ad_script_abort + } +}