Files correlati : Ricompilazione Demo : [ ] Commento : Migliorie varie sul frontend git-svn-id: svn://10.65.10.50/trunk@7679 c028cbd2-c16b-5b4b-a496-9718f37d4682
85 lines
1.9 KiB
C++
Executable File
85 lines
1.9 KiB
C++
Executable File
#include "StdAfx.h"
|
|
|
|
#include "connect.h"
|
|
#include "server.h"
|
|
|
|
static int CountPeerUser(TConnection& conn, void* pJolly)
|
|
{
|
|
const CString& strPeerUser = *(CString*)pJolly;
|
|
const int at = strPeerUser.Find('@');
|
|
const CString strUser = strPeerUser.Left(at);
|
|
|
|
const TPrassiConnection& c = (TPrassiConnection&)conn;
|
|
CString pu = c.User();
|
|
if (pu != strUser)
|
|
return 0;
|
|
|
|
pu += "@";
|
|
pu += c.PeerName();
|
|
return strPeerUser != pu;
|
|
}
|
|
|
|
BOOL TPrassiConnection::DoUserLogin(const CString& user,
|
|
const CString& pwd,
|
|
const CString& app)
|
|
{
|
|
BOOL ok = GetServer().SerialNumber() != 0xFFFF;
|
|
|
|
if (ok)
|
|
{
|
|
if (user != "******" && user != "GUEST")
|
|
{
|
|
CString security = GetIniString("Server", "Security", "0");
|
|
if (atoi(security) > 0)
|
|
{
|
|
CString strPeerUser = user; strPeerUser.MakeUpper();
|
|
strPeerUser += "@";
|
|
strPeerUser += PeerName();
|
|
|
|
int total = Server().ForEachConnection(CountPeerUser,
|
|
(void*)&strPeerUser);
|
|
ok = total == 0;
|
|
}
|
|
}
|
|
|
|
if (ok)
|
|
{
|
|
m_strUser = user; m_strUser.MakeUpper();
|
|
m_strApp = app; m_strApp.MakeUpper();
|
|
}
|
|
}
|
|
return ReturnBool(ok);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// BOOL UserLogin(CString user, CString pwd, CString app)
|
|
//
|
|
// Esegue il login dell'utente user con password opzionale
|
|
|
|
int f_UserLogin(TConnection& conn, void* pJolly)
|
|
{
|
|
CStringArray& argv = *(CStringArray*)pJolly;
|
|
const int argc = argv.GetSize();
|
|
if (argc > 3)
|
|
{
|
|
TPrassiConnection& c = (TPrassiConnection&)conn;
|
|
return c.DoUserLogin(argv[1], argv[2], argv[3]);
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// BOOL UserLogout()
|
|
|
|
int f_UserLogout(TConnection& conn, void* pJolly)
|
|
{
|
|
return ((TPrassiConnection&)conn).DoUserLogout();
|
|
}
|
|
|
|
BOOL TPrassiConnection::DoUserLogout()
|
|
{
|
|
ReturnBool(TRUE);
|
|
return TRUE;
|
|
}
|
|
|