X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fauth.c;h=0c4e76b516b04b0eb9f23297ae8454923fccff91;hb=3d6fea2eca29405b8a90d91ee862e5a30aebdd3b;hp=d85ad0cb2c09bf377caf807c2d356d8a21a47462;hpb=2362c3d4de86f20822ab81015222a196137fd20e;p=citadel.git diff --git a/webcit/auth.c b/webcit/auth.c index d85ad0cb2..0c4e76b51 100644 --- a/webcit/auth.c +++ b/webcit/auth.c @@ -8,6 +8,9 @@ #include "webserver.h" #include + +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. @@ -38,9 +41,9 @@ void display_login(char *mesg) output_headers(1, 1, 2, 0, 0, 0); wprintf("
\n"); - if (mesg != NULL) if (!IsEmptyStr(mesg)) { - stresc(buf, SIZ, mesg, 0, 0); - svprintf(HKEY("MESG"), WCS_STRING, "%s", buf); + if ((mesg != NULL) && (!IsEmptyStr(mesg))) { + stresc(buf, SIZ, mesg, 0, 0); + svprintf(HKEY("MESG"), WCS_STRING, "%s", buf); } svprintf(HKEY("LOGIN_INSTRUCTIONS"), WCS_STRING, @@ -94,7 +97,7 @@ void display_login(char *mesg) svput("OFFER_OPENID_LOGIN", WCS_STRING, ""); } - do_template("login"); + do_template("login", NULL); wDumpContent(2); } @@ -113,9 +116,9 @@ void display_openid_login(char *mesg) output_headers(1, 1, 2, 0, 0, 0); wprintf("
\n"); - if (mesg != NULL) if (!IsEmptyStr(mesg)) { - stresc(buf, SIZ, mesg, 0, 0); - svprintf(HKEY("MESG"), WCS_STRING, "%s", buf); + if ((mesg != NULL) && (!IsEmptyStr(mesg))) { + stresc(buf, SIZ, mesg, 0, 0); + svprintf(HKEY("MESG"), WCS_STRING, "%s", buf); } svprintf(HKEY("LOGIN_INSTRUCTIONS"), WCS_STRING, @@ -150,7 +153,7 @@ void display_openid_login(char *mesg) "Log in using a user name and password" ); - do_template("openid_login"); + do_template("openid_login", NULL); wDumpContent(2); } @@ -185,7 +188,7 @@ void display_openid_name_request(char *claimed_id, char *username) { svprintf(HKEY("BOXTITLE"), WCS_STRING, _("%s - powered by Citadel"), serv_info.serv_humannode); - do_template("openid_manual_create"); + do_template("openid_manual_create", NULL); wDumpContent(2); } @@ -206,6 +209,7 @@ void display_openid_name_request(char *claimed_id, char *username) { void become_logged_in(char *user, char *pass, char *serv_response) { char buf[SIZ]; + StrBuf *FloorDiv; WC->logged_in = 1; extract_token(WC->wc_fullname, &serv_response[4], 0, '|', sizeof WC->wc_fullname); @@ -229,7 +233,8 @@ void become_logged_in(char *user, char *pass, char *serv_response) get_pref_long("current_iconbar", &WC->current_iconbar, current_iconbar_menu); - get_preference("floordiv_expanded", &WC->floordiv_expanded); + get_preference("floordiv_expanded", &FloorDiv); + WC->floordiv_expanded = FloorDiv; } @@ -283,6 +288,7 @@ void do_login(void) } } if (WC->logged_in) { + set_preference("language", NewStrBufPlain(bstr("language"), -1), 1); if (WC->need_regi) { display_reg(1); } else if (WC->need_vali) { @@ -401,14 +407,14 @@ void finalize_openid_login(void) urlcontent *u; void *U; long HKLen; - char *HKey; + const char *HKey; HashPos *Cursor; Cursor = GetNewHashPos (); while (GetNextHashPos(WCC->urlstrings, Cursor, &HKLen, &HKey, &U)) { u = (urlcontent*) U; if (!strncasecmp(u->url_key, "openid.", 7)) { - serv_printf("%s|%s", &u->url_key[7], u->url_data); + serv_printf("%s|%s", &u->url_key[7], ChrPtr(u->url_data)); } } @@ -536,6 +542,8 @@ void do_welcome(void) if (ChrPtr(Buf)[0] == '/') { StrBufCutLeft(Buf, 1); } + if (StrLength(Buf) == 0) + StrBufAppendBufPlain(Buf, "dotgoto?room=_BASEROOM_", -1, 0); http_redirect(ChrPtr(Buf)); } @@ -547,7 +555,6 @@ void end_webcit_session(void) { if (WC->logged_in) { set_pref_long("current_iconbar", WC->current_iconbar, 0); - set_preference("floordiv_expanded", WC->floordiv_expanded, 1); } serv_puts("QUIT"); @@ -789,7 +796,7 @@ void display_changepw(void) output_headers(1, 1, 1, 0, 0, 0); svput("BOXTITLE", WCS_STRING, _("Change your password")); - do_template("beginbox"); + do_template("beginbox", NULL); if (!IsEmptyStr(WC->ImportantMessage)) { wprintf("" @@ -823,7 +830,7 @@ void display_changepw(void) wprintf("
\n"); wprintf("\n"); - do_template("endbox"); + do_template("endbox", NULL); wDumpContent(1); } @@ -875,10 +882,48 @@ void changepw(void) } } +int ConditionalAide(WCTemplateToken *Token, void *Context, int ContextType) +{ + return (WC->is_aide == 0); +} +int ConditionalRoomAide(WCTemplateToken *Token, void *Context, int ContextType) +{ + return (WC->is_room_aide == 0); +} -void InitModule_AUTH(void) +int ConditionalRoomAcessDelete(WCTemplateToken *Token, void *Context, int ContextType) { - WebcitAddUrlHandler(HKEY("do_welcome"), do_welcome, 0); + struct wcsession *WCC = WC; + return ( (WCC->is_room_aide) || (WCC->is_mailbox) || (WCC->room_flags2 & QR2_COLLABDEL) ); +} + + + +void _display_openid_login(void) {display_openid_login(NULL);} +void _display_reg(void) {display_reg(0);} + + +void +InitModule_AUTH +(void) +{ + WebcitAddUrlHandler(HKEY("do_welcome"), do_welcome, ANONYMOUS); + WebcitAddUrlHandler(HKEY("login"), do_login, ANONYMOUS); + WebcitAddUrlHandler(HKEY("display_openid_login"), _display_openid_login, ANONYMOUS); + WebcitAddUrlHandler(HKEY("openid_login"), do_openid_login, ANONYMOUS); + WebcitAddUrlHandler(HKEY("finalize_openid_login"), finalize_openid_login, ANONYMOUS); + WebcitAddUrlHandler(HKEY("openid_manual_create"), openid_manual_create, ANONYMOUS); + WebcitAddUrlHandler(HKEY("do_logout"), do_logout, 0); + WebcitAddUrlHandler(HKEY("validate"), validate, 0); + WebcitAddUrlHandler(HKEY("display_reg"), _display_reg, 0); + WebcitAddUrlHandler(HKEY("display_changepw"), display_changepw, 0); + WebcitAddUrlHandler(HKEY("changepw"), changepw, 0); + WebcitAddUrlHandler(HKEY("termquit"), do_logout, 0); + + RegisterConditional(HKEY("COND:AIDE"), 2, ConditionalAide, CTX_NONE); + RegisterConditional(HKEY("COND:ROOMAIDE"), 2, ConditionalRoomAide, CTX_NONE); + RegisterConditional(HKEY("COND:ACCESS:DELETE"), 2, ConditionalRoomAcessDelete, CTX_NONE); + return ; }