summaryrefslogtreecommitdiff
path: root/web/cgi/session/queryauth.tcl
blob: 450674a467294af897f6ab248fddb2fb83a00d12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!./tclsh
# $Id: queryauth.tcl 1204 2009-02-02 19:54:23Z hubert@u.washington.edu $
# ========================================================================
# Copyright 2006 University of Washington
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# ========================================================================

#  queryauth.tcl
#
#  Purpose:  CGI script to generate html form used to ask for authentication
#            credentials

# input:
set query_vars {
  {cid		"Missing Command ID"}
  {authcol	"Missing Authentication Collection"}
  {authfolder	"Missing Authentication Folder"}
  {authpage	"No Post Authorization Instructions"}
  {authcancel	"No Auth Cancel Instructions"}
  {authuser	""	""}
  {reason	""	""}
}

#  Output:
#
#	HTML/Javascript/CSS data representing the message specified
#	by the 'uid' argument


# inherit global config
source ./alpine.tcl
source ../$_wp(appdir)/$_wp(ui1dir)/cmdfunc.tcl


set query_menu {
  {
    {}
    {
      {
	# * * * * Help * * * *
	cgi_put "Get Help"
      }
    }
  }
}


WPEval $query_vars {

  if {$cid != [WPCmd PEInfo key]} {
    error [list _action open "Invalid Operation ID" "Click Back button to try again."]
  }

  cgi_http_head {
    WPStdHttpHdrs
  }

  cgi_html {
    cgi_head {
      WPStdHtmlHdr "Authentication Credentials"
      WPStyleSheets
    }

    if {[string length $authuser]} {
      set onload "onLoad=document.auth.pass.focus()"
    } else {
      set onload "onLoad=document.auth.user.focus()"
    }

    cgi_body BGCOLOR="$_wp(bordercolor)" $onload {
      cgi_form $_wp(serverpath)/session/setauth.tcl method=post enctype=multipart/form-data name=auth target=_top {
	cgi_text "sessid=$sessid" type=hidden notab
	cgi_text "cid=$cid" type=hidden notab
	cgi_text "authcol=$authcol" type=hidden notab
	cgi_text "authfolder=$authfolder" type=hidden notab
	cgi_text "authpage=$authpage" type=hidden notab
	cgi_text "authcancel=$authcancel" type=hidden notab

	cgi_table border=0 cellspacing=0 cellpadding=2 width="100%" height="100%" {
	  cgi_table_row {
	    eval {
	      cgi_table_data $_wp(menuargs) {
		WPTFCommandMenu query_menu {}
	      }
	    }

	    cgi_table_data valign=top class=dialog {
	      cgi_division align=center class=dialog "style=\"padding:30 12%\"" {
		if {[info exists reason] && [string compare BADPASSWD [string range $reason 0 8]]} {
		  cgi_puts $reason
		} else {
		  cgi_puts "Login Required"
		}
	      }

	      cgi_center {
		cgi_puts [cgi_font size=+1 class=dialog "Username: "]
		cgi_text user=$authuser maxlength=30 size=25%
		cgi_br
		cgi_br
		cgi_puts [cgi_font size=+1 class=dialog "Password: "]
		cgi_text pass= type=password maxlength=30 size=25%
		cgi_br
		cgi_br
		cgi_submit_button auths=Login
		cgi_submit_button cancel=Cancel
	      }
	    }
	  }
	}
      }
    }
  }
}