* $Id$
*
* WebcitAuth; Handles authentication of users to a Citadel server.
+ *
+ * Copyright (c) 1996-2010 by the citadel.org team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "webcit.h"
const char *pch;
pch = ChrPtr(Buf) + 4;
- WCC->new_mail = StrBufExtractNext_long(Buf, &pch, '|');
+ /*WCC->new_mail =*/ StrBufExtractNext_long(Buf, &pch, '|');
WCC->need_regi = StrBufExtractNext_long(Buf, &pch, '|');
WCC->need_vali = StrBufExtractNext_long(Buf, &pch, '|');
if (WCC->cs_inet_email == NULL)
{
wcsession *WCC = WC;
StrBuf *Buf;
+ long ret, rc;
if (havebstr("language")) {
set_selected_language(bstr("language"));
if (havebstr("login_action")) {
serv_printf("USER %s", bstr("name"));
StrBuf_ServGetln(Buf);
- if (GetServerStatus(Buf, NULL) == 3) {
+ 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 {
- snprintf(WCC->ImportantMessage,
- sizeof (WCC->ImportantMessage),
- "%s",
- &(ChrPtr(Buf))[4]);
+ StrBufCutLeft(Buf, 4);
+ AppendImportantMessage(SKEY(Buf));
display_login();
FreeStrBuf(&Buf);
return;
}
- } else {
- snprintf(WCC->ImportantMessage,
- sizeof (WCC->ImportantMessage),
- "%s",
- &(ChrPtr(Buf))[4]);
+ 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")) {
- snprintf(WCC->ImportantMessage,
- sizeof (WCC->ImportantMessage),
- "%s",
- _("Blank passwords are not allowed."));
+ AppendImportantMessage(_("Blank passwords are not allowed."), -1);
display_login();
FreeStrBuf(&Buf);
return;
serv_printf("SETP %s", bstr("pass"));
StrBuf_ServGetln(Buf); /* Don't care? */
} else {
- snprintf(WCC->ImportantMessage,
- sizeof (WCC->ImportantMessage),
- "%s",
- &(ChrPtr(Buf))[4]);
+ StrBufCutLeft(Buf, 4);
+ AppendImportantMessage(SKEY(Buf));
display_login();
FreeStrBuf(&Buf);
return;
do_welcome();
}
} else {
- snprintf(WCC->ImportantMessage,
- sizeof (WCC->ImportantMessage),
- "%s",
- _("Your password was not accepted."));
+ AppendImportantMessage(_("Your password was not accepted."), -1);
display_login();
}
FreeStrBuf(&Buf);
}
}
+int ConditionalHaveAccessCreateRoom(StrBuf *Target, WCTemplputParams *TP)
+{
+ StrBuf *Buf;
+
+ Buf = NewStrBuf();
+ serv_puts("CRE8 0");
+ StrBuf_ServGetln(Buf);
+
+ if (GetServerStatus(Buf, NULL) == 2) {
+ StrBufCutLeft(Buf, 4);
+ AppendImportantMessage(SKEY(Buf));
+ FreeStrBuf(&Buf);
+ return 0;
+ }
+ FreeStrBuf(&Buf);
+ return 1;
+}
+
int ConditionalAide(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
InitModule_AUTH
(void)
{
+ initialize_axdefs();
RegisterHeaderHandler(HKEY("COOKIE"), Header_HandleCookie);
RegisterHeaderHandler(HKEY("AUTHORIZATION"), Header_HandleAuth);
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);
return ;
}