Esempio n. 1
0
 public function getPasswordService()
 {
     if (!$this->passwordService) {
         $this->passwordService = new PasswordService($this->getPasswordGateway(), $this->getTokenGenerator(), $this->getValidator());
         if ($this->logger) {
             $this->passwordService->setLogger($this->logger);
         }
         // this might be better to be set only if the storage is instantiated already!
         $this->passwordService->setStorage($this->getStorage());
     }
     return $this->passwordService;
 }
Esempio n. 2
0
<?php

require_once "../services/PasswordService.php";
require_once "../assets/php/JsonResponse.php";
$service = new PasswordService();
$response = new JsonResponse();
if (isset($_POST) && isset($_POST['action']) && $_POST["action"] == "add") {
    $record = $service->Create($_POST["password"]);
    $html = getRow($record);
    $response->successful("Successfully added a new password", $record, $html);
} else {
    if (isset($_POST) && isset($_POST['action']) && $_POST["action"] == "delete") {
        $record = $service->Delete($_POST['id']);
        $response->successful("Successfully deleted a password", $record);
    } else {
        if (isset($_POST) && isset($_POST['action']) && $_POST["action"] == "edit") {
            $record = $service->Update($_POST["password"]);
            $html = getRow($record);
            $response->successful("Successfully updated the password", $record, $html);
        } else {
            if (isset($_POST) && isset($_POST['id'])) {
                $record = $service->Get($_POST['id']);
                $response->successful("Successfully retrieved the password", $record);
            } else {
                $records = $service->Get();
                $html = "<table style='margin-bottom: 0;' class='table table-condensed table-bordered table-hover'><thead><tr>";
                $html .= "<th>Place</th>";
                $html .= "<th>Username</th>";
                $html .= "<th>Password</th>";
                $html .= "</tr></thead><tbody>";
                for ($i = 0; $i < count($records); $i++) {