diff --git a/Sources/src/data/model/CoachAthlete.php b/Sources/src/data/model/CoachAthlete.php new file mode 100644 index 00000000..b7578a85 --- /dev/null +++ b/Sources/src/data/model/CoachAthlete.php @@ -0,0 +1,7 @@ +currentUser)) { + this->currentUser = authService->currentUser; + } } } \ No newline at end of file diff --git a/Sources/src/data/stub/StubData.php b/Sources/src/data/stub/StubData.php index 6cd06efd..03b73d2f 100644 --- a/Sources/src/data/stub/StubData.php +++ b/Sources/src/data/stub/StubData.php @@ -7,9 +7,11 @@ use Stub\UserRepository; class StubData extends DataManager{ public function __construct(){ - $this->userMgr = new UserManager(new AuthService(new UserRepository(),new HashPassword())); - if($this->userMgr->currentUser->Role) - $this->coachMgr = new CoachManager(); + $userRepository = new \Stub\UserRepository(); + $authService = new \Stub\AuthService($userRepository,new HashPassword()); + $this->userMgr = new UserManager($authService); +// if($this->userMgr->currentUser->Role ) // is an instance of ... + $this->coachMgr->currentUser = new CoachManager($authService); // if(user.Role is instance of Coach) { // this->CoachMgr = new CoachManager(); // } diff --git a/Sources/src/data/stub/service/AuthService.php b/Sources/src/data/stub/service/AuthService.php index 0b1e170e..0b8ba248 100644 --- a/Sources/src/data/stub/service/AuthService.php +++ b/Sources/src/data/stub/service/AuthService.php @@ -11,6 +11,9 @@ use Stub\UserRepository; class AuthService implements IAuthService { private $userRepository; private $passwordHasher; + + private $currentUser; + public function __construct(UserRepository $userRepository, IHashPassword $passwordHasher) { $this->userRepository = $userRepository; $this->passwordHasher = $passwordHasher; @@ -23,7 +26,7 @@ class AuthService implements IAuthService { throw new \Exception('Unable to find user with that name'); } if ($user->isValidPassword($password)) { - return $user; + return this->currentUser = $user; } return null; }