aboutsummaryrefslogtreecommitdiff
path: root/ctl.c
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-09-19 22:27:31 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-09-19 22:27:31 +0200
commitfd9e2f7245212f2b652652f4669648260e59f9e9 (patch)
tree35e12c2f78cde9338f34780921cd8020eea1bbb4 /ctl.c
parent93c1df59ef14348e9a3e1d66ea0b96960f5b5732 (diff)
downloadcforum-fd9e2f7245212f2b652652f4669648260e59f9e9.tar.gz
Add bcrypt
Diffstat (limited to 'ctl.c')
-rw-r--r--ctl.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/ctl.c b/ctl.c
index 58db942..cd90f4f 100644
--- a/ctl.c
+++ b/ctl.c
@@ -37,6 +37,19 @@ printhtml(char *s)
}
}
+void
+login()
+{
+ char *hlite, msg[MAXMSG], *name;
+ char title[] = "Log In";
+
+ *msg = 0;
+ hlite = name = NULL;
+
+ printf("Content-Type: text/html\n\n");
+ #include "t/login.tc"
+}
+
/*
* The `new' functions provide a way to add a new attachment/post/user.
* On GET, they show a form. On POST, they insert the posted information
@@ -145,13 +158,15 @@ newuser()
"Full name may only contain visible characters");
goto err;
}
-
- /* Ensure all required fields are there. */
+
+ /* Validate captcha. */
if(captcha && strcmp(captcha, "9") != 0){
hlite = strdup("captcha");
snprintf(msg, MAXMSG, "Incorrectly answered captcha");
goto err;
}
+
+ /* Ensure all required fields are there. */
if(!name || !*name){
hlite = strdup("name");
snprintf(msg, MAXMSG, "Username is required");
@@ -173,7 +188,7 @@ newuser()
user->name = name;
user->full = *full? full: NULL;
- user->hash = pass; /* TODO */
+ makehash(pass, &user->hash, &user->salt);
if(!adduser(user)){
if(strcmp(sqlite3_errmsg(db), "column name is not unique")==0)