diff --git a/app/Controller/Admin/LoginController.php b/app/Controller/Admin/LoginController.php index 43b36c5..76dca0c 100644 --- a/app/Controller/Admin/LoginController.php +++ b/app/Controller/Admin/LoginController.php @@ -101,4 +101,5 @@ public function destroy() } + } \ No newline at end of file diff --git a/app/Controller/Admin/PasswordRecoveryController.php b/app/Controller/Admin/PasswordRecoveryController.php new file mode 100644 index 0000000..cdc8576 --- /dev/null +++ b/app/Controller/Admin/PasswordRecoveryController.php @@ -0,0 +1,49 @@ +view("admin/esqueceu_senha",["template_admin" => $this->templateAdmin]); + + } + + public function enviarLinkRecuperarSenha(){ + + $validate = new Validate(); + $data = $validate->validate([ + "email" => "required:email" + ]); + + if($validate->hasErros()){ + foreach($data as $field => $value){ + flash("post_".$field,$data[$field]); + } + back(); + } + + $config = (object) Load::file("/config.php"); + $user = (new User())->select()->where("email",$data["email"])->first(); + + if(!$user){ + echo("Não achou o e-mail: {$data["email"]}"); + return false; + }else{ + $code = base64_encode(openssl_encrypt($dataRecovery["idrecovery"],"AES-128-ECB",User::SECRET)); + dd($user); + } + + } +} \ No newline at end of file diff --git a/app/Model/Pessoa.php b/app/Model/Pessoa.php new file mode 100644 index 0000000..0d344bc --- /dev/null +++ b/app/Model/Pessoa.php @@ -0,0 +1,11 @@ +run($container); diff --git a/composer.json b/composer.json index 9797ab9..56e314b 100755 --- a/composer.json +++ b/composer.json @@ -13,7 +13,8 @@ "vlucas/phpdotenv": "^4.1", "dopesong/slim-whoops": "^2.3", "robmorgan/phinx": "^0.11.4", - "intervention/image": "^2.5" + "intervention/image": "^2.5", + "phpmailer/phpmailer": "^6.1" }, "autoload": { "psr-4": { @@ -25,7 +26,8 @@ ] }, "scripts":{ - "server":"php -S localhost:8080 -t public" + "server":"php -S localhost:8080 -t public", + "phinx" :"php vendor/bin/phinx" }, "require-dev": { } diff --git a/composer.lock b/composer.lock index 5dff31d..c94e03c 100755 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "e70ba3b02554bcd1e15900eaa855e746", + "content-hash": "e694316cbc96be32b76ed0fca97b63e9", "packages": [ { "name": "cakephp/cache", @@ -671,6 +671,68 @@ ], "time": "2018-02-13T20:26:39+00:00" }, + { + "name": "phpmailer/phpmailer", + "version": "v6.1.4", + "source": { + "type": "git", + "url": "https://github.com/PHPMailer/PHPMailer.git", + "reference": "c5e61d0729507049cec9673aa1a679f9adefd683" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/c5e61d0729507049cec9673aa1a679f9adefd683", + "reference": "c5e61d0729507049cec9673aa1a679f9adefd683", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-filter": "*", + "php": ">=5.5.0" + }, + "require-dev": { + "doctrine/annotations": "^1.2", + "friendsofphp/php-cs-fixer": "^2.2", + "phpunit/phpunit": "^4.8 || ^5.7" + }, + "suggest": { + "ext-mbstring": "Needed to send email in multibyte encoding charset", + "hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication", + "league/oauth2-google": "Needed for Google XOAUTH2 authentication", + "psr/log": "For optional PSR-3 debug logging", + "stevenmaguire/oauth2-microsoft": "Needed for Microsoft XOAUTH2 authentication", + "symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)" + }, + "type": "library", + "autoload": { + "psr-4": { + "PHPMailer\\PHPMailer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1-only" + ], + "authors": [ + { + "name": "Marcus Bointon", + "email": "phpmailer@synchromedia.co.uk" + }, + { + "name": "Jim Jagielski", + "email": "jimjag@gmail.com" + }, + { + "name": "Andy Prevost", + "email": "codeworxtech@users.sourceforge.net" + }, + { + "name": "Brent R. Matzelle" + } + ], + "description": "PHPMailer is a full-featured email creation and transfer class for PHP", + "time": "2019-12-10T11:17:38+00:00" + }, { "name": "phpoption/phpoption", "version": "1.7.2", diff --git a/phinx.yml b/phinx.yml index e11a407..152fc11 100755 --- a/phinx.yml +++ b/phinx.yml @@ -19,7 +19,7 @@ environments: host: localhost name: twig_slim user: root - pass: '1475' + pass: 'nokia5233' port: 3306 charset: utf8 diff --git a/public/index.php b/public/index.php index 7b58016..f51adda 100755 --- a/public/index.php +++ b/public/index.php @@ -6,6 +6,8 @@ $app->get("/login","LoginController:index")->add($middleware->checkLoggedIn()); $app->post("/login","LoginController:store"); $app->get("/logout","LoginController:destroy"); +$app->get("/forgot-password","PasswordRecoveryController:forgot")->add($middleware->checkLoggedIn()); +$app->post("/forgot-password","PasswordRecoveryController:enviarLinkRecuperarSenha"); $app->group("/painel/admin",function() use ($app){ $app->get("[/]","AdminController:index"); diff --git a/src/Login.php b/src/Login.php index aea2488..4baae5c 100755 --- a/src/Login.php +++ b/src/Login.php @@ -42,8 +42,6 @@ public static function getUserLoggedIn(Model $model){ public function logout(){ - - Redirect::redirect("/admin"); exit; } diff --git a/src/db/migrations/20200219004255_create_users_table.php b/src/db/migrations/20200219004255_create_users_table.php index 8499c28..5bd3fae 100644 --- a/src/db/migrations/20200219004255_create_users_table.php +++ b/src/db/migrations/20200219004255_create_users_table.php @@ -37,7 +37,7 @@ public function change() $table->addColumn("email","string",["limit" => 70]); $table->addColumn("phone","string",["limit" => 11]); $table->addColumn("avatar","string",["limit" => 300]); - $table->addColumn('role_id', 'integer', ['null' => false]); + $table->addColumn('role_id', 'integer', ['null' => true]); $table->addForeignKey('role_id', 'roles', 'id',['delete'=> 'SET_NULL']); $table->addColumn("created",'timestamp', ['default' => 'CURRENT_TIMESTAMP']); $table->create(); diff --git a/views/admin/esqueceu_senha.html b/views/admin/esqueceu_senha.html new file mode 100644 index 0000000..4093d41 --- /dev/null +++ b/views/admin/esqueceu_senha.html @@ -0,0 +1,63 @@ + + +
+ + +Esqueceu sua senha?
Aqui você pode facilmente criar uma nova senha.