/*
- * Perform authentication using a user name and password
+ * modal/ajax version of 'login' (username and password)
*/
-void do_login(void)
-{
- wcsession *WCC = WC;
- StrBuf *Buf;
- long ret, rc;
-
- if (havebstr("language")) {
- set_selected_language(bstr("language"));
- go_selected_language();
- }
+void ajax_login_username_password(void) {
+ StrBuf *Buf = NewStrBuf();
- if (havebstr("exit_action")) {
- do_logout();
- return;
- }
- Buf = NewStrBuf();
- if (havebstr("login_action")) {
- serv_printf("USER %s", bstr("name"));
- StrBuf_ServGetln(Buf);
- rc = GetServerStatus(Buf, &ret);
- StrBufCutLeft(Buf, 4);
- switch (rc) {
- case 3:
- serv_printf("PASS %s", bstr("pass"));
- StrBuf_ServGetln(Buf);
- if (GetServerStatus(Buf, NULL) == 2) {
- become_logged_in(sbstr("name"), sbstr("pass"), Buf);
- } else {
- StrBufCutLeft(Buf, 4);
- AppendImportantMessage(SKEY(Buf));
- display_login();
- FreeStrBuf(&Buf);
- return;
- }
- break;
- case 5:
- if (ret == 541)
- {
- AppendImportantMessage(SKEY(Buf));
- display_main_menu();
- return;
- }
- default:
- AppendImportantMessage(SKEY(Buf));
- display_login();
- FreeStrBuf(&Buf);
- return;
- }
- }
- if (havebstr("newuser_action")) {
- if (!havebstr("pass")) {
- AppendImportantMessage(_("Blank passwords are not allowed."), -1);
- display_login();
- FreeStrBuf(&Buf);
- return;
- }
- serv_printf("NEWU %s", bstr("name"));
+ serv_printf("USER %s", bstr("name"));
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) == 3) {
+ serv_printf("PASS %s", bstr("pass"));
StrBuf_ServGetln(Buf);
if (GetServerStatus(Buf, NULL) == 2) {
become_logged_in(sbstr("name"), sbstr("pass"), Buf);
- serv_printf("SETP %s", bstr("pass"));
- StrBuf_ServGetln(Buf); /* Don't care? */
- } else {
- StrBufCutLeft(Buf, 4);
- AppendImportantMessage(SKEY(Buf));
- display_login();
- FreeStrBuf(&Buf);
- return;
- }
- }
- if (WCC->logged_in) {
- if (WCC->need_regi) {
- display_reg(1);
- } else if (WCC->need_vali) {
- validate();
- } else {
- do_welcome();
}
- } else {
- AppendImportantMessage(_("Your password was not accepted."), -1);
- display_login();
}
+
+ /* The client is expecting to read back a citadel protocol response */
+ wc_printf("%s", ChrPtr(Buf));
FreeStrBuf(&Buf);
}
/*
- * modal/ajax version of 'login' (username and password)
+ * modal/ajax version of 'new user' (username and password)
*/
-void ajax_login_username_password(void) {
+void ajax_login_newuser(void) {
StrBuf *Buf = NewStrBuf();
- serv_printf("USER %s", bstr("name"));
+ serv_printf("NEWU %s", bstr("name"));
StrBuf_ServGetln(Buf);
- if (GetServerStatus(Buf, NULL) == 3) {
- serv_printf("PASS %s", bstr("pass"));
+ if (GetServerStatus(Buf, NULL) == 2) {
+ serv_printf("SETP %s", bstr("pass"));
StrBuf_ServGetln(Buf);
if (GetServerStatus(Buf, NULL) == 2) {
become_logged_in(sbstr("name"), sbstr("pass"), Buf);
return;
}
- convenience_page("770000", _("Error"), &buf[4]);
+ begin_burst();
+ output_headers(1, 0, 0, 0, 1, 0);
+ wc_printf("<html><body>");
+ escputs(&buf[4]);
+ wc_printf("</body></html>");
+ end_burst();
}
*/
/*
+ * FIXME make this work again!!!!
+ *
else if (!strcasecmp(ChrPtr(result), "verify_only")) {
putbstr("__claimed_id", claimed_id);
claimed_id = NULL;
/* Did we manage to log in? If so, continue with the normal flow... */
if (WC->logged_in) {
-
begin_burst();
output_headers(1, 0, 0, 0, 1, 0);
do_template("authpopup_finished", NULL);
end_burst();
- /* FIXME make all this crap work again
+ /* FIXME make this work again. Maybe put it in authpopup_finished?
if (WC->need_regi) {
display_reg(1);
- } else {
- do_welcome();
}
*/
} else {
- /* maybe do something prettier here? */
- convenience_page("770000", _("Error"), _("Error") );
+ begin_burst();
+ output_headers(1, 0, 0, 0, 1, 0);
+ wc_printf("<html><body>");
+ wc_printf(_("An error has occurred.")); /* FIXME do something prettier here */
+ wc_printf("</body></html>");
+ end_burst();
}
FreeStrBuf(&result);
int ConditionalAide(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
- return (WCC != NULL)? (WC->is_aide == 0) : 0;
+ return (WCC != NULL) ? ((WCC->logged_in == 0)||(WC->is_aide == 0)) : 0;
}
int ConditionalIsLoggedIn(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
- return (WCC != NULL)? (WCC->logged_in == 0) : 0;
+ return (WCC != NULL) ? (WCC->logged_in == 0) : 0;
}
/* some of these will be removed soon */
WebcitAddUrlHandler(HKEY("do_welcome"), "", 0, do_welcome, ANONYMOUS|COOKIEUNNEEDED);
- WebcitAddUrlHandler(HKEY("login"), "", 0, do_login, ANONYMOUS|COOKIEUNNEEDED);
WebcitAddUrlHandler(HKEY("openid_login"), "", 0, do_openid_login, ANONYMOUS);
WebcitAddUrlHandler(HKEY("finalize_openid_login"), "", 0, finalize_openid_login, ANONYMOUS);
WebcitAddUrlHandler(HKEY("openid_manual_create"), "", 0, openid_manual_create, ANONYMOUS);
WebcitAddUrlHandler(HKEY("changepw"), "", 0, changepw, 0);
WebcitAddUrlHandler(HKEY("termquit"), "", 0, do_logout, 0);
WebcitAddUrlHandler(HKEY("do_logout"), "", 0, do_logout, ANONYMOUS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
- WebcitAddUrlHandler(HKEY("ajax_login_username_password"), "", 0,
- ajax_login_username_password, AJAX|ANONYMOUS);
-
+ WebcitAddUrlHandler(HKEY("ajax_login_username_password"), "", 0, ajax_login_username_password, AJAX|ANONYMOUS);
+ WebcitAddUrlHandler(HKEY("ajax_login_newuser"), "", 0, ajax_login_newuser, AJAX|ANONYMOUS);
RegisterConditional(HKEY("COND:AIDE"), 2, ConditionalAide, CTX_NONE);
RegisterConditional(HKEY("COND:LOGGEDIN"), 2, ConditionalIsLoggedIn, CTX_NONE);
RegisterConditional(HKEY("COND:MAY_CREATE_ROOM"), 2, ConditionalHaveAccessCreateRoom, CTX_NONE);