Skip to content

Commit

Permalink
Reset Password Implementing
Browse files Browse the repository at this point in the history
  • Loading branch information
douglas-88 committed Feb 20, 2020
1 parent ebddb47 commit fa159a8
Show file tree
Hide file tree
Showing 12 changed files with 201 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/Controller/Admin/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,5 @@ public function destroy()

}


}
49 changes: 49 additions & 0 deletions app/Controller/Admin/PasswordRecoveryController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php


namespace App\Controller\Admin;


use App\Model\User;
use Core\Controller;
use Core\Load;
use Core\Validate;

class PasswordRecoveryController extends Controller
{

CONST SECRET = "";

public function forgot(){

$this->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);
}

}
}
11 changes: 11 additions & 0 deletions app/Model/Pessoa.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php


namespace App\Model;

use App\Model\User;

class Pessoa
{
//# As Pessoas que serão assistidas pelo projeto, herdaram
}
5 changes: 5 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
return $service;
};

$container['PasswordRecoveryController'] = function ($container) {
$service = new \App\Controller\Admin\PasswordRecoveryController();
return $service;
};

$whoops = new Whoops();
$whoops->run($container);

Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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": {
}
Expand Down
64 changes: 63 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion phinx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ environments:
host: localhost
name: twig_slim
user: root
pass: '1475'
pass: 'nokia5233'
port: 3306
charset: utf8

Expand Down
2 changes: 2 additions & 0 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 0 additions & 2 deletions src/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ public static function getUserLoggedIn(Model $model){

public function logout(){



Redirect::redirect("/admin");
exit;
}
Expand Down
2 changes: 1 addition & 1 deletion src/db/migrations/20200219004255_create_users_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
63 changes: 63 additions & 0 deletions views/admin/esqueceu_senha.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>PROJETO RESGATE | Login</title>
<!-- Tell the browser to be responsive to screen width -->
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- Font Awesome -->
<link rel="stylesheet" href="{{ template_admin }}/plugins/fontawesome-free/css/all.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<!-- icheck bootstrap -->
<link rel="stylesheet" href="{{ template_admin }}/plugins/icheck-bootstrap/icheck-bootstrap.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="{{ template_admin }}/dist/css/adminlte.min.css">
<!-- Google Font: Source Sans Pro -->
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
</head>
<body class="hold-transition login-page">
<div class="login-box">
<div class="login-logo">
<a href="../../index2.html"><b>PROJETO RESGATE</b></a>
</div>
<!-- /.login-logo -->
<div class="card">
<div class="card-body login-card-body">
<p class="login-box-msg">Esqueceu sua senha?<br>Aqui você pode facilmente criar uma nova senha.</p>

<form action="/forgot-password" method="post">
<div class="input-group mb-3">
<input type="email" class="form-control" name="email" placeholder="Email">
<div class="input-group-append">
<div class="input-group-text">
<span class="fas fa-envelope"></span>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<button type="submit" class="btn btn-primary btn-block">Enviar link por e-mail</button>
</div>
<!-- /.col -->
</div>
</form>
</div>
<!-- /.login-card-body -->
</div>
{{ message("success") }}
{{ message("warning") }}
</div>
<!-- /.login-box -->

<!-- jQuery -->
<script src="{{ template_admin }}/plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="{{ template_admin }}/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- AdminLTE App -->
<script src="{{ template_admin }}/dist/js/adminlte.min.js"></script>

</body>
</html>
2 changes: 1 addition & 1 deletion views/admin/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</form>
<!-- /.social-auth-links -->
<p class="mb-1 mt-2">
<a href="forgot-password.html">Esqueceu a senha ?</a>
<a href="/forgot-password">Esqueceu a senha ?</a>
</p>
<p class="mb-0">
<a href="register.html" class="text-center">Ainda Não possuo cadastro.</a>
Expand Down

0 comments on commit fa159a8

Please sign in to comment.