{= # # # authentication.cfv # # authentication.cfv is called from the C++ or from the client upon login or when validating a new license # with volatile.authentication_state = not_authenticated | session_timed_out | invalid_license | no_root_admin_password # # # include "templates.util.authentication_util"; debug_message("\n\n#### authentication.cfv \n"); # volatile.authentication_state = not_authenticated | session_timed_out | no_root_admin_password | invalid_license # DEBUG ONLY if (?("v.fp")) then ( debug_message("\n\n" . node_as_string("v.fp") . "\n\n"); ) else ( debug_message("\n\n#### The node \"v.fp\" does not exist. \n\n"); ); if (?("command_line")) then ( debug_message("\n" . node_as_string("command_line") . "\n"); ) else ( debug_message("#### authentication.cfv - command_line DOES NOT EXIST \n"); ); if (?("v.fp.is_regular_login_form_processing")) then ( debug_message("#### authentication.cfv - LOGIN form processing SERVER BACKGROUND CALL EXISTS \n"); ) else ( debug_message("#### authentication.cfv - LOGIN form processing SERVER BACKGROUND CALL DOES NOT EXIST \n"); ); # DEBUG ONLY END string authentication_state = if (?("volatile.authentication_state")) then (volatile.authentication_state) else ("unknown"); bool is_server_backround_call = (?("volatile.is_server_background_call")); bool is_login_form_processing = (?("v.fp.is_login_form_processing")); bool is_new_password_form_processing = (?("v.fp.is_new_password_form_processing")); bool is_license_validation = (?("v.fp.license_key")); bool is_auto_login = false; string username; string password; debug_message("#### authentication_state: " . authentication_state . "\n"); debug_message("#### is_server_backround_call: " . is_server_backround_call . "\n"); debug_message("#### is_login_form_processing: " . is_login_form_processing . "\n"); debug_message("#### is_new_password_form_processing: " . is_new_password_form_processing . "\n"); debug_message("#### is_license_validation: " . is_license_validation . "\n"); if ((authentication_state eq "not_authenticated") and !is_server_backround_call and !is_login_form_processing and !is_new_password_form_processing and !is_license_validation) then ( # # Check if this is auto login (username and password is provided in URL) # if (?("command_line.login_username") and @("command_line.login_username") ne "") then ( username = @("command_line.login_username"); ) else if (?("webvars.username")) then ( # We support the deprecated webvars.username for backward compatibility username = @("webvars.username"); ); if (?("command_line.login_password") and @("command_line.login_password") ne "") then ( password = @("command_line.login_password"); ) else if (?("webvars.password")) then ( # We support the deprecated webvars.password for backward compatibility password = @("webvars.password"); ); is_auto_login = (username ne "" or password ne ""); ); debug_message("#### is_auto_login: " . is_auto_login . "\n"); debug_message("#### username: " . username . "\n"); debug_message("#### password: " . password . "\n"); if (is_login_form_processing or is_new_password_form_processing) then ( username = v.fp.username; password = v.fp.password; debug_message("#### username: " . username . "\n"); debug_message("#### password: " . password . "\n"); if (is_login_form_processing) then ( # # Login form processing # validate_login_form_processing(username, password); ) else ( # # New password form processing (the existing password expired) # string new_password = v.fp.new_password; debug_message("#### new_password: " . new_password . "\n"); validate_login_with_new_password_form_processing(username, password, new_password); ); ) else if (is_license_validation) then ( # Validate license key (Note, this is server background call from authentication.cfv!) string license_key = v.fp.license_key; # debug_message("#### license_key: " . license_key . "\n"); authentication_handle_license_submission(license_key); ) else ( if (authentication_state eq "not_authenticated" or authentication_state eq "session_timed_out") then ( handle_not_authenticated_or_session_timed_out( authentication_state, is_auto_login, username, password, is_server_backround_call ); ) else if (authentication_state eq "invalid_license") then ( authentication_handle_invalid_license(); ) else if (authentication_state eq "no_root_admin_password") then ( # KHP-RC no_root_admin_password state error("volatile.authentication_state = \"no_root_admin_password\""); ) else ( error("Unknown authentication_state \"" . authentication_state . "\" in volatile.authentication_state"); ); ); debug_message("#### authentication.cfv END \n\n"); =}