From 04d95f114db21745cec7e8d046b349cc141607d9 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 20 Dec 2020 19:58:09 +0100 Subject: [PATCH] Create profile temp password --- Controller/ApiController.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 96d6855..3a75a17 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -92,6 +92,32 @@ final class ApiController extends Controller return true; } + /** + * @param Profile $profile Profile to create in the database + * @param RequestAbstract $request Request + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + public function apiProfileTempLoginCreate(Profile $profile, RequestAbstract $request) : void + { + $account = AccountMapper::get($reqeust->header->account); + $account->tempPassword = \password_hash(\random_bytes(64), \PASSWORD_DEFAULT); + + $this->updateModel($request->header->account, $old, $profile, AccountMapper::class, 'profile', $request->getOrigin()); + + $this->fillJsonResponse( + $request, $response, + $status ? NotificationLevel::OK : NotificationLevel::WARNING, + 'Profil', + 'Temp password successfully created.', + $account->tempPassword + ); + } + /** * Method to create profile from request. *