Advertisement
tlmarker1968

Untitled

Jan 23rd, 2020
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.95 KB | None | 0 0
  1. <?php
  2.     /**
  3.      * Phoenix Hospitality Management System
  4.      * Phoenix REST API - API Security Service file
  5.      * Written in PHP using the Slim microframework
  6.      *
  7.      * @author Troy L. Marker
  8.      * @version 0.5.0
  9.      * @since 0.5.0
  10.      * @copyright Copyright (c) 2020 By Troy Marker Enterprises
  11.      *
  12.      * Declare namespace and Import needed functions/classes
  13.      */
  14.     namespace App\Domain\Service;
  15.  
  16.     use App\Domain\Data\LoggingUser as LoggingUser;
  17.     use App\Domain\Data\CurrentUser as CurrentUser;
  18.     use App\Domain\Repository\Security as SecurityRepository;
  19.     use UnexpectedValueException;
  20.  
  21.     /**
  22.      * This class provides the service calls for the Security Service file
  23.      */
  24.     final class Security {
  25.         private $repository;
  26.  
  27.         /**
  28.          * This method constructs the service and injects the Security Repository
  29.          *
  30.          * @param SecurityRepository $repository - The repository being injected
  31.          */
  32.         public function __construct(SecurityRepository $repository) {
  33.             $this->repository = $repository;
  34.         }
  35.    
  36.         /**
  37.          * This method logs a user onto the system.
  38.          */
  39.         public function login(LoggingUser $loggingUser) {
  40.             var_dump($loggingUser);
  41.             $return_value['success'] = false;
  42.             $return_value['message'] = '';
  43.             if(!$logginguser->username){
  44.                 $return_value['message'] = 'username field  required in Security::login';
  45.             } else {
  46.                 if (!$loggeduser->password) {
  47.                     $return_value['message'] = 'password field required in Security::login';
  48.                 } else {
  49.                     $return_value['success'] = true;
  50.                     $return_value['message'] = 'User successfully retreived';
  51.                     $return_value['data'] = $this->repository->login($loggingUser);
  52.                 }
  53.             }
  54.         }
  55.  
  56.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement