commit e2e7bc2
default
·
2023-05-08 07:02:45 +0000 UTC
parent 29fb145
Added a source (web, mastoapi, etc) to lastlog_write().
5 files changed,
+7,
-5
M
data.c
+2,
-2
1@@ -1575,14 +1575,14 @@ xs_list *history_list(snac *snac)
2 }
3
4
5-void lastlog_write(snac *snac)
6+void lastlog_write(snac *snac, const char *source)
7 /* writes the last time the user logged in */
8 {
9 xs *fn = xs_fmt("%s/lastlog.txt", snac->basedir);
10 FILE *f;
11
12 if ((f = fopen(fn, "w")) != NULL) {
13- fprintf(f, "%lf\n", ftime());
14+ fprintf(f, "%lf %s\n", ftime(), source);
15 fclose(f);
16 }
17 }
M
html.c
+1,
-1
1@@ -34,7 +34,7 @@ int login(snac *snac, const xs_dict *headers)
2 }
3
4 if (logged_in)
5- lastlog_write(snac);
6+ lastlog_write(snac, "web");
7
8 return logged_in;
9 }
M
main.c
+2,
-0
1@@ -145,6 +145,8 @@ int main(int argc, char *argv[])
2 return 1;
3 }
4
5+ lastlog_write(&snac, "cmdline");
6+
7 if (strcmp(cmd, "resetpwd") == 0) {
8 return resetpwd(&snac);
9 }
+1,
-1
1@@ -854,7 +854,7 @@ int process_auth_token(snac *snac, const xs_dict *req)
2 logged_in = 1;
3
4 /* this counts as a 'login' */
5- lastlog_write(snac);
6+ lastlog_write(snac, "mastoapi");
7
8 srv_debug(2, xs_fmt("mastoapi auth: valid token for user %s", uid));
9 }
M
snac.h
+1,
-1
1@@ -142,7 +142,7 @@ xs_str *history_get(snac *snac, const char *id);
2 int history_del(snac *snac, const char *id);
3 xs_list *history_list(snac *snac);
4
5-void lastlog_write(snac *snac);
6+void lastlog_write(snac *snac, const char *source);
7
8 xs_str *notify_check_time(snac *snac, int reset);
9 void notify_add(snac *snac, const char *type, const char *utype,