Fossil SCM
implemented /json/logout.
Commit
e94605b54fa0b7ad9d53de29e2609b879274bc17
Parent
98cdd410df5134c…
1 file changed
+25
-1
+25
-1
| --- src/json.c | ||
| +++ src/json.c | ||
| @@ -543,13 +543,24 @@ | ||
| 543 | 543 | |
| 544 | 544 | tmp = cson_value_new_string(MANIFEST_UUID,strlen(MANIFEST_UUID)); |
| 545 | 545 | SET("fossil"); |
| 546 | 546 | |
| 547 | 547 | {/* "timestamp" */ |
| 548 | + cson_int_t jsTime; | |
| 549 | +#if 1 | |
| 548 | 550 | time_t const t = (time_t)time(0); |
| 549 | 551 | struct tm gt = *gmtime(&t); |
| 550 | - cson_int_t jsTime = (cson_int_t)mktime(>); | |
| 552 | + gt.tm_isdst = -1; | |
| 553 | + jsTime = (cson_int_t)mktime(>); | |
| 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 | |
| 551 | 562 | tmp = cson_value_new_integer(jsTime); |
| 552 | 563 | SET("timestamp"); |
| 553 | 564 | } |
| 554 | 565 | if( 0 != resultCode ){ |
| 555 | 566 | if( ! pMsg ) pMsg = json_err_str(resultCode); |
| @@ -754,10 +765,22 @@ | ||
| 754 | 765 | payload = cson_value_new_string( cookie, strlen(cookie) ); |
| 755 | 766 | free(cookie); |
| 756 | 767 | } |
| 757 | 768 | return payload; |
| 758 | 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 | +} | |
| 759 | 782 | |
| 760 | 783 | /* |
| 761 | 784 | ** Implementation of the /json/stat page/command. |
| 762 | 785 | ** |
| 763 | 786 | */ |
| @@ -881,10 +904,11 @@ | ||
| 881 | 904 | static const JsonPageDef JsonPageDefs[] = { |
| 882 | 905 | /* please keep alphabetically sorted (case-insensitive) for maintenance reasons. */ |
| 883 | 906 | {"cap", json_page_cap, 0}, |
| 884 | 907 | {"HAI",json_page_version,0}, |
| 885 | 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.*/}, | |
| 886 | 910 | {"stat",json_page_stat,0}, |
| 887 | 911 | {"version",json_page_version,0}, |
| 888 | 912 | {"wiki",json_page_wiki,0}, |
| 889 | 913 | /* Last entry MUST have a NULL name. */ |
| 890 | 914 | {NULL,NULL} |
| 891 | 915 |
| --- 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(>); |
| 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(>); |
| 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 |