68 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			68 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include "StdAfx.h"
 | |
| 
 | |
| #include "connect.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 = FALSE;
 | |
| 	m_strUser = "";
 | |
| 	int total = Server().ForEachConnection(CountUser, (void *)&user);
 | |
| 	if (app == "ba0100")
 | |
| 	{
 | |
| 		ok = total == 0 && !pwd.IsEmpty();
 | |
| 	}
 | |
| 	else
 | |
| 	{
 | |
| 		ok = TRUE;
 | |
| 	}
 | |
| 	
 | |
| 	if (ok)
 | |
| 	{
 | |
| 		m_strUser = user;
 | |
| 		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;
 | |
| }
 | |
| 
 |