New function lastlog_write().

This commit is contained in:
default 2023-04-05 23:46:51 +02:00
parent 7c00a9918a
commit 1fe34ffb4a
3 changed files with 20 additions and 2 deletions

13
data.c
View File

@ -1366,6 +1366,19 @@ d_char *history_list(snac *snac)
}
void lastlog_write(snac *snac)
/* writes the last time and date 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());
fclose(f);
}
}
/** inbox collection **/
void inbox_add(const char *inbox)

7
html.c
View File

@ -13,11 +13,11 @@
#include "snac.h"
int login(snac *snac, char *headers)
int login(snac *snac, const xs_dict *headers)
/* tries a login */
{
int logged_in = 0;
char *auth = xs_dict_get(headers, "authorization");
const char *auth = xs_dict_get(headers, "authorization");
if (auth && xs_startswith(auth, "Basic ")) {
int sz;
@ -33,6 +33,9 @@ int login(snac *snac, char *headers)
}
}
if (logged_in)
lastlog_write(snac);
return logged_in;
}

2
snac.h
View File

@ -132,6 +132,8 @@ d_char *history_get(snac *snac, char *id);
int history_del(snac *snac, char *id);
d_char *history_list(snac *snac);
void lastlog_write(snac *snac);
void inbox_add(const char *inbox);
void inbox_add_by_actor(const xs_dict *actor);
xs_list *inbox_list(void);