Get login working

This commit is contained in:
Ryan Prather 2024-11-28 11:37:56 -05:00
parent 17b399aa3f
commit 2656d93208
18 changed files with 1577 additions and 15 deletions

View File

@ -0,0 +1,30 @@
<?php
namespace App\Controller;
use App\Entity\User;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\CurrentUser;
class DefaultController extends AbstractController
{
#[Route('/dashboard', name: 'app_dashboard')]
public function dashboard(Request $request, #[CurrentUser()] ?User $user): Response
{
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
if (!$user->getCompany()) {
return $this->redirectToRoute('app_register_step', ['step' => RegistrationController::REGISTER_STEP_TWO]);
}
return $this->render(
'internal/dashboard.html.twig',
[
'user' => $user
]
);
}
}

View File

@ -0,0 +1,157 @@
<?php
namespace App\Controller;
use App\DataTransferObject\CompanyDetailsDto;
use App\Entity\User;
use App\Enums\CaseLevel;
use App\Enums\JobType;
use App\Enums\RateType;
use App\Factory\CompanyFactory;
use App\Form\CompanyFormType;
use App\Form\RegistrationFormType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Security\Http\Authentication\UserAuthenticatorInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\CurrentUser;
class RegistrationController extends AbstractController
{
public const REGISTER_STEP_ONE = 'admin';
public const REGISTER_STEP_TWO = 'company';
public function __construct(
private readonly CompanyFactory $companyFactory,
private readonly RequestStack $requestStack,
private readonly EntityManagerInterface $entityManager,
private readonly UserPasswordHasherInterface $userPasswordHasher,
private readonly UserAuthenticatorInterface $userAuthenticator
) {
}
#[Route('/register/{step}', name: 'app_register_step')]
public function registerStep(string $step, Request $request, #[CurrentUser] ?User $user): Response
{
$form = match($step) {
self::REGISTER_STEP_ONE => $this->createForm(RegistrationFormType::class),
self::REGISTER_STEP_TWO => $this->renderRegisterStepTwo(),
default => $this->redirectToRoute('app_register_step', ['step' => self::REGISTER_STEP_ONE]),
};
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
return match(true) {
$step === self::REGISTER_STEP_ONE => $this->handleRegisterStepOne($form, $request),
$step === self::REGISTER_STEP_TWO => $this->handleRegisterStepTwo($form, $user),
default => $this->redirectToRoute('app_register_step', ['step' => self::REGISTER_STEP_ONE]),
};
}
return $this->render(sprintf('registration/register-step-%s.html.twig', $step), [
'form' => $form,
'data' => $form->getData(),
'admin' => $user
]);
}
private function handleRegisterStepOne(FormInterface $form, Request $request): Response
{
$user = new User();
$form = $this->createForm(RegistrationFormType::class, $user);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
// @var string $plainPassword
$plainPassword = $form->get('plainPassword')->getData();
// encode the plain password
$user->setPassword(
$this->userPasswordHasher->hashPassword(
$user,
$plainPassword
)
);
$user->setJob(JobType::ADMIN);
$user->setRateType(RateType::FIXED);
$user->setRate('0.00');
$user->setRoles(['ROLE_ADMIN']);
$user->setLevel(CaseLevel::ADMIN);
// save user
$this->entityManager->persist($user);
$this->entityManager->flush();
return $this->redirectToRoute('app_dashboard');
}
return $this->redirectToRoute('app_register_step', ['step' => self::REGISTER_STEP_ONE]);
}
private function renderRegisterStepTwo(): FormInterface
{
$company = $this->requestStack->getSession()->get('register-form-step-two');
if (!$company instanceof CompanyDetailsDto) {
$company = new CompanyDetailsDto();
}
return $this->createForm(CompanyFormType::class, $company);
}
private function handleRegisterStepTwo(FormInterface $form, User $owner): Response
{
$company = $this->companyFactory->create($form->getData(), $owner);
$owner->setCompany($company);
$this->entityManager->persist($owner);
$this->entityManager->persist($company);
$this->entityManager->flush();
return $this->redirectToRoute('app_dashboard');
}
#[Route('/new-user', name: 'app_new_user')]
public function newUser(Request $request): Response
{
return $this->render('registration/new-user.html.twig');
}
#[Route('/add-user', name: 'app_add_user')]
public function addUser(Request $request, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager): Response
{
$user = new User();
$user->setUsername('new-user');
$user->setEmail('g6eK1@example.com');
$user->setName('New User');
$user->setPassword(
$this->userPasswordHasher->hashPassword(
$user,
'password'
)
);
$user->setJob(JobType::ADMIN);
$user->setRateType(RateType::FIXED);
$user->setRate('0.00');
$entityManager->persist($user);
$entityManager->flush();
return $this->redirectToRoute('dashboard');
}
#[Route('/register', name: 'app_register')]
public function register(): Response
{
return $this->redirectToRoute('app_register_step', ['step' => self::REGISTER_STEP_ONE]);
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class SecurityController extends AbstractController
{
#[Route(path: '/', name: 'app_login')]
public function login(AuthenticationUtils $authenticationUtils): Response
{
if ($this->isGranted('IS_AUTHENTICATED_FULLY')) {
return $this->redirectToRoute('app_dashboard');
}
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('security/login.html.twig', [
'last_username' => $lastUsername,
'error' => $error,
]);
}
#[Route(path: '/logout', name: 'app_logout')]
public function logout(): void
{
}
}

View File

@ -0,0 +1,199 @@
<?php
namespace App\DataTransferObject;
class CompanyDetailsDto
{
public function __construct(
private ?string $name = null,
private ?string $address = null,
private ?string $email = null,
private ?string $phone = null,
private ?string $url = null,
private ?string $zip = null,
private ?string $city = null,
private ?string $state = null,
private ?string $owner = null,
) {
}
/**
* Get the value of name
*/
public function getName()
{
return $this->name;
}
/**
* Set the value of name
*
* @return self
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get the value of address
*/
public function getAddress()
{
return $this->address;
}
/**
* Set the value of address
*
* @return self
*/
public function setAddress($address)
{
$this->address = $address;
return $this;
}
/**
* Get the value of email
*/
public function getEmail()
{
return $this->email;
}
/**
* Set the value of email
*
* @return self
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Get the value of phone
*/
public function getPhone()
{
return $this->phone;
}
/**
* Set the value of phone
*
* @return self
*/
public function setPhone($phone)
{
$this->phone = $phone;
return $this;
}
/**
* Get the value of url
*/
public function getUrl()
{
return $this->url;
}
/**
* Set the value of url
*
* @return self
*/
public function setUrl($url)
{
$this->url = $url;
return $this;
}
/**
* Get the value of zip
*/
public function getZip()
{
return $this->zip;
}
/**
* Set the value of zip
*
* @return self
*/
public function setZip($zip)
{
$this->zip = $zip;
return $this;
}
/**
* Get the value of city
*/
public function getCity()
{
return $this->city;
}
/**
* Set the value of city
*
* @return self
*/
public function setCity($city)
{
$this->city = $city;
return $this;
}
/**
* Get the value of state
*/
public function getState()
{
return $this->state;
}
/**
* Set the value of state
*
* @return self
*/
public function setState($state)
{
$this->state = $state;
return $this;
}
/**
* Get the value of owner
*/
public function getOwner()
{
return $this->owner;
}
/**
* Set the value of owner
*
* @return self
*/
public function setOwner($owner)
{
$this->owner = $owner;
return $this;
}
}

202
src/Entity/Company.php Normal file
View File

@ -0,0 +1,202 @@
<?php
namespace App\Entity;
use App\Repository\CompanyRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity(repositoryClass: CompanyRepository::class)]
class Company
{
#[ORM\Id]
#[ORM\Column(type: UuidType::NAME, unique: true)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
private ?Uuid $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(length: 255)]
private ?string $address = null;
#[ORM\Column(length: 255)]
private ?string $city = null;
#[ORM\Column(length: 10)]
private ?string $state = null;
#[ORM\Column(length: 15)]
private ?string $zip = null;
#[ORM\Column(length: 15)]
private ?string $phone = null;
#[ORM\Column(length: 64)]
private ?string $email = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $url = null;
/**
* @var Collection<int, User>
*/
#[ORM\OneToMany(targetEntity: User::class, mappedBy: 'company')]
private Collection $users;
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
#[ORM\JoinColumn(nullable: false)]
private ?User $owner = null;
public function __construct()
{
$this->users = new ArrayCollection();
}
public function getId(): ?Uuid
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(string $address): static
{
$this->address = $address;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(string $city): static
{
$this->city = $city;
return $this;
}
public function getState(): ?string
{
return $this->state;
}
public function setState(string $state): static
{
$this->state = $state;
return $this;
}
public function getZip(): ?string
{
return $this->zip;
}
public function setZip(string $zip): static
{
$this->zip = $zip;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(string $phone): static
{
$this->phone = $phone;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): static
{
$this->email = $email;
return $this;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(?string $url): static
{
$this->url = $url;
return $this;
}
/**
* @return Collection<int, User>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): static
{
if (!$this->users->contains($user)) {
$this->users->add($user);
$user->setCompany($this);
}
return $this;
}
public function removeUser(User $user): static
{
if ($this->users->removeElement($user)) {
// set the owning side to null (unless already changed)
if ($user->getCompany() === $this) {
$user->setCompany(null);
}
}
return $this;
}
public function getOwner(): ?User
{
return $this->owner;
}
public function setOwner(User $owner): static
{
$this->owner = $owner;
return $this;
}
}

267
src/Entity/User.php Normal file
View File

@ -0,0 +1,267 @@
<?php
namespace App\Entity;
use App\Repository\UserRepository;
use App\Enums\RateType;
use App\Enums\JobType;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Uid\Uuid;
use \App\Enums\CaseLevel;
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_USERNAME', fields: ['username'])]
#[UniqueEntity(fields: ['username'], message: 'There is already an account with this username')]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\Column(type: UuidType::NAME, unique: true)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
private ?Uuid $id = null;
#[ORM\Column(length: 45)]
private ?string $username = null;
/**
* @var list<string> The user roles
*/
#[ORM\Column]
private array $roles = [];
/**
* @var string The hashed password
*/
#[ORM\Column]
private ?string $password = null;
#[ORM\Column(length: 45)]
private ?string $name = null;
#[ORM\Column(length: 45)]
private ?string $email = null;
#[ORM\Column(length: 45)]
private ?JobType $job = null;
#[ORM\Column(enumType: RateType::class)]
private ?RateType $rateType = null;
#[ORM\Column(type: Types::DECIMAL, precision: 6, scale: 2)]
private ?string $rate = null;
/**
* @var Collection<int, UserCase>
*/
#[ORM\OneToMany(targetEntity: UserCase::class, mappedBy: 'userId')]
private Collection $userCases;
#[ORM\ManyToOne(inversedBy: 'users')]
#[ORM\JoinColumn(nullable: true)]
private ?Company $company = null;
#[ORM\Column(enumType: CaseLevel::class)]
private ?CaseLevel $level = null;
public function __construct()
{
$this->userCases = new ArrayCollection();
}
public function getId(): ?Uuid
{
return $this->id;
}
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(string $username): static
{
$this->username = $username;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->username;
}
/**
* @see UserInterface
*
* @return list<string>
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
/**
* @param list<string> $roles
*/
public function setRoles(array $roles): static
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password): static
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function eraseCredentials(): void
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): static
{
$this->email = $email;
return $this;
}
public function getJob(): ?JobType
{
return $this->job;
}
public function setJob(JobType $job): static
{
$this->job = $job;
return $this;
}
public function getRateType(): ?RateType
{
return $this->rateType;
}
public function setRateType(RateType $rateType): static
{
$this->rateType = $rateType;
return $this;
}
public function getRate(): ?string
{
return $this->rate;
}
public function setRate(string $rate): static
{
$this->rate = $rate;
return $this;
}
/**
* @return Collection<int, UserCase>
*/
public function getUserCases(): Collection
{
return $this->userCases;
}
public function addUserCase(UserCase $userCase): static
{
if (!$this->userCases->contains($userCase)) {
$this->userCases->add($userCase);
$userCase->setUserId($this);
}
return $this;
}
public function removeUserCase(UserCase $userCase): static
{
if ($this->userCases->removeElement($userCase)) {
// set the owning side to null (unless already changed)
if ($userCase->getUserId() === $this) {
$userCase->setUserId(null);
}
}
return $this;
}
public function getCompany(): ?Company
{
return $this->company;
}
public function setCompany(?Company $company): static
{
$this->company = $company;
return $this;
}
public function getLevel(): ?CaseLevel
{
return $this->level;
}
public function setLevel(CaseLevel $level): static
{
$this->level = $level;
return $this;
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Factory;
use App\DataTransferObject\CompanyDetailsDto;
use App\Entity\Company;
use App\Entity\User;
final class CompanyFactory
{
public function create(
CompanyDetailsDto $companyDetails,
User $ownerDetails,
) : Company {
$company = new Company();
$company->setName($companyDetails->getName());
$company->setAddress($companyDetails->getAddress());
$company->setCity($companyDetails->getCity());
$company->setState($companyDetails->getState());
$company->setZip($companyDetails->getZip());
$company->setPhone($companyDetails->getPhone());
$company->setEmail($companyDetails->getEmail());
$company->setUrl($companyDetails->getUrl());
$company->setOwner($ownerDetails);
return $company;
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace App\Form;
use App\DataTransferObject\CompanyDetailsDto;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\UrlType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class CompanyFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('name', TextType::class, [
'required' => true,
'attr' => [
'placeholder' => 'Company Name',
'class' => 'form-control',
'autofocus' => true,
'autocomplete' => 'off'
]
])
->add('address', TextType::class, [
'required' => true
])
->add('city', TextType::class, [
'required' => true
])
->add('state', TextType::class, [
'required' => true
])
->add('zip', TextType::class, [
'required' => true
])
->add('phone', TextType::class, [
'required' => true
])
->add('email', EmailType::class, [
'required' => true
])
->add('url', UrlType::class)
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => CompanyDetailsDto::class,
]);
}
}

View File

@ -0,0 +1,47 @@
<?php
namespace App\Form;
use App\Entity\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
class RegistrationFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('name')
->add('username')
->add('email')
->add('plainPassword', PasswordType::class, [
// instead of being set onto the object directly,
// this is read and encoded in the controller
'mapped' => false,
'attr' => ['autocomplete' => 'new-password'],
'constraints' => [
new NotBlank([
'message' => 'Please enter a password',
]),
new Length([
'min' => 6,
'minMessage' => 'Your password should be at least {{ limit }} characters',
// max length allowed by Symfony for security reasons
'max' => 4096,
]),
],
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => User::class,
]);
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace App\Repository;
use App\Entity\Company;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Company>
*/
class CompanyRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Company::class);
}
// /**
// * @return Company[] Returns an array of Company objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('c')
// ->andWhere('c.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('c.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?Company
// {
// return $this->createQueryBuilder('c')
// ->andWhere('c.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@ -0,0 +1,60 @@
<?php
namespace App\Repository;
use App\Entity\User;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
/**
* @extends ServiceEntityRepository<User>
*/
class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, User::class);
}
/**
* Used to upgrade (rehash) the user's password automatically over time.
*/
public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void
{
if (!$user instanceof User) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', $user::class));
}
$user->setPassword($newHashedPassword);
$this->getEntityManager()->persist($user);
$this->getEntityManager()->flush();
}
// /**
// * @return User[] Returns an array of User objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('u')
// ->andWhere('u.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('u.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?User
// {
// return $this->createQueryBuilder('u')
// ->andWhere('u.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@ -1,17 +1,54 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="utf-8"/>
<title>{% block title %}Welcome!{% endblock %}</title> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text><text y=%221.3em%22 x=%220.2em%22 font-size=%2276%22 fill=%22%23fff%22>sf</text></svg>"> <link rel="apple-touch-icon" sizes="76x76" href="/assets/img/apple-icon.png">
{% block stylesheets %} <link rel="icon" type="image/png" href="/assets/img/favicon.png">
{% endblock %} <title>
{% block title %}CM Tracker
{% endblock %}
</title>
<!-- Fonts and icons -->
<link
rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Inter:300,400,500,600,700,900"/>
<!-- Nucleo Icons -->
<link href="/assets/css/nucleo-icons.css" rel="stylesheet"/>
<link
href="/assets/css/nucleo-svg.css" rel="stylesheet"/>
<!-- Font Awesome Icons -->
<script src="https://kit.fontawesome.com/42d5adcbca.js" crossorigin="anonymous"></script>
<!-- Material Icons -->
<link
rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@24,400,0,0"/>
<!-- CSS Files -->
<link id="pagestyle" href="/assets/css/material-dashboard.css?v=3.2.0" rel="stylesheet"/> {% block stylesheets %}{% endblock %}
</head>
{% block javascripts %} <body class="bg-gray-200"> {% block body %}{% endblock %}
{% block importmap %}{{ importmap('app') }}{% endblock %}
{% endblock %} {% block javascripts %}
</head> <script src="/assets/js/core/popper.min.js"></script>
<body> <script src="/assets/js/core/bootstrap.min.js"></script>
{% block body %}{% endblock %} <script src="/assets/js/plugins/perfect-scrollbar.min.js"></script>
</body> <script src="/assets/js/plugins/smooth-scrollbar.min.js"></script>
</html> <script>
var win = navigator.platform.indexOf('Win') > -1;
if (win && document.querySelector('#sidenav-scrollbar')) {
var options = {
damping: '0.5'
}
Scrollbar.init(document.querySelector('#sidenav-scrollbar'), options);
}
</script>
<!-- Github buttons -->
<script async defer src="https://buttons.github.io/buttons.js"></script>
<!-- Control Center for Material Dashboard: parallax effects, scripts for the example pages etc -->
<script src="/assets/js/material-dashboard.min.js?v=3.2.0"></script>
{% block importmap %}
{{ importmap('app') }}
{% endblock %}
{% endblock %}
</body>
</html>

View File

@ -0,0 +1,6 @@
{% extends 'base.html.twig' %}
{% block title %}Dashboard
{% endblock %}
{% block body %}{% endblock %}

View File

@ -0,0 +1,38 @@
{% block footer %}
<footer class="footer position-absolute bottom-2 py-2 w-100">
<div class="container">
<div class="row align-items-center justify-content-lg-between">
<div class="col-12 col-md-6 my-auto">
<div class="copyright text-center text-sm text-white text-lg-start">
©
<script>
document.write(new Date().getFullYear())
</script>,
made by
<a href="https://www.creativetim.com" class="font-weight-bold text-white" target="_blank">CreativeTim</a>
</div>
</div>
<div class="col-12 col-md-6">
<ul class="nav nav-footer justify-content-center justify-content-lg-end">
<!--
Replace with links to company
<li class="nav-item">
<a href="https://www.creative-tim.com" class="nav-link text-white" target="_blank">Creative Tim</a>
</li>
<li class="nav-item">
<a href="https://www.creative-tim.com/presentation" class="nav-link text-white" target="_blank">About Us</a>
</li>
<li class="nav-item">
<a href="https://www.creative-tim.com/blog" class="nav-link text-white" target="_blank">Blog</a>
</li>
<li class="nav-item">
<a href="https://www.creative-tim.com/license" class="nav-link pe-0 text-white" target="_blank">License</a>
</li>
-->
</ul>
</div>
</div>
</div>
</footer>
{% endblock %}

View File

@ -0,0 +1,52 @@
{% block nav %}
<!-- Navbar -->
<nav class="navbar navbar-expand-lg blur border-radius-xl top-0 z-index-3 shadow position-absolute my-3 py-2 start-0 end-0 mx-4">
<div class="container-fluid ps-2 pe-0">
<a class="navbar-brand font-weight-bolder ms-lg-0 ms-3 " href="../pages/dashboard.html">
CM Tracker
</a>
<button class="navbar-toggler shadow-none ms-2" type="button" data-bs-toggle="collapse" data-bs-target="#navigation" aria-controls="navigation" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon mt-2">
<span class="navbar-toggler-bar bar1"></span>
<span class="navbar-toggler-bar bar2"></span>
<span class="navbar-toggler-bar bar3"></span>
</span>
</button>
<div class="collapse navbar-collapse" id="navigation">
<ul class="navbar-nav mx-auto">
<li class="nav-item">
<a class="nav-link d-flex align-items-center me-2 active" aria-current="page" href="/index.php/">
<i class="fa fa-chart-pie opacity-6 text-dark me-1"></i>
Dashboard
</a>
</li>
<!-- @todo only display when logged in -->
<li class="nav-item">
<a class="nav-link me-2" href="/index.php/profile">
<i class="fa fa-user opacity-6 text-dark me-1"></i>
Profile
</a>
</li>
<li class="nav-item">
<a class="nav-link me-2" href="/index.php/">
<i class="fas fa-key opacity-6 text-dark me-1"></i>
Sign In
</a>
</li>
</ul>
<ul class="navbar-nav d-lg-flex d-none">
<!--
replace with other link
<li class="nav-item d-flex align-items-center">
<a class="btn btn-outline-primary btn-sm mb-0 me-2" target="_blank" href="https://www.creative-tim.com/builder?ref=navbar-material-dashboard">Online Builder</a>
</li>
<li class="nav-item">
<a href="https://www.creative-tim.com/product/material-dashboard" class="btn btn-sm mb-0 me-1 bg-gradient-dark">Free download</a>
</li>
-->
</ul>
</div>
</div>
</nav>
<!-- End Navbar -->
{% endblock %}

View File

@ -0,0 +1,93 @@
{% extends 'base.html.twig' %}
{% block title %}Register Admin
{% endblock %}
{% block body %}
<div class="container position-sticky z-index-sticky top-0">
<div class="row">
<div class="col-12">
{{ block("nav", "libs/nav.html.twig") }}
</div>
</div>
</div>
<main class="main-content mt-0">
<section>
<div class="page-header min-vh-100">
<div class="container">
<div class="row">
<div class="col-6 d-lg-flex d-none h-100 my-auto pe-0 position-absolute top-0 start-0 text-center justify-content-center flex-column">
<div class="position-relative bg-gradient-primary h-100 m-3 px-7 border-radius-lg d-flex flex-column justify-content-center" style="background-image: url('/assets/img/illustrations/illustration-signup.jpg'); background-size: cover;"></div>
</div>
<div class="col-xl-4 col-lg-5 col-md-7 d-flex flex-column ms-auto me-auto ms-lg-auto me-lg-5">
<div class="card card-plain">
<div class="card-header">
<h4 class="font-weight-bolder">Sign Up</h4>
<p class="mb-0">Enter your email and password to register</p>
</div>
<div class="card-body">
{{ form_errors(form) }}
{{ form_start(form) }}
<div class="input-group input-group-outline mb-3">
<label for="registration_form_name" class="form-label">Name</label>
<input type="text" name="{{ field_name(form.name) }}" placeholder="" class="form-control" required="required"/>
</div>
<div class="input-group input-group-outline mb-3">
<label for="registration_form_username" class="form-label">Username</label>
<input type="text" name="{{ field_name(form.username) }}" placeholder="" class="form-control" required="required"/>
</div>
<div class="input-group input-group-outline mb-3">
<label for="registration_form_email" class="form-label">Email</label>
<input type="email" name="{{ field_name(form.email) }}" placeholder="" class="form-control" required="required"/>
</div>
<div class="input-group input-group-outline mb-3">
<label for="registration_form_plainPassword" class="form-label">Password</label>
<input type="password" name="{{ field_name(form.plainPassword) }}" placeholder="" class="form-control" required="required"/>
</div>
<div class="text-center">
<button type="submit" class="btn btn-lg bg-gradient-dark btn-lg w-100 mt-4 mb-0">Sign Up</button>
</div>
{{ form_end(form) }}
<!--
<form role="form" name="registration_form" method="post">
<div class="input-group input-group-outline mb-3">
<label class="form-label" for="registration_form_name">Name</label>
<input type="text" id="registration_form_name" name="registration_form[name]" required="required" class="form-control">
</div>
<div class='input-group input-group-outline mb-3'>
<label class='form-label' for="registration_form_username">Username</label>
<input type='text' id="registration_form_username" name="registration_form[username]" autocomplete="username" required="required" class='form-control'>
</div>
<div class="input-group input-group-outline mb-3">
<label class="form-label" for="registration_form_email">Email</label>
<input type="email" id="registration_form_email" name="registration_form[email]" required="required" class="form-control">
</div>
<div class="input-group input-group-outline mb-3">
<label class="form-label" for="registration_form_plainPassword">Password</label>
<input type="password" id="registration_form_plainPassword" name="registration_form[plainPassword]" autocomplete="current-password" required="required" class="form-control">
</div>
<div class="text-center">
<input type='hidden' name='registration_form[_token]' id='registration_form__token' value='{{ csrf_token("registration") }}'/>
<button type="submit" class="btn btn-lg bg-gradient-dark btn-lg w-100 mt-4 mb-0">Sign Up</button>
</div>
</form>
-->
</div>
<div class="card-footer text-center pt-0 px-lg-2 px-1">
<p class="mb-2 text-sm mx-auto">
Already have an account?
<a href="/index.php/" class="text-primary text-gradient font-weight-bold">Sign in</a>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</main>
<!-- Core JS Files -->
{% endblock %}

View File

@ -0,0 +1,78 @@
{% extends 'base.html.twig' %}
{% block title %}Register Company
{% endblock %}
{% block body %}
<div class="container position-sticky z-index-sticky top-0">
<div class="row">
<div class="col-12">
{{ block("nav", "libs/nav.html.twig") }}
</div>
</div>
</div>
<main class="main-content mt-0">
<section>
<div class="page-header min-vh-100">
<div class="container">
<div class="row">
<div class="col-6 d-lg-flex d-none h-100 my-auto pe-0 position-absolute top-0 start-0 text-center justify-content-center flex-column">
<div class="position-relative bg-gradient-primary h-100 m-3 px-7 border-radius-lg d-flex flex-column justify-content-center" style="background-image: url('/assets/img/illustrations/illustration-signup.jpg'); background-size: cover;"></div>
</div>
<div class="col-xl-4 col-lg-5 col-md-7 d-flex flex-column ms-auto me-auto ms-lg-auto me-lg-5">
<div class="card card-plain">
<div class="card-header">
<h4 class="font-weight-bolder">Sign Up</h4>
<p class="mb-0">Enter your email and password to register</p>
</div>
<div class="card-body">
{{ form_errors(form) }}
{{ form_start(form) }}
<div class="input-group input-group-outline mb-3">
<label for="registration_form_name" class="form-label">Name</label>
<input type="text" name="{{ field_name(form.name) }}" placeholder="" class="form-control" required="required"/>
</div>
<div class="input-group input-group-outline mb-3">
<label for="registration_form_address" class="form-label">Address</label>
<input type="text" name="{{ field_name(form.address) }}" placeholder="" class="form-control" required="required"/>
</div>
<div class="input-group input-group-outline mb-3">
<label for="registration_form_city" class="form-label">City</label>
<input type="text" name="{{ field_name(form.city) }}" placeholder="" class="form-control" required="required"/>
</div>
<div class="input-group input-group-outline mb-3">
<label for="registration_form_state" class="form-label">State</label>
<input type="text" name="{{ field_name(form.state) }}" placeholder="" class="form-control" required="required"/>
</div>
<div class="input-group input-group-outline mb-3">
<label for="registration_form_zip" class="form-label">Zip</label>
<input type="text" name="{{ field_name(form.zip) }}" class="form-control" required="required"/>
</div>
<div class="input-group input-group-outline mb-3">
<label for="registration_form_phone" class="form-label">Phone</label>
<input type="text" name="{{ field_name(form.phone) }}" class="form-control" required="required"/>
</div>
<div class="input-group input-group-outline mb-3">
<label for="registration_form_email" class="form-label">Email</label>
<input type="email" name="{{ field_name(form.email) }}" class="form-control" required="required"/>
</div>
<div class="input-group input-group-outline mb-3">
<label for="registration_form_url" class="form-label">URL</label>
<input type="text" name="{{ field_name(form.url) }}" class="form-control"/>
</div>
<div class="text-center">
<button type="submit" class="btn btn-lg bg-gradient-dark btn-lg w-100 mt-4 mb-0">Next</button>
</div>
{{ form_end(form) }}
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</main>
<!-- Core JS Files -->
{% endblock %}

View File

@ -0,0 +1,135 @@
{% extends 'base.html.twig' %}
{% block title %}Sign in
{% endblock %}
{% block body %}
{#
<form method="post">
{% if error %}
<div class="alert alert-danger">{{ error.messageKey|trans(error.messageData, 'security') }}</div>
{% endif %}
{% if app.user %}
<div class="mb-3">
You are logged in as
{{ app.user.userIdentifier }},
<a href="{{ path('app_logout') }}">Logout</a>
</div>
{% endif %}
<h1 class="h3 mb-3 font-weight-normal">Please sign in</h1>
<label for="username">Username</label>
<input type="text" value="{{ last_username }}" name="_username" id="username" class="form-control" autocomplete="username" required autofocus>
<label for="password">Password</label>
<input type="password" name="_password" id="password" class="form-control" autocomplete="current-password" required>
<input
type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}">
{#
Uncomment this section and add a remember_me option below your firewall to activate remember me functionality.
See https://symfony.com/doc/current/security/remember_me.html
<div class="checkbox mb-3">
<input type="checkbox" name="_remember_me" id="_remember_me">
<label for="_remember_me">Remember me</label>
</div>
<button class="btn btn-lg btn-primary" type="submit">
Sign in
</button>
</form>
#}
<!--
=========================================================
* Material Dashboard 3 - v3.2.0
=========================================================
* Product Page: https://www.creative-tim.com/product/material-dashboard
* Copyright 2024 Creative Tim (https://www.creative-tim.com)
* Licensed under MIT (https://www.creative-tim.com/license)
* Coded by Creative Tim
=========================================================
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-->
<div class="container position-sticky z-index-sticky top-0"> <div class="row">
<div class="col-12">
{{ block("nav", "libs/nav.html.twig") }}
</div>
</div>
</div>
<main
class="main-content mt-0">
<!-- @todo replace background image -->
<div class="page-header align-items-start min-vh-100" style="background-image: url('https://images.unsplash.com/photo-1497294815431-9365093b7331?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1950&q=80');">
<span class="mask bg-gradient-dark opacity-6"></span>
<div class="container my-auto">
<div class="row">
<div class="col-lg-4 col-md-8 col-12 mx-auto">
<div class="card z-index-0 fadeIn3 fadeInBottom">
<div class="card-header p-0 position-relative mt-n4 mx-3 z-index-2">
<div class="bg-gradient-dark shadow-dark border-radius-lg py-3 pe-1">
<h4 class="text-white font-weight-bolder text-center mt-2 mb-0">Sign in</h4>
<div class="row mt-3">
<div class="col-2 text-center ms-auto">
<a class="btn btn-link px-3" href="javascript:;">
<i class="fa fa-facebook text-white text-lg"></i>
</a>
</div>
<div class="col-2 text-center px-1">
<a class="btn btn-link px-3" href="javascript:;">
<i class="fa fa-github text-white text-lg"></i>
</a>
</div>
<div class="col-2 text-center me-auto">
<a class="btn btn-link px-3" href="javascript:;">
<i class="fa fa-google text-white text-lg"></i>
</a>
</div>
</div>
</div>
</div>
<div class="card-body">
<form role="form" class="text-start" method="post">
{% if error %}
<div class="alert alert-danger">{{ error.messageKey|trans(error.messageData, 'security') }}</div>
{% endif %}
{% if app.user %}
<div class="mb-3">
You are logged in as
{{ app.user.userIdentifier }},
<a href="{{ path('app_logout') }}">Logout</a>
</div>
{% endif %}
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}"/>
<div class="input-group input-group-outline my-3">
<label class="form-label" for="username">Username</label>
<input type="text" value="{{ last_username }}" name="_username" id="username" autocomplete="username" required autofocus class="form-control">
</div>
<div class="input-group input-group-outline mb-3">
<label class="form-label" for='password'>Password</label>
<input type="password" name="_password" id="password" autocomplete="current-password" required class="form-control">
</div>
<div class="form-check form-switch d-flex align-items-center mb-3">
<input class="form-check-input" type="checkbox" name="_remember_me" id="_remember_me">
<label class="form-check-label mb-0 ms-3" for="_remember_me">Remember me</label>
</div>
<div class="text-center">
<button type="submit" class="btn bg-gradient-dark w-100 my-4 mb-2">Sign in</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
{{ block("footer", "libs/footer.html.twig") }}
</div>
</main>
{% endblock %}