(********************************** 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 nameError = MyOption.getError
val orAnonymous = Some
(* I can't express this in terms of whenIdentified'--I get a "substitution in
constructor is blocked by a too-deep unification variable." *)
fun whenIdentified [ctx] [use] uOrA text =
case uOrA of
None =>
| Some u => text
fun whenIdentified' [ctx] [use] uOrA generator =
case uOrA of
None =>
| Some u => generator u
fun toOptionTag [_use] uOrA =
case uOrA of
None =>
| Some u =>