diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2015-03-19 17:26:32 +0900 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2015-03-19 17:26:32 +0900 |
commit | 6b54e36d837548bcf0fc9076bd9b6dcf5356dfe9 (patch) | |
tree | b445503ba495f5d3761678daacea8514645172d1 | |
parent | 65fb5b9f7c0882213b97cc1eccdd9dd36c311190 (diff) | |
parent | 740abe29157f9afbfc1b83cf29945960dfe4fd6b (diff) | |
download | sariulclocks-6b54e36d837548bcf0fc9076bd9b6dcf5356dfe9.tar.gz |
Merge branch 'master' of git://github.com/spwhitton/sariulclocksv1.0.1
-rw-r--r-- | assets/js/main.js | 10 | ||||
-rwxr-xr-x | deploy.sh | 8 | ||||
-rw-r--r-- | src/Types/Session.hs | 7 | ||||
-rw-r--r-- | src/sariulclocks.hs | 3 |
4 files changed, 21 insertions, 7 deletions
diff --git a/assets/js/main.js b/assets/js/main.js index 1586c5c..f4d5af2 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -46,7 +46,8 @@ function createCookie(name,value,days) { var expires = "; expires="+date.toGMTString(); } else var expires = ""; - document.cookie = name+"="+value+expires+"; path=/"; + // TODO: make this not absolute + document.cookie = name+"="+value+expires+"; path=/sariul/cgi-bin"; } function readCookie(name) { @@ -89,6 +90,9 @@ function startLesson() // set the cookie and reload to start the session createCookie("class_cookie", cookieString, 1); + // reset clock because it's currently dangerous to do so when + // ending a lesson + timeWastingClock.reset(); // reload, preventing Firefox from resubmitting POST data window.location.assign(document.URL.split("#")[0]); } @@ -124,7 +128,9 @@ function endLesson() // submit timeWastingClock.stop(); - timeWastingClock.reset(); + // dangerous to reset clock here in case user inputs wrong + // password: instead reset when *starting* a class + // timeWastingClock.reset(); $form.submit(); } @@ -6,8 +6,8 @@ # 1. choose where to deploy -live="$HOME/html/sariul" -devel="$HOME/html/sariul-devel" +live="$HOME/html/sariul/cgi-bin" +devel="$HOME/html/sariul-devel/cgi-bin" if [ "$1" = "live" ]; then dest="$live" @@ -45,6 +45,10 @@ cp -RL ../schoolclock/sounds $dest cd $HOME # mkhomepg -p mkdir -p $dest/data +if ! [ -e "$dest/password" ]; then + echo "dummy_password" > $dest/password + echo "Please update password in $dest/password!" +fi chmod 777 $dest/data chmod 755 $dest/sariulclocks.cgi diff --git a/src/Types/Session.hs b/src/Types/Session.hs index 5d037a4..210cd28 100644 --- a/src/Types/Session.hs +++ b/src/Types/Session.hs @@ -26,7 +26,7 @@ makeClassCookie now session = Nothing -> "Nothing" , cookieExpires = Just $ endOfSchoolDay now , cookieDomain = Nothing - , cookiePath = Nothing + , cookiePath = Just "/sariul/cgi-bin" , cookieSecure = False} makeClockCookie :: ClockTime -> Session -> Cookie @@ -38,7 +38,7 @@ makeClockCookie now session = CountUpClock -> "1" , cookieExpires = Just $ endOfSchoolDay now , cookieDomain = Nothing - , cookiePath = Nothing + , cookiePath = Just "/sariul/cgi-bin" , cookieSecure = False} makeSsCookie :: ClockTime -> Session -> Cookie @@ -50,7 +50,8 @@ makeSsCookie now session = Just c -> show $ numberOfSs c , cookieExpires = Just $ endOfSchoolDay now , cookieDomain = Nothing - , cookiePath = Nothing +-- make the cookie path not absolute + , cookiePath = Just "/sariul/cgi-bin" , cookieSecure = False} endOfSchoolDay :: ClockTime -> CalendarTime diff --git a/src/sariulclocks.hs b/src/sariulclocks.hs index 74ae00c..137e1bd 100644 --- a/src/sariulclocks.hs +++ b/src/sariulclocks.hs @@ -164,6 +164,9 @@ cgiMain = do -- TODO: use POST,REDIRECT,GET https://stackoverflow.com/questions/570015/how-do-i-reload-a-page-without-a-postdata-warning-in-javascript/570069#570069 + + -- TODO: restore time wasting clock if password was wrong + let scores' = if points' /= 0 && userPassword == (unpack . strip . pack) password then updateScore scores (fromJust cookieClass) points' timeWasted' |