* modal/ajax version of 'login' (username and password)
*/
void ajax_login_username_password(void) {
- StrBuf *Buf;
+ StrBuf *Buf = NewStrBuf();
serv_printf("USER %s", bstr("name"));
StrBuf_ServGetln(Buf);
StrBuf_ServGetln(Buf);
if (GetServerStatus(Buf, NULL) == 2) {
become_logged_in(sbstr("name"), sbstr("pass"), Buf);
- wc_printf("FIXME success");
}
}
- wc_printf("FIXME %s", ChrPtr(Buf));
-
+ /* The client is expecting to read back a citadel protocol response */
+ wc_printf("%s", ChrPtr(Buf));
FreeStrBuf(&Buf);
}
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 ;
+ return;
}
--- /dev/null
+/*
+ * Copyright 2010, the Citadel Team
+ * Licensed under the GPL V3
+ *
+ * JavaScript functions which handle various authentication methods.
+ */
+
+
+/*
+ * Wrapper script to require logging in before completing an action
+ */
+function GetLoggedInFirst(destination_url) {
+
+ /* If logged in already, go directly to the destination. */
+ /* FIXME implement this */
+
+ /* If not logged in, go modal and ask the user to log in first. */
+ p = 'do_template?template=get_logged_in?destination_url=' + destination_url;
+ new Ajax.Updater(
+ 'md-content',
+ p,
+ {
+ method: 'get',
+ onSuccess: function(cl_success) {
+ toggleModal(1);
+ }
+ }
+ );
+}
+
+
+/*
+ * Attempt login with username/password, called from modal dialog
+ */
+function ajax_try_username_and_password(destination_url) {
+ $('login_errmsg').innerHTML = "";
+ $('ajax_username_password_form').request({
+ onSuccess: function(ctdlresult) {
+ if (ctdlresult.responseText.substr(0,1) == '2') {
+ window.location = destination_url;
+ }
+ else {
+ $('login_errmsg').innerHTML = ctdlresult.responseText.substr(4) ;
+ }
+ }
+ });
+}
<title>Citadel Instant Messenger</title>
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="wclib.js"></script>
+ <script type="text/javascript" src="authmethods.js"></script>
</head>
<body onLoad='FetchNewMsgs();'>
<script type="text/javascript" src="static/datepicker-dev.js"></script>
<script type="text/javascript" src="static/table.js"></script>
<script type="text/javascript" src="static/wclib.js"></script>
+ <script type="text/javascript" src="static/authmethods.js"></script>
<meta http-equiv="refresh" content="15; URL=do_template?template=aide_display_menu"/>
</head>
<body>
<script type="text/javascript" src="static/datepicker-dev.js"></script>
<script type="text/javascript" src="static/table.js"></script>
<script type="text/javascript" src="static/wclib.js"></script>
+ <script type="text/javascript" src="static/authmethods.js"></script>
<meta http-equiv="refresh" content="40; URL=server_shutdown?when=now"/>
</head>
<body>
<a href="javascript:toggleModal(0);"><img src="static/closewindow.gif" border="0"></a>
</div>
<div align="center">
-To complete this action, you must log in.<br>
+To complete this action, you must log in. FIXME localize this string.<br>
+<div class="login_message" id="login_errmsg"></div>
<hr>
-<form method="POST" id="ajax_login_username_password">
+<form id="ajax_username_password_form" method="POST" action="ajax_login_username_password">
<table border=0 cellspacing=0 cellpadding=0><tr>
<td><?_("User name:")></td>
<td><input type="text" name="name" id="uname"></td>
</tr></table>
</form>
<hr>
-<a href="<?BSTR("destination_url")>">Proceed and fail</a><br>
+<a href="javascript:ajax_try_username_and_password('<?BSTR("destination_url")>');">Proceed and be clueless</a><br>
<a href="javascript:toggleModal(0);"><?_("Cancel")></a>
</div>
</body>
<script type="text/javascript" src="static/wcpref.js"></script>
<script type="text/javascript" src="static/table.js"></script>
<script type="text/javascript" src="static/wclib.js"></script>
+ <script type="text/javascript" src="static/authmethods.js"></script>
<script type="text/javascript" src="static/roomops.js"></script>
<script type="text/javascript" src="static/ctdldragdrop.js"></script>
<script type="text/javascript" src="static/modal.js"></script>
}
);
}
-
-
-/*
- * Wrapper script to require logging in before completing an action
- */
-function GetLoggedInFirst(destination_url) {
-
- /* If logged in already, go directly to the destination. */
- /* FIXME implement this */
-
- /* If not logged in, go modal and ask the user to log in first. */
- p = 'do_template?template=get_logged_in?destination_url=' + destination_url;
- new Ajax.Updater(
- 'md-content',
- p,
- {
- method: 'get',
- onSuccess: function(cl_success) {
- toggleModal(1);
- }
- }
- );
-}