-/*
- * Perform authentication using a user name 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();
- }
-
- 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"));
- 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();
- }
- FreeStrBuf(&Buf);
-}
-
-
-