#include "login_2.h"

// Author: Steve Talbot

login_2:: login_2(){
}

login_2:: ~login_2(){
}

bool login_2:: login( int y_, Data* data_, MDA_EFSM* M_ ){

	// NOTE: this version still assumes 1 user has access to file
	//       at a time (no concurrent access).  However,
	//		 this version _always_ uses the latest "file copy",
	//		 never the "local copy" ..

	// should handle loading in the correct “accountInfo”
	// from file if necessary, HERE ..

	bool isFileLoaded = data_->loadAccountInfoFromFile( y_ );

	if( isFileLoaded == true ) {

		// indicate that the "current account info" is coming from the file ..
		// in preparation / anticipation of the next step yielding a correct "pin" ..
		data_->setIsCurrentAccountFromFile( true );

		data_->setTempId( y_ );

		bool result = M_->correct_login();

		return result;

	} else {

		// indicate that the "current account info" is NOT coming from the file ..
		data_->setIsCurrentAccountFromFile( false );

		bool result = M_->incorrect_login();

		return result;

	}

	// default (shouldn't reach this point) ..
	bool result = M_->incorrect_login();
	return result;

} // end "login()" ..
