From 62f7a60ff05392feffeef169f632068064f63506 Mon Sep 17 00:00:00 2001 From: onefang Date: Wed, 22 Apr 2020 20:25:49 +1000 Subject: Send the validation email. --- src/sledjchisl/sledjchisl.c | 78 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 3 deletions(-) (limited to 'src/sledjchisl') diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index c4a1ae4..87aac15 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c @@ -3082,8 +3082,15 @@ char *checkLinky(reqData *Rd) { char *t1 = qurl_encode(t0, strlen(t0)); free(ret); - ret = xmprintf("

You have an email waiting with a linky in it %s.

\n", - Rd->Host, Rd->RUri, t1, t0); + ret = xmprintf("

You have an email waiting with a validation link in it, please check your email.   " + "It will be from %s@%s, and it might be in your spam folder, coz these sorts of emails sometimes end up there.   " + "You should add that email address to your contacts, or otherwise let it through your spam filter.   " +// "%s" + "

\n", + "grid_no_reply", Rd->Host, + Rd->Host, Rd->RUri +// ,t1, t0 + ); free(t1); } return ret; @@ -3271,6 +3278,68 @@ t("Write shs %s", tnm4); free(tnm1); free(tnm0); free(file); + + + if (linky) + { +// TODO - send email. Quick and easy is to invoke the sandmail command. Later use libcurl. grid_no_reply@Rd->Host + + char *uuid = Rd->shs.UUID, *first = getStrH(Rd->stuff, "firstName"), *last = getStrH(Rd->stuff, "lastName"); +// TODO - should be from Rd.shs->linky-hashish + char *t0 = Rd->lnk->hashish, *content, *command; + + if ('\0' != t0[0]) + { + char *t1 = qurl_encode(t0, strlen(t0)); + + content = xmprintf( + "From: grid_no_reply@%s\n" + "Relpy-to: grid_no_reply@%s\n" + "Return-Path: bounce_email@%s\n" + "To: %s\n" + "Subject: Validate your new account on %s\n" + "\n" + "This is an automated validation email sent from %s.\n" + "\n" + "Dear %s %s,\n" + "\n" + "Some one has created the account '%s %s' on \n" + "https://%s%s, and hopefully it was you.\n" + "If it wasn't you, you can ignore this email.\n" + "\n" + "Please go to this web link to validate your new account -\n" + "https://%s%s?hashish=%s\n" + "\n" + "Do not replay to this email.\n" + "\n", + Rd->Host, Rd->Host, Rd->Host, + getStrH(Rd->stuff, "email"), + Rd->Host, Rd->Host, + first, last, + first, last, Rd->Host, Rd->RUri, + Rd->Host, Rd->RUri, t1 + ); + l = strlen(content); + file = xmprintf("%s/sessions/%s.email", scCache, shs->leaf); + fd = notstdio(xcreate_stdio(file, O_CREAT | O_WRONLY | O_TRUNC | O_CLOEXEC, S_IRUSR | S_IWUSR)); + + if (l != writeall(fd, content, l)) + { + perror_msg("Writing %s", file); +// freeSesh(Rd, linky, TRUE); + } + xclose(fd); + I("Sending linky email to %s %s", getStrH(Rd->stuff, "email"), t1); + command = xmprintf("sendmail -oi -t <%s", file); + int i = system(command); + if (!WIFEXITED(i)) + E("sendmail command failed!"); + free(command); + free(file); + free(content); + free(t1); + } + } } @@ -4004,6 +4073,9 @@ static int emailValidate(reqData *Rd, inputForm *iF, inputValue *iV) static void emailWeb(reqData *Rd, inputForm *oF, inputValue *oV) { HTMLtext(Rd->reply, "email", oV->field->title, oV->field->name, displayPrep(getStrH(Rd->stuff, oV->field->name)), oV->field->viewLength, oV->field->maxLength, oV->field->flags & FLD_REQUIRED); + Rd->reply->addstrf(Rd->reply, "

An email will be sent from %s@%s, and it might be in your spam folder, coz these sorts of emails sometimes end up there.   " + "You should add that email address to your contacts, or otherwise let it through your spam filter.

", + "grid_no_reply", Rd->Host); } @@ -4670,6 +4742,7 @@ static int accountAddSub(reqData *Rd, inputForm *iF, inputValue *iV) } else { + free(h); generateAccountUUID(Rd); Rd->stuff->putstr(Rd->stuff, "passwordHash", getStrH(Rd->stuff, "passHash")); @@ -4684,7 +4757,6 @@ static int accountAddSub(reqData *Rd, inputForm *iF, inputValue *iV) Rd->output = "accountView"; Rd->form = "accountView"; Rd->doit = "login"; -// TODO - send email. Quick and easy is to invoke the sandmail command. Later use libcurl. } } freeSesh(Rd, FALSE, wipe); -- cgit v1.1