1 /***************************************************************************
2 * Copyright (C) 2008 by Sverre Rabbelier *
3 * sverre@rabbelier.nl *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "EditorNewAccount.h"
22 #include "EditorAccountLogin.h"
23 #include "EditorAccount.h"
27 #include "AccountManager.h"
33 EditorAccountLogin::EditorAccountLogin(UBSocket
* sock
) :
38 OnLine(Global::Get()->EmptyString
);
41 EditorAccountLogin::~EditorAccountLogin(void)
45 void EditorAccountLogin::OnLine(const std::string
&line
)
47 if(!line
.compare("quit"))
49 m_sock
->Send("Goodbye!\n");
50 m_sock
->SetCloseAndDelete();
58 Global::Get()->bug("EditorAccountLogin::OnLine(), default m_state!\n");
59 m_sock
->Send("BUG! Disconnecting you now...\n");
60 m_sock
->SetCloseAndDelete();
72 if(!line
.compare("new"))
74 m_sock
->Send("Starting account creation...\n");
75 m_sock
->SetEditor(new EditorNewAccount(m_sock
));
81 m_sock
->Send("Please enter your name:\n");
87 m_account
= mud::Managers::Get()->Account
->GetByName(line
);
89 OnLine(Global::Get()->EmptyString
);
91 catch(RowNotFoundException
& e
)
93 m_sock
->Send("No such account.\n");
94 OnLine(Global::Get()->EmptyString
);
104 m_sock
->Send("Please enter your password: \n");
108 if(line
.compare(m_account
->getPassword()))
110 m_sock
->Send("Password incorrect, try again.\n");
112 OnLine(Global::Get()->EmptyString
);
116 m_sock
->Sendf("Welcome back, %s\n", m_account
->getName().c_str());
118 m_sock
->SetAccount(m_account
);
119 m_sock
->SetEditor(new EditorAccount(m_sock
));
121 } /* case M_PASSWORD: */
123 } /* switch(state) */
127 bool EditorAccountLogin::canReceiveChannel(mud::ChannelPtr channel
) const
129 if(!channel
->needLogin())
135 bool EditorAccountLogin::supportPrefixes() const