Check for success on user creation
[blerg.git] / cgi / cgi_blerg.c
index abf1237..becaa96 100644 (file)
@@ -294,10 +294,14 @@ int main(int argc, char *argv[]) {
                }
 
                struct blerg *b = blerg_open(username);
-               blerg_close(b);
-               auth_set_password(username, password);
-               
-               respond_JSON_Success();
+               if (b != NULL) {
+                       blerg_close(b);
+                       auth_set_password(username, password);
+                       
+                       respond_JSON_Success();
+               } else {
+                       respond_JSON_Failure();
+               }
        } else if (strncmp(path, "/login", 7) == 0) {
                if (strcmp(request_method, "POST") != 0) {
                        respond_405();