ad_page_contract {
    Checks the user-supplied passcode.

    You may use this software free under the GNU General Public License.
    
    @param passcode  A 4-digit passcode, required for entry into the telephone directory.
    
    @author Eve Andersson, eveander@eveander.com
    @creation-date February 24, 2001
} {
    passcode:notnull,integer
}

# There's no way for users to log in to the ACS using VXML (can't type their
# passwords), so authentication is going to be done with a passcode.
# Instead of doing some kind of user sessioning thing and keeping records in
# the database of which sessions are valid, I'll just pass the passcode along
# on each request. 
# The passcode may as well be passed using goto instead of submit method=post
# because the passcode is going to be passed in the query string regardless
# (I guess this is a Tellme feature).


if { [string compare $passcode [vxml_tellme_phone_dir_passcode]] != 0 } {

    # tell them it's the wrong passcode and send them back to index.vxml

    set content "<vxml>
<form id=\"passcode_check\">
   <block>
      <audio>I'm sorry, that is not the correct passcode.</audio>
      <goto next=\"index.vxml#phone_dir_entry_point\"/>
   </block>
</form>
</vxml>"
} else {

    # passcode is correct; send them on to name-search-input
    set content "<vxml>
<form id=\"passcode_check\">
   <block>
      <goto next=\"name-search-input.tcl?passcode=$passcode#phone_dir_name_entry\"/>
   </block>
</form>
</vxml>"

}

vxml_return_content $content