diff options
| -rwxr-xr-x | src/site.clj | 17 | ||||
| -rwxr-xr-x | static/index.html | 5 | ||||
| -rw-r--r-- | template/form_login.st | 10 |
3 files changed, 26 insertions, 6 deletions
diff --git a/src/site.clj b/src/site.clj index f10f925..996fe4e 100755 --- a/src/site.clj +++ b/src/site.clj @@ -264,6 +264,13 @@ (set-cookie :token "dummy" :expires "Thu, 01-Jan-70 00:00:01 GMT")) +(defn set-login-token + [nick hash] + (set-cookie :token (generate-login-token nick hash) + :expires (gmt-string (new Date + (+ (System/currentTimeMillis) + *login-cookie-duration*))))) + (defn apply-login-info [request user-info] (let [req-cookies (request :cookies) @@ -308,13 +315,13 @@ (let [nick (params :nick) hash (params :hash) db-user (authorize-nick-hash nick hash) - remember-me (params :rememberme)] + remember-me (= (params :rememberme) "yes") + login-cookie (if remember-me + (set-login-token nick hash) + (clear-login-token))] (if db-user [(session-assoc-from-db db-user) - (set-cookie :token (generate-login-token nick hash) - :expires (gmt-string (new Date - (+ (System/currentTimeMillis) - *login-cookie-duration*)))) + login-cookie (resp-success "OK")] (resp-error "BAD_LOGIN")))) diff --git a/static/index.html b/static/index.html index a963264..7710601 100755 --- a/static/index.html +++ b/static/index.html @@ -175,6 +175,11 @@ line-height:-1; <input type="text" id="nickInput" size="17" /> <input id="passwordInputLabel" name="passwordInputLabel" size="17" type="text" class="invisible"> <input type="password" id="passwordInput" size="17" /> + + <label> + <input type="checkbox" name="rememberme" id="remembermeInput" /> + Remember Me + </label> <!-- <br /><a id="signin-submit">Sign In</a> --> <input id="signin-submit" value="Sign In" /> </div> diff --git a/template/form_login.st b/template/form_login.st index ea2d020..8b126ff 100644 --- a/template/form_login.st +++ b/template/form_login.st @@ -15,6 +15,14 @@ <input id="passwordInputLabel" name="passwordInputLabel" tabindex="5" type="text" class="invisible"> <input id="passwordInput" name="passwordInput" title="password" tabindex="5" type="password"> </p> + + <p> + <label> + <input type="checkbox" name="rememberme" id="remembermeInput" /> + Remember Me + </label> + </p> + <p class="remember"><br> <img src="/static/signin.gif" id="signin-submit"> @@ -26,4 +34,4 @@ <script src="/static/js/home.js" type="text/javascript"></script> <script type="text/javascript"> jQuery(document).ready(initExpandableLoginForm) -</script>
\ No newline at end of file +</script> |
