diff options
| -rw-r--r-- | data.c | 13 | ||||
| -rw-r--r-- | html.c | 7 | ||||
| -rw-r--r-- | snac.h | 2 |
3 files changed, 20 insertions, 2 deletions
| @@ -1366,6 +1366,19 @@ d_char *history_list(snac *snac) | |||
| 1366 | } | 1366 | } |
| 1367 | 1367 | ||
| 1368 | 1368 | ||
| 1369 | void lastlog_write(snac *snac) | ||
| 1370 | /* writes the last time and date the user logged in */ | ||
| 1371 | { | ||
| 1372 | xs *fn = xs_fmt("%s/lastlog.txt", snac->basedir); | ||
| 1373 | FILE *f; | ||
| 1374 | |||
| 1375 | if ((f = fopen(fn, "w")) != NULL) { | ||
| 1376 | fprintf(f, "%lf\n", ftime()); | ||
| 1377 | fclose(f); | ||
| 1378 | } | ||
| 1379 | } | ||
| 1380 | |||
| 1381 | |||
| 1369 | /** inbox collection **/ | 1382 | /** inbox collection **/ |
| 1370 | 1383 | ||
| 1371 | void inbox_add(const char *inbox) | 1384 | void inbox_add(const char *inbox) |
| @@ -13,11 +13,11 @@ | |||
| 13 | 13 | ||
| 14 | #include "snac.h" | 14 | #include "snac.h" |
| 15 | 15 | ||
| 16 | int login(snac *snac, char *headers) | 16 | int login(snac *snac, const xs_dict *headers) |
| 17 | /* tries a login */ | 17 | /* tries a login */ |
| 18 | { | 18 | { |
| 19 | int logged_in = 0; | 19 | int logged_in = 0; |
| 20 | char *auth = xs_dict_get(headers, "authorization"); | 20 | const char *auth = xs_dict_get(headers, "authorization"); |
| 21 | 21 | ||
| 22 | if (auth && xs_startswith(auth, "Basic ")) { | 22 | if (auth && xs_startswith(auth, "Basic ")) { |
| 23 | int sz; | 23 | int sz; |
| @@ -33,6 +33,9 @@ int login(snac *snac, char *headers) | |||
| 33 | } | 33 | } |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | if (logged_in) | ||
| 37 | lastlog_write(snac); | ||
| 38 | |||
| 36 | return logged_in; | 39 | return logged_in; |
| 37 | } | 40 | } |
| 38 | 41 | ||
| @@ -132,6 +132,8 @@ d_char *history_get(snac *snac, char *id); | |||
| 132 | int history_del(snac *snac, char *id); | 132 | int history_del(snac *snac, char *id); |
| 133 | d_char *history_list(snac *snac); | 133 | d_char *history_list(snac *snac); |
| 134 | 134 | ||
| 135 | void lastlog_write(snac *snac); | ||
| 136 | |||
| 135 | void inbox_add(const char *inbox); | 137 | void inbox_add(const char *inbox); |
| 136 | void inbox_add_by_actor(const xs_dict *actor); | 138 | void inbox_add_by_actor(const xs_dict *actor); |
| 137 | xs_list *inbox_list(void); | 139 | xs_list *inbox_list(void); |