Logo Search packages:      
Sourcecode: verlihub version File versions

int nDirectConnect::nProtocol::cDCProto::DC_MyPass ( cMessageDC msg,
cConnDC conn 
) [protected]

Treat the DC message in a appropriate way

Definition at line 249 of file cdcproto.cpp.

References nDirectConnect::nTables::cBanList::AddNickTempBan(), nDirectConnect::cUser::CheckPwd(), nDirectConnect::cServerDC::ConnCloseMsg(), nDirectConnect::cServerDC::DCHello(), cObj::Log(), nDirectConnect::nTables::cRegList::Login(), nDirectConnect::nTables::cRegList::LoginError(), cObj::LogStream(), nDirectConnect::cServerDC::mBanList, nDirectConnect::cUserBase::mClass, nDirectConnect::cUserBase::mNick, nDirectConnect::cConnDC::mpUser, nDirectConnect::cServerDC::mR, nServer::cAsyncSocketServer::mTime, nDirectConnect::cUser::Register(), nUtils::cTime::Sec(), nDirectConnect::cConnDC::Send(), nDirectConnect::cConnDC::SetLSFlag(), and nDirectConnect::nProtocol::cMessageDC::SplitChunks().

{
      if(msg->SplitChunks()) return -1;
      string &pwd=msg->ChunkString(eCH_1_PARAM);

      string omsg;
      
      if(!conn->mpUser)
      {
            omsg = "Bad Login sequence, you must provide a valid nick first.";
            if(conn->Log(1))conn->LogStream() << "Mypass before validatenick" << endl;
            return -1;
            mS->ConnCloseMsg(conn,omsg,1000, eCR_LOGIN_ERR);
      }
      if(conn->mpUser->CheckPwd(pwd)) // check the password
      {
            conn->SetLSFlag( eLS_PASSWD );
            // setup the user class..
            conn->mpUser->Register();
            mS->mR->Login(conn, conn->mpUser->mNick);
            mS->DCHello(conn->mpUser->mNick,conn);
            // if op .. send LoggedIn and Oplist
            if(conn->mpUser->mClass >= eUC_OPERATOR)
            {
                  omsg = "$LogedIn ";
                  omsg+= conn->mpUser->mNick;
                  conn->Send(omsg, true);
            }
      }
      else // wrong password
      {
            omsg="$BadPass";
            conn->Send(omsg);
            omsg="You provided wrong password, 30s ban.";
            mS->mBanList->AddNickTempBan(conn->mpUser->mNick, mS->mTime.Sec() + 30, omsg);
/*#else
            cBan Ban;
            mS->mBanList->NewBan(Ban, conn, mS->mEmpty, omsg, 30u, int(cBan::eBF_NICK));
            mS->mBanList->AddBan(Ban);
#endif*/
            mS->mR->LoginError(conn, conn->mpUser->mNick);
            if(conn->Log(2)) conn->LogStream() << "Wrong password, ban " << 30 <<"s, closing" << endl;
            mS->ConnCloseMsg(conn, omsg, 2000, eCR_PASSWORD);
            return -1;
      }
      return 0;
}


Generated by  Doxygen 1.6.0   Back to index