75 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			75 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include "StdAfx.h"
 | 
						|
 | 
						|
#include "connect.h"
 | 
						|
#include "server.h"
 | 
						|
 | 
						|
int CountUser(TConnection& conn, void* pJolly)
 | 
						|
{
 | 
						|
	const CString& user = *(CString*)pJolly;
 | 
						|
	const TPrassiConnection& c = (TPrassiConnection&)conn;
 | 
						|
	return user.CompareNoCase(c.User()) == 0;
 | 
						|
}
 | 
						|
 | 
						|
BOOL TPrassiConnection::DoUserLogin(const CString& user, 
 | 
						|
									const CString& pwd, 
 | 
						|
									const CString& app)
 | 
						|
{
 | 
						|
	BOOL ok = GetServer().SerialNumber() != 0xFFFF;
 | 
						|
 | 
						|
	if (ok)
 | 
						|
	{
 | 
						|
		m_strUser = "";
 | 
						|
		int total = Server().ForEachConnection(CountUser, (void *)&user);
 | 
						|
		if (app == "ba0100")
 | 
						|
		{
 | 
						|
			if (user == "******")
 | 
						|
				ok = !pwd.IsEmpty();
 | 
						|
			else
 | 
						|
				ok = total == 0 && !pwd.IsEmpty();
 | 
						|
		}
 | 
						|
		else
 | 
						|
		{
 | 
						|
			ok = total == 1;
 | 
						|
		}
 | 
						|
		
 | 
						|
		if (ok)
 | 
						|
		{
 | 
						|
			m_strUser = user; m_strUser.MakeUpper();
 | 
						|
			m_strApp = app;
 | 
						|
		}
 | 
						|
	}
 | 
						|
	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;
 | 
						|
}
 | 
						|
 |