From 53a2c4d4a18c2f5903961bce7bc61cf19336157f Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Thu, 2 May 2013 19:45:39 -0400 Subject: Forum: Make anonymity typesafe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ‘username’ and ‘usernameOrAnonymous’ are now separate types. --- forum/forum.ur | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'forum/forum.ur') diff --git a/forum/forum.ur b/forum/forum.ur index e1bf577..c43befe 100644 --- a/forum/forum.ur +++ b/forum/forum.ur @@ -21,7 +21,6 @@ functor Make(Template : sig end) = struct open Styles -open Author style entryList style entryMetadata @@ -33,19 +32,15 @@ table entry : { Id : int, Class : EntryClass.entryClass, Title : option string, Body : string, - Author : author + Author : Author.usernameOrAnonymous } PRIMARY KEY Id sequence entryIdS table vote : { QuestionId : int, - Author : author, + Author : Author.username, Value : Score.score } -(* Grabs real name out of MIT certificate. *) -val getName : transaction (option string) = - getenv (blessEnvVar "SSL_CLIENT_S_DN_CN") - (* Like query1', but automatically dereferences the field *) fun queryColumn [tab ::: Name] [field ::: Name] [state ::: Type] (q : sql_query [] [] [tab = [field = state]] []) @@ -64,7 +59,7 @@ fun getScore (questionId : int) : transaction Score.score = (***************************** Single questions ******************************) fun detail (id : int) : transaction page = - authorOpt <- getName; + authorOpt <- Author.current; question <- oneRow1 (SELECT * FROM entry WHERE Entry.Class = {[EntryClass.question]} AND Entry.Id = {[id]}); @@ -90,9 +85,7 @@ fun detail (id : int) : transaction page =