mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 05:15:04 +00:00
Added a source (web, mastoapi, etc) to lastlog_write().
This commit is contained in:
parent
29fb145fc4
commit
e2e7bc2d71
5 changed files with 7 additions and 5 deletions
4
data.c
4
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 */
|
/* writes the last time the user logged in */
|
||||||
{
|
{
|
||||||
xs *fn = xs_fmt("%s/lastlog.txt", snac->basedir);
|
xs *fn = xs_fmt("%s/lastlog.txt", snac->basedir);
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
if ((f = fopen(fn, "w")) != NULL) {
|
if ((f = fopen(fn, "w")) != NULL) {
|
||||||
fprintf(f, "%lf\n", ftime());
|
fprintf(f, "%lf %s\n", ftime(), source);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
html.c
2
html.c
|
@ -34,7 +34,7 @@ int login(snac *snac, const xs_dict *headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (logged_in)
|
if (logged_in)
|
||||||
lastlog_write(snac);
|
lastlog_write(snac, "web");
|
||||||
|
|
||||||
return logged_in;
|
return logged_in;
|
||||||
}
|
}
|
||||||
|
|
2
main.c
2
main.c
|
@ -145,6 +145,8 @@ int main(int argc, char *argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastlog_write(&snac, "cmdline");
|
||||||
|
|
||||||
if (strcmp(cmd, "resetpwd") == 0) {
|
if (strcmp(cmd, "resetpwd") == 0) {
|
||||||
return resetpwd(&snac);
|
return resetpwd(&snac);
|
||||||
}
|
}
|
||||||
|
|
|
@ -854,7 +854,7 @@ int process_auth_token(snac *snac, const xs_dict *req)
|
||||||
logged_in = 1;
|
logged_in = 1;
|
||||||
|
|
||||||
/* this counts as a 'login' */
|
/* 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));
|
srv_debug(2, xs_fmt("mastoapi auth: valid token for user %s", uid));
|
||||||
}
|
}
|
||||||
|
|
2
snac.h
2
snac.h
|
@ -142,7 +142,7 @@ xs_str *history_get(snac *snac, const char *id);
|
||||||
int history_del(snac *snac, const char *id);
|
int history_del(snac *snac, const char *id);
|
||||||
xs_list *history_list(snac *snac);
|
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);
|
xs_str *notify_check_time(snac *snac, int reset);
|
||||||
void notify_add(snac *snac, const char *type, const char *utype,
|
void notify_add(snac *snac, const char *type, const char *utype,
|
||||||
|
|
Loading…
Reference in a new issue