extern uint32_t hashlittle( const void *key, size_t length, uint32_t initval);
-void display_reg(int during_login);
-
/*
* Access level definitions. This is initialized from a function rather than a
* static array so that the strings may be localized.
}
WCC->axlevel = StrBufExtract_int(serv_response, 1, '|');
- if (WCC->axlevel >= 6) { /* TODO: make this a define, else it might trick us later */
+ if (WCC->axlevel >= 6) {
WCC->is_aide = 1;
}
get_preference("floordiv_expanded", &FloorDiv);
WCC->floordiv_expanded = FloorDiv;
FreeStrBuf(&Buf);
+ FlushRoomlist();
}
{
StrBuf *Buf;
+ /* Did the user change his mind? Pack up and go home. */
if (havebstr("exit_action")) {
- do_logout();
+ begin_burst();
+ output_headers(1, 0, 0, 0, 1, 0);
+ do_template("authpopup_finished", NULL);
+ end_burst();
return;
}
- if (havebstr("newuser_action")) {
- Buf = NewStrBuf();
- serv_printf("OIDC %s", bstr("name"));
- StrBuf_ServGetln(Buf);
- if (GetServerStatus(Buf, NULL) == 2) {
- StrBuf *gpass;
-
- gpass = NewStrBuf();
- serv_puts("SETP GENERATE_RANDOM_PASSWORD");
- StrBuf_ServGetln(gpass);
- StrBufCutLeft(gpass, 4);
- become_logged_in(sbstr("name"), gpass, Buf);
- FreeStrBuf(&gpass);
- }
- FreeStrBuf(&Buf);
+
+ /* Ok, let's give this a try. Can we create the new user? */
+
+ Buf = NewStrBuf();
+ serv_printf("OIDC %s", bstr("name"));
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) == 2) {
+ StrBuf *gpass;
+
+ gpass = NewStrBuf();
+ serv_puts("SETP GENERATE_RANDOM_PASSWORD");
+ StrBuf_ServGetln(gpass);
+ StrBufCutLeft(gpass, 4);
+ become_logged_in(sbstr("name"), gpass, Buf);
+ FreeStrBuf(&gpass);
}
+ FreeStrBuf(&Buf);
+ /* Did we manage to log in? If so, continue with the normal flow... */
if (WC->logged_in) {
- if (WC->need_regi) {
- display_reg(1);
- } else if (WC->need_vali) {
- validate();
- } else {
- do_welcome();
+ if (WC->logged_in) {
+ begin_burst();
+ output_headers(1, 0, 0, 0, 1, 0);
+ do_template("authpopup_finished", NULL);
+ end_burst();
}
} else {
+ /* Still no good! Go back to teh dialog to select a username */
const StrBuf *Buf;
-
putbstr("__claimed_id", NewStrBufDup(sbstr("openid_url")));
Buf = sbstr("name");
if (StrLength(Buf) > 0)
putbstr("__username", NewStrBufDup(Buf));
begin_burst();
+ output_headers(1, 0, 0, 0, 1, 0);
+ wc_printf("<html><body>");
do_template("openid_manual_create", NULL);
+ wc_printf("</body></html>");
end_burst();
}
{
StrBuf *Buf;
wcsession *WCC = WC;
- int already_logged_in = (WCC->logged_in) ;
int linecount = 0;
StrBuf *result = NULL;
StrBuf *username = NULL;
}
}
- /* If we were already logged in, this was an attempt to associate an OpenID account
- FIXME put this back in
- if (already_logged_in) {
+ /*
+ * Is this an attempt to associate a new OpenID with an account that is already logged in?
+ */
+ if ( (WCC->logged_in) && (havebstr("attach_existing")) ) {
display_openids();
- FreeStrBuf(&result);
- FreeStrBuf(&username);
- FreeStrBuf(&password);
- FreeStrBuf(&claimed_id);
- FreeStrBuf(&logged_in_response);
- return;
}
- */
/* If this operation logged us in, either by connecting with an existing account or by
* auto-creating one using Simple Registration Extension, we're already on our way.
*/
- if (!strcasecmp(ChrPtr(result), "authenticate")) {
+ else if (!strcasecmp(ChrPtr(result), "authenticate")) {
become_logged_in(username, password, logged_in_response);
+
+ /* 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();
+ } else {
+ begin_burst();
+ output_headers(1, 0, 0, 0, 1, 0);
+ wc_printf("<html><body>");
+ wc_printf(_("An error has occurred."));
+ wc_printf("</body></html>");
+ end_burst();
+ }
}
- /* The specified OpenID was verified but the desired user name was either not specified via SRI
+ /* The specified OpenID was verified but the desired user name was either not specified via SRE
* or conflicts with an existing user. Either way the user will need to specify a new name.
*/
-
-/*
- * FIXME make this work again!!!!
- *
else if (!strcasecmp(ChrPtr(result), "verify_only")) {
putbstr("__claimed_id", claimed_id);
claimed_id = NULL;
username = NULL;
}
begin_burst();
+ output_headers(1, 0, 0, 0, 1, 0);
+ wc_printf("<html><body>");
do_template("openid_manual_create", NULL);
+ wc_printf("</body></html>");
end_burst();
}
-*/
-
-
- /* 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();
- } else {
+ /* Something went VERY wrong if we get to this point */
+ else {
+ syslog(1, "finalize_openid_login() failed to do anything. This is a code problem.\n");
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(_("An error has occurred."));
wc_printf("</body></html>");
end_burst();
}
buf[strlen(buf)-1] = 0;
fclose(fp);
if (atoi(buf) == serv_info.serv_rev_level) {
- setup_wizard = 1; /**< already run */
+ setup_wizard = 1; /* already run */
}
}
}
/* close() of citadel socket will be done by do_housekeeping() */
}
+
/*
- * execute the logout
+ * Log out the session with the Citadel server
*/
void do_logout(void)
{
FlushStrBuf(WCC->wc_username);
FlushStrBuf(WCC->wc_password);
FlushStrBuf(WCC->wc_fullname);
+ FlushRoomlist();
serv_puts("LOUT");
serv_getln(buf, sizeof buf);
}
-
/*
* Display form for registration.
*
FreeStrBuf(&ReturnTo);
}
- /* FIXME - don't we have to free VCMsg and VCAtt ?? */
}
-
-
/*
* display form for changing your password
*/
}
}
+
int ConditionalHaveAccessCreateRoom(StrBuf *Target, WCTemplputParams *TP)
{
StrBuf *Buf;
return 1;
}
+
int ConditionalAide(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
return (WCC != NULL) ? ((WCC->logged_in == 0)||(WC->is_aide == 0)) : 0;
}
+
int ConditionalIsLoggedIn(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
}
+/*
+ * toggle the session over to a different language
+ */
+void switch_language(void) {
+ set_selected_language(bstr("lang"));
+ pop_destination();
+}
+
void _display_reg(void) {
display_reg(0);
}
}
+
void CheckAuthBasic(ParsedHttpHdrs *hdr)
{
/*
*/
}
+
void GetAuthBasic(ParsedHttpHdrs *hdr)
{
const char *Pos = NULL;
StrBufExtract_NextToken(hdr->c_password, hdr->HR.plainauth, &Pos, ':');
}
+
void Header_HandleCookie(StrBuf *Line, ParsedHttpHdrs *hdr)
{
const char *pch;
hdr->HR.got_auth = AUTH_COOKIE;
}
+
void
HttpNewModule_AUTH
(ParsedHttpHdrs *httpreq)
httpreq->c_roomname = NewStrBuf();
httpreq->c_language = NewStrBuf();
}
+
+
void
HttpDetachModule_AUTH
(ParsedHttpHdrs *httpreq)
FLUSHStrBuf(httpreq->c_language);
}
+
void
HttpDestroyModule_AUTH
(ParsedHttpHdrs *httpreq)
FreeStrBuf(&httpreq->c_language);
}
+
void
InitModule_AUTH
(void)
/* no url pattern at all? Show login. */
WebcitAddUrlHandler(HKEY(""), "", 0, do_welcome, ANONYMOUS|COOKIEUNNEEDED);
- /* some of these will be removed soon */
WebcitAddUrlHandler(HKEY("do_welcome"), "", 0, do_welcome, ANONYMOUS|COOKIEUNNEEDED);
WebcitAddUrlHandler(HKEY("openid_login"), "", 0, do_openid_login, ANONYMOUS);
WebcitAddUrlHandler(HKEY("finalize_openid_login"), "", 0, finalize_openid_login, ANONYMOUS);
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_newuser"), "", 0, ajax_login_newuser, AJAX|ANONYMOUS);
+ WebcitAddUrlHandler(HKEY("switch_language"), "", 0, switch_language, 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);