aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2015-03-23 06:07:27 +0000
committerSean Whitton <spwhitton@spwhitton.name>2015-03-23 06:07:27 +0000
commit38107bbadb1739e17afe9886ee6a7d31368c1be2 (patch)
treea978a917926c50833e358704b0d1fdd98df6934a
parent3d024944e8e572a48377d37f3a0a9bfa52020cf2 (diff)
downloadsariulclocks-38107bbadb1739e17afe9886ee6a7d31368c1be2.tar.gz
dynamic cookie path (so works with devel site too)
-rw-r--r--assets/js/main.js5
-rw-r--r--sariulclocks.cabal4
-rw-r--r--src/Types/Session.hs18
3 files changed, 14 insertions, 13 deletions
diff --git a/assets/js/main.js b/assets/js/main.js
index f701f85..d72d8e9 100644
--- a/assets/js/main.js
+++ b/assets/js/main.js
@@ -56,8 +56,9 @@ function createCookie(name,value,days) {
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
- // TODO: make this not absolute
- document.cookie = name+"="+value+expires+"; path=/sariul/cgi-bin";
+ var path = $(location).attr('pathname');
+ var dir = path.substring(0, path.lastIndexOf("/"));
+ document.cookie = name+"="+value+expires+"; path="+dir;
}
function readCookie(name) {
diff --git a/sariulclocks.cabal b/sariulclocks.cabal
index 7db9ac8..e43409a 100644
--- a/sariulclocks.cabal
+++ b/sariulclocks.cabal
@@ -18,14 +18,14 @@ cabal-version: >=1.10
executable sariulclocks.cgi
main-is: sariulccgi.hs
- build-depends: base, cgi, xhtml, time, directory, filepath, split, old-time, mtl, text, boxes
+ build-depends: base, cgi, xhtml, time, directory, filepath, split, old-time, mtl, text, boxes, network
hs-source-dirs: src
default-language: Haskell2010
ld-options: -static -pthread
executable sariulccron
main-is: sariulccron.hs
- build-depends: base, cgi, xhtml, time, directory, filepath, split, old-time, mtl, text, boxes
+ build-depends: base, cgi, xhtml, time, directory, filepath, split, old-time, mtl, text, boxes, network
hs-source-dirs: src
default-language: Haskell2010
ld-options: -static -pthread
diff --git a/src/Types/Session.hs b/src/Types/Session.hs
index 2f17de9..356d1f1 100644
--- a/src/Types/Session.hs
+++ b/src/Types/Session.hs
@@ -21,8 +21,8 @@ freshSession = Session { currentClass = Nothing
-- Cookie where it uses the reader monad to get the CalendarTime and
-- maybe the session from the state monad
-makeClassCookie :: ClockTime -> Session -> Cookie
-makeClassCookie now session =
+makeClassCookie :: ClockTime -> String -> Session -> Cookie
+makeClassCookie now path session =
Cookie { cookieName = "class_cookie"
, cookieValue =
case currentClass session of
@@ -30,11 +30,11 @@ makeClassCookie now session =
Nothing -> "Nothing"
, cookieExpires = Just $ endOfSchoolDay now
, cookieDomain = Nothing
- , cookiePath = Just "/sariul/cgi-bin"
+ , cookiePath = Just path
, cookieSecure = False}
-makeClockCookie :: ClockTime -> Session -> Cookie
-makeClockCookie now session =
+makeClockCookie :: ClockTime -> String -> Session -> Cookie
+makeClockCookie now path session =
Cookie { cookieName = "clock_cookie"
, cookieValue =
case currentClock session of
@@ -42,11 +42,11 @@ makeClockCookie now session =
CountUpClock -> "1"
, cookieExpires = Just $ endOfSchoolDay now
, cookieDomain = Nothing
- , cookiePath = Just "/sariul/cgi-bin"
+ , cookiePath = Just path
, cookieSecure = False}
-makeSsCookie :: ClockTime -> Session -> Cookie
-makeSsCookie now session =
+makeSsCookie :: ClockTime -> String -> Session -> Cookie
+makeSsCookie now path session =
Cookie { cookieName = "ss_cookie"
, cookieValue =
case currentClass session of
@@ -55,7 +55,7 @@ makeSsCookie now session =
, cookieExpires = Just $ endOfSchoolDay now
, cookieDomain = Nothing
-- make the cookie path not absolute
- , cookiePath = Just "/sariul/cgi-bin"
+ , cookiePath = Just path
, cookieSecure = False}
endOfSchoolDay :: ClockTime -> CalendarTime