Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Commit

Permalink
correções nas telas de recuperação de acesso
Browse files Browse the repository at this point in the history
  • Loading branch information
ozenilsoncruz committed Dec 10, 2021
1 parent 72c01e5 commit e3de29c
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 31 deletions.
48 changes: 32 additions & 16 deletions app/Http/Controllers/MailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,45 @@
use Mail;
use App\Models\Cliente;
use App\Models\Funcionario;
use Illuminate\Support\Facades\DB;

class MailController extends Controller
{
public function recuperaAcessoCliente(Request $request){
$novaSenha = rand(100000, 999999);
define('email', $request->email);
Cliente::alterarSenha($request->email, $novaSenha);
Mail::raw("Sua nova senha é: {$novaSenha}", function($message)
{
$message->to(email, 'BusOn')->subject('BusOn - Recuperação de Senha');
});
return view("auth.login");
$usuario = DB::select("select * from cliente where email = ?", [$request->email]);
if(!empty($usuario)){
$novaSenha = rand(100000, 999999);
define('email', $request->email);
Cliente::alterarSenha($request->email, $novaSenha);
Mail::raw("Sua nova senha é: {$novaSenha}", function($message)
{
$message->to(email, 'BusOn')->subject('BusOn - Recuperação de Senha');
});
return redirect()->route('clienteLogin')
->with('success', 'Email foi enviado com a nova senha.');
}else{
return redirect()->back()
->with('error', 'Email não cadastrado no nosso sistema.');
}

}

public function recuperaAcessoFuncionario(Request $request){
$novaSenha = rand(100000, 999999);
define('email', $request->email);
Funcionario::alterarSenha($request->email, $novaSenha);
Mail::raw("Sua nova senha é: {$novaSenha}", function($message)
{
$message->to(email, 'BusOn')->subject('BusOn - Recuperação de Senha');
});
return ('/login/funcionario');
$usuario = DB::select("select * from cliente where email = ?", [$request->email]);
if(!empty($usuario)){
$novaSenha = rand(100000, 999999);
define('email', $request->email);
Funcionario::alterarSenha($request->email, $novaSenha);
Mail::raw("Sua nova senha é: {$novaSenha}", function($message)
{
$message->to(email, 'BusOn')->subject('BusOn - Recuperação de Senha');
});
return redirect()->route('clienteLogin')
->with('success', 'Email foi enviado com a nova senha.');
}else{
return redirect()->back()
->with('error', 'Email não cadastrado no nosso sistema.');
}
}

}
39 changes: 26 additions & 13 deletions resources/views/auth/login.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,32 @@
<div class="container" style="flex-grow: 3;">
<div class="row justify-content-center">
<div class="col-sm-6">
@if(Session::has('message'))
<div class="alert alert-success alert-dismissable">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong>{{session('message')}}</strong>
</div>
@endif

@if(Session::has('error'))
<div class="alert alert-danger alert-dismissable">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong>{{session('error')}}</strong>
</div>
@endif
@if ($errors->any())
<div class="alert alert-danger alert-dismissable">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<ul>
@foreach($errors->all() as $error)
<li><strong>{{ $error }}</strong></li>
@endforeach
</ul>
</div>
@endif
@if (session('success'))
<div class="alert alert-success alert-dismissable">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<ul>
<li><strong>{{session ('success')}}</strong></li>
</ul>
</div>
@endif
@if (session('error'))
<div class="alert alert-danger alert-dismissable">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<ul>
<li><strong>{{session ('error')}}</strong></li>
</ul>
</div>
@endif



Expand Down
28 changes: 27 additions & 1 deletion resources/views/cliente/recuperarAcesso.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,38 @@
<div class="container">
<h5 class="texto">Recuperar Acesso</h5>
<div class="card">
@if ($errors->any())
<div class="alert alert-danger alert-dismissable">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<ul>
@foreach($errors->all() as $error)
<li><strong>{{ $error }}</strong></li>
@endforeach
</ul>
</div>
@endif
@if (session('success'))
<div class="alert alert-success alert-dismissable">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<ul>
<li><strong>{{session ('success')}}</strong></li>
</ul>
</div>
@endif
@if (session('error'))
<div class="alert alert-danger alert-dismissable">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<ul>
<li><strong>{{session ('error')}}</strong></li>
</ul>
</div>
@endif
<div class="card-body">
<form method="POST" action="{{route('recuperarAcessoCliente')}}" id="recuperarAcessoCliente">
@csrf
<div class="form-group">
<label for="entradaEmail">Email Cadastrado</label>
<input type="email" class="form-control" name="email" id="email">
<input type="email" class="form-control" name="email" id="email" required>
</div>
<div class="btnCC">
<button class="botao botaoAmarelo" id="btnCriarConta">Enviar Senha Provisória</button>
Expand Down
28 changes: 27 additions & 1 deletion resources/views/funcionario/recuperarAcesso.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,38 @@
<div class="container">
<h5 class="texto">Recuperar Acesso</h5>
<div class="card">
@if ($errors->any())
<div class="alert alert-danger alert-dismissable">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<ul>
@foreach($errors->all() as $error)
<li><strong>{{ $error }}</strong></li>
@endforeach
</ul>
</div>
@endif
@if (session('success'))
<div class="alert alert-success alert-dismissable">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<ul>
<li><strong>{{session ('success')}}</strong></li>
</ul>
</div>
@endif
@if (session('error'))
<div class="alert alert-danger alert-dismissable">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<ul>
<li><strong>{{session ('error')}}</strong></li>
</ul>
</div>
@endif
<div class="card-body">
<form method="POST" action="{{route('recuperarAcessoFuncionario')}}" id="recuperarAcessoFuncionario">
@csrf
<div class="form-group">
<label for="entradaEmail">Email Cadastrado</label>
<input type="email" class="form-control" name="email" id="email">
<input type="email" class="form-control" name="email" id="email" required>
</div>
<div class="btnCC">
<button class="botao botaoAmarelo" id="btnCriarConta">Enviar Senha Provisória</button>
Expand Down

0 comments on commit e3de29c

Please sign in to comment.