Fossil SCM

implemented /json/logout.

stephan 2011-09-16 19:27 UTC json
Commit e94605b54fa0b7ad9d53de29e2609b879274bc17
1 file changed +25 -1
+25 -1
--- src/json.c
+++ src/json.c
@@ -543,13 +543,24 @@
543543
544544
tmp = cson_value_new_string(MANIFEST_UUID,strlen(MANIFEST_UUID));
545545
SET("fossil");
546546
547547
{/* "timestamp" */
548
+ cson_int_t jsTime;
549
+#if 1
548550
time_t const t = (time_t)time(0);
549551
struct tm gt = *gmtime(&t);
550
- cson_int_t jsTime = (cson_int_t)mktime(&gt);
552
+ gt.tm_isdst = -1;
553
+ jsTime = (cson_int_t)mktime(&gt);
554
+#else
555
+ /* i'm not 100% sure that the above actually does what i expect,
556
+ but we can't use the following because this function can be
557
+ called in response to error handling if the db cannot be opened
558
+ (or before that).
559
+ */
560
+ jsTime = (cson_int_t)db_int64(0, "SELECT strftime('%%s','now')");
561
+#endif
551562
tmp = cson_value_new_integer(jsTime);
552563
SET("timestamp");
553564
}
554565
if( 0 != resultCode ){
555566
if( ! pMsg ) pMsg = json_err_str(resultCode);
@@ -754,10 +765,22 @@
754765
payload = cson_value_new_string( cookie, strlen(cookie) );
755766
free(cookie);
756767
}
757768
return payload;
758769
}
770
+
771
+/*
772
+** Impl of /json/logout.
773
+**
774
+** Shortcomings: this never reports failure, as we don't go through
775
+** the trouble of actually checking whether the user is logged in or
776
+** not.
777
+*/
778
+cson_value * json_page_logout(void){
779
+ login_clear_login_data();
780
+ return NULL;
781
+}
759782
760783
/*
761784
** Implementation of the /json/stat page/command.
762785
**
763786
*/
@@ -881,10 +904,11 @@
881904
static const JsonPageDef JsonPageDefs[] = {
882905
/* please keep alphabetically sorted (case-insensitive) for maintenance reasons. */
883906
{"cap", json_page_cap, 0},
884907
{"HAI",json_page_version,0},
885908
{"login",json_page_login,1/*should be >0. Only 0 for dev/testing purposes.*/},
909
+{"logout",json_page_logout,1/*should be >0. Only 0 for dev/testing purposes.*/},
886910
{"stat",json_page_stat,0},
887911
{"version",json_page_version,0},
888912
{"wiki",json_page_wiki,0},
889913
/* Last entry MUST have a NULL name. */
890914
{NULL,NULL}
891915
--- src/json.c
+++ src/json.c
@@ -543,13 +543,24 @@
543
544 tmp = cson_value_new_string(MANIFEST_UUID,strlen(MANIFEST_UUID));
545 SET("fossil");
546
547 {/* "timestamp" */
 
 
548 time_t const t = (time_t)time(0);
549 struct tm gt = *gmtime(&t);
550 cson_int_t jsTime = (cson_int_t)mktime(&gt);
 
 
 
 
 
 
 
 
 
551 tmp = cson_value_new_integer(jsTime);
552 SET("timestamp");
553 }
554 if( 0 != resultCode ){
555 if( ! pMsg ) pMsg = json_err_str(resultCode);
@@ -754,10 +765,22 @@
754 payload = cson_value_new_string( cookie, strlen(cookie) );
755 free(cookie);
756 }
757 return payload;
758 }
 
 
 
 
 
 
 
 
 
 
 
 
759
760 /*
761 ** Implementation of the /json/stat page/command.
762 **
763 */
@@ -881,10 +904,11 @@
881 static const JsonPageDef JsonPageDefs[] = {
882 /* please keep alphabetically sorted (case-insensitive) for maintenance reasons. */
883 {"cap", json_page_cap, 0},
884 {"HAI",json_page_version,0},
885 {"login",json_page_login,1/*should be >0. Only 0 for dev/testing purposes.*/},
 
886 {"stat",json_page_stat,0},
887 {"version",json_page_version,0},
888 {"wiki",json_page_wiki,0},
889 /* Last entry MUST have a NULL name. */
890 {NULL,NULL}
891
--- src/json.c
+++ src/json.c
@@ -543,13 +543,24 @@
543
544 tmp = cson_value_new_string(MANIFEST_UUID,strlen(MANIFEST_UUID));
545 SET("fossil");
546
547 {/* "timestamp" */
548 cson_int_t jsTime;
549 #if 1
550 time_t const t = (time_t)time(0);
551 struct tm gt = *gmtime(&t);
552 gt.tm_isdst = -1;
553 jsTime = (cson_int_t)mktime(&gt);
554 #else
555 /* i'm not 100% sure that the above actually does what i expect,
556 but we can't use the following because this function can be
557 called in response to error handling if the db cannot be opened
558 (or before that).
559 */
560 jsTime = (cson_int_t)db_int64(0, "SELECT strftime('%%s','now')");
561 #endif
562 tmp = cson_value_new_integer(jsTime);
563 SET("timestamp");
564 }
565 if( 0 != resultCode ){
566 if( ! pMsg ) pMsg = json_err_str(resultCode);
@@ -754,10 +765,22 @@
765 payload = cson_value_new_string( cookie, strlen(cookie) );
766 free(cookie);
767 }
768 return payload;
769 }
770
771 /*
772 ** Impl of /json/logout.
773 **
774 ** Shortcomings: this never reports failure, as we don't go through
775 ** the trouble of actually checking whether the user is logged in or
776 ** not.
777 */
778 cson_value * json_page_logout(void){
779 login_clear_login_data();
780 return NULL;
781 }
782
783 /*
784 ** Implementation of the /json/stat page/command.
785 **
786 */
@@ -881,10 +904,11 @@
904 static const JsonPageDef JsonPageDefs[] = {
905 /* please keep alphabetically sorted (case-insensitive) for maintenance reasons. */
906 {"cap", json_page_cap, 0},
907 {"HAI",json_page_version,0},
908 {"login",json_page_login,1/*should be >0. Only 0 for dev/testing purposes.*/},
909 {"logout",json_page_logout,1/*should be >0. Only 0 for dev/testing purposes.*/},
910 {"stat",json_page_stat,0},
911 {"version",json_page_version,0},
912 {"wiki",json_page_wiki,0},
913 /* Last entry MUST have a NULL name. */
914 {NULL,NULL}
915

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button