blob: f58d4cf797042cc928c7daebff98376519259837 (
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
|
(********************************** A user ***********************************)
type usernameOrAnonymous = option string
(*** Instances ***)
val eq_usernameOrAnonymous = Option.eq
val show_usernameOrAnonymous =
mkShow (
fn nameOpt =>
case nameOpt of
None => "Anonymous"
| Some nam => nam)
val read_author =
let fun parse text =
case text of
"Anonymous" => None
| nam => Some nam
in
mkRead parse (compose Some parse)
end
val sql_usernameOrAnonymous = sql_option_prim
(*** Getting the username ***)
val current =
addressOpt <- getenv (blessEnvVar "SSL_CLIENT_S_DN_Email");
(* SSL_CLIENT_EMAIL contains the user's entire e-mail address, including
the "@MIT.EDU" part. Get rid of the domain name. *)
return (address <- addressOpt;
usernameAndDomain <- String.split address #"@";
return usernameAndDomain.1)
(******************************* A named user ********************************)
type username = string
(*** Instances ***)
val eq_username = eq_string
val show_username = show_string
val read_username = read_string
val sql_username = sql_prim
(******************************** Converting *********************************)
fun name uOrA = uOrA
val orAnonymous = Some
fun toOptionTag [_use] uOrA =
case uOrA of
None => <xml/>
| Some u => <xml><option>{[u]}</option></xml>
|