summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-05-08 09:02:45 +0200
committerdefault <nobody@localhost>2023-05-08 09:02:45 +0200
commite2e7bc2d713e469d5af61f58dc85c063bba94e42 (patch)
tree799482b6085d6807f0471798c6244cc3e6f770b0
parent29fb145fc471034d563ec49d19f4a2da6e330ff1 (diff)
Added a source (web, mastoapi, etc) to lastlog_write().
-rw-r--r--data.c4
-rw-r--r--html.c2
-rw-r--r--main.c2
-rw-r--r--mastoapi.c2
-rw-r--r--snac.h2
5 files changed, 7 insertions, 5 deletions
diff --git a/data.c b/data.c
index 72b63f8..92574c2 100644
--- a/data.c
+++ b/data.c
@@ -1575,14 +1575,14 @@ xs_list *history_list(snac *snac)
}
-void lastlog_write(snac *snac)
+void lastlog_write(snac *snac, const char *source)
/* writes the last time the user logged in */
{
xs *fn = xs_fmt("%s/lastlog.txt", snac->basedir);
FILE *f;
if ((f = fopen(fn, "w")) != NULL) {
- fprintf(f, "%lf\n", ftime());
+ fprintf(f, "%lf %s\n", ftime(), source);
fclose(f);
}
}
diff --git a/html.c b/html.c
index 8d4203d..1227cfe 100644
--- a/html.c
+++ b/html.c
@@ -34,7 +34,7 @@ int login(snac *snac, const xs_dict *headers)
}
if (logged_in)
- lastlog_write(snac);
+ lastlog_write(snac, "web");
return logged_in;
}
diff --git a/main.c b/main.c
index 3f34673..322aa67 100644
--- a/main.c
+++ b/main.c
@@ -145,6 +145,8 @@ int main(int argc, char *argv[])
return 1;
}
+ lastlog_write(&snac, "cmdline");
+
if (strcmp(cmd, "resetpwd") == 0) {
return resetpwd(&snac);
}
diff --git a/mastoapi.c b/mastoapi.c
index b82ecfa..1b9ab09 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -854,7 +854,7 @@ int process_auth_token(snac *snac, const xs_dict *req)
logged_in = 1;
/* this counts as a 'login' */
- lastlog_write(snac);
+ lastlog_write(snac, "mastoapi");
srv_debug(2, xs_fmt("mastoapi auth: valid token for user %s", uid));
}
diff --git a/snac.h b/snac.h
index 6a8092a..2a66255 100644
--- a/snac.h
+++ b/snac.h
@@ -142,7 +142,7 @@ xs_str *history_get(snac *snac, const char *id);
int history_del(snac *snac, const char *id);
xs_list *history_list(snac *snac);
-void lastlog_write(snac *snac);
+void lastlog_write(snac *snac, const char *source);
xs_str *notify_check_time(snac *snac, int reset);
void notify_add(snac *snac, const char *type, const char *utype,