Skip to content

Commit

Permalink
ADD - Generate an email for a new account
Browse files Browse the repository at this point in the history
  • Loading branch information
nipunayf committed Dec 14, 2020
1 parent 7f75c71 commit a00132d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Core/database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ CREATE TABLE `vehicle` (
`CurrentLocation` VARCHAR(255),
`NumOfAllocations` INT,
`IsLeased` TINYINT(1),
`VehiclePicturePath` VARCHAR(50),
`VehiclePicturePath` VARCHAR(255),
`IsDeleted` TINYINT(1) DEFAULT 0,
PRIMARY KEY (`RegistrationNo`),
FOREIGN KEY (AssignedOfficer) REFERENCES employee(EmpID) ON UPDATE CASCADE
Expand Down
4 changes: 4 additions & 0 deletions src/EmailClient/EmailGenerator.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,11 @@ public function newAccountNotification(string $email, string $password)
->subject('New User Account')
->paragraph()
->text('A new account has been created for you in Vehicle Fleet Management System.')
->close()
->paragraph()
->text("Email: $email")
->close()
->paragraph()
->text("Password: $password")
->close()
->getEmail();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use DB\Viewer\EmployeeViewer;
use Exception;
use Request\Factory\Base\RealRequest;
use EmailClient\EmailClient;

class PrivilegedEmployeeFactory
{
Expand Down Expand Up @@ -39,7 +40,11 @@ public static function makeNewEmployee(array $values): PrivilegedEmployee
if (!self::checkAccess()) throw new Exception('Illegel Access');

$values['ProfilePicturePath'] = '';
$values['Password']=password_hash(self::generateRandomPassword(), PASSWORD_BCRYPT);

$emailClient = EmailClient::getInstance();
$password = self::generateRandomPassword();
$emailClient->notifyNewAccount($values['Email'],$password);
$values['Password']=password_hash($password, PASSWORD_BCRYPT);
$employee = self::createConcreteEmployee($values);
$employee->saveToDatabase();
return self::castToEmployee($employee);
Expand Down

0 comments on commit a00132d

Please sign in to comment.