src/server/daemon/auth.c

changeset 467
4d038bc6f86e
parent 415
d938228c382e
child 490
d218607f5a7e
--- a/src/server/daemon/auth.c	Sun Mar 12 11:42:17 2023 +0100
+++ b/src/server/daemon/auth.c	Sun Mar 12 20:02:04 2023 +0100
@@ -283,34 +283,18 @@
  * from public/auth.h
  */
 
-User* authdb_get_user(AuthDB *db, const char *user) {
+User* authdb_get_user(AuthDB *db, Session *sn, Request *rq, const char *user) {
     if(db->use_cache) {
         User *u = auth_cache_get(db->name, user);
         if(u) {
             return u;
         }
     }
-    return db->get_user(db, user);
+    return db->get_user(db, sn, rq, user);
 }
 
-User* authdb_get_and_verify(AuthDB *db, const char *user, const char *password, int *pw) {
-    User *u = NULL;
-    // try getting the user from the cache
-    if(db->use_cache) {
-        u = auth_cache_get(db->name, user);
-        if(u) {
-            if(u->verify_password(u, password)) {
-                *pw = 1;
-            } else {
-                *pw = 0;
-                u->free(u);
-                u = NULL;
-            }
-            return u;
-        }
-    }
-    // user not cached
-    u = db->get_user(db, user);
+User* authdb_get_and_verify(AuthDB *db, Session *sn, Request *rq, const char *user, const char *password, int *pw) {
+    User *u = authdb_get_user(db, sn, rq, user);
     if(u) {
         if(u->verify_password(u, password)) {
             if(db->use_cache) {

mercurial