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 Assert(m_state
!= m_state
);
70 if(!line
.compare("new"))
72 m_sock
->Send("Starting account creation...\n");
73 m_sock
->SetEditor(new EditorNewAccount(m_sock
));
79 m_sock
->Send("Please enter your name:\n");
85 m_account
= mud::Managers::Get()->Account
->GetByName(line
);
87 OnLine(Global::Get()->EmptyString
);
89 catch(RowNotFoundException
& e
)
91 m_sock
->Send("No such account.\n");
92 OnLine(Global::Get()->EmptyString
);
102 m_sock
->Send("Please enter your password: \n");
106 if(line
.compare(m_account
->getPassword()))
108 m_sock
->Send("Password incorrect, try again.\n");
110 OnLine(Global::Get()->EmptyString
);
114 m_sock
->Sendf("Welcome back, %s\n", m_account
->getName().c_str());
116 m_sock
->SetAccount(m_account
);
117 m_sock
->SetEditor(new EditorAccount(m_sock
));
119 } /* case M_PASSWORD: */
121 } /* switch(state) */
125 bool EditorAccountLogin::canReceiveChannel(mud::ChannelPtr channel
) const
127 if(!channel
->needLogin())
133 bool EditorAccountLogin::supportPrefixes() const