user creation update from pending_users
This commit is contained in:
parent
a57af0d118
commit
ef5536a0d3
|
|
@ -23,20 +23,20 @@ public function create(array $input): User
|
||||||
{
|
{
|
||||||
// dd($input);
|
// dd($input);
|
||||||
|
|
||||||
Validator::make($input, [
|
// Validator::make($input, [
|
||||||
'name' => ['required', 'string', 'max:255'],
|
// 'name' => ['required', 'string', 'max:255'],
|
||||||
'email' => [
|
// 'email' => [
|
||||||
'required',
|
// 'required',
|
||||||
'string',
|
// 'string',
|
||||||
'email',
|
// 'email',
|
||||||
'max:255',
|
// 'max:255',
|
||||||
Rule::unique(User::class),
|
// Rule::unique(User::class),
|
||||||
],
|
// ],
|
||||||
'user_type' => ['required', Rule::in(['Cliente', 'Administrador', 'Super_Administrador','Gestor_Obra','Tecnicos','inspetor'])],
|
// 'user_type' => ['required', Rule::in(['Cliente', 'Administrador', 'Super_Administrador','Gestor_Obra','Tecnicos','inspetor'])],
|
||||||
'user_phone' => ['required', 'integer'],
|
// 'user_phone' => ['required', 'integer'],
|
||||||
'user_nif' => ['required', 'string', 'max:15'],
|
// 'user_nif' => ['required', 'string', 'max:15'],
|
||||||
'password' => $this->passwordRules(),
|
// 'password' => $this->passwordRules(),
|
||||||
])->validate();
|
// ])->validate();
|
||||||
|
|
||||||
return User::create([
|
return User::create([
|
||||||
'name' => $input['name'],
|
'name' => $input['name'],
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,15 @@
|
||||||
|
|
||||||
class Pending_UserController extends Controller
|
class Pending_UserController extends Controller
|
||||||
{
|
{
|
||||||
public function mostrar()
|
public function ListPendingUsers()
|
||||||
{
|
{
|
||||||
$pend_users = pending_user::all();
|
$pend_users = pending_user::all();
|
||||||
return view('email/CreateUsers', compact('pend_users'));
|
return view('email/pendingUsers', compact('pend_users'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function ShowFormUser($id){
|
||||||
|
$pend_users = pending_user::findOrFail($id);
|
||||||
|
return view ('Admin.CrudUsers.createUser', compact('pend_users'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ public function handle(Request $request, Closure $next, string ...$guards): Resp
|
||||||
// }
|
// }
|
||||||
|
|
||||||
foreach ($guards as $guard) {
|
foreach ($guards as $guard) {
|
||||||
if (Auth::guard($guard)->check()) {
|
if (Auth::guard($guard)->check() && ! $request->is('register') && ! $request->is('email/verify')) {
|
||||||
$user = Auth::guard($guard)->user();
|
$user = Auth::guard($guard)->user();
|
||||||
|
|
||||||
switch ($user->user_type) {
|
switch ($user->user_type) {
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ public function boot(): void
|
||||||
return view('auth.verify-email');
|
return view('auth.verify-email');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Fortify::createUsersUsing(CreateNewUser::class);
|
Fortify::createUsersUsing(CreateNewUser::class);
|
||||||
|
|
||||||
Fortify::updateUserProfileInformationUsing(UpdateUserProfileInformation::class);
|
Fortify::updateUserProfileInformationUsing(UpdateUserProfileInformation::class);
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@
|
||||||
|
|
||||||
'home' => RouteServiceProvider::HOME,
|
'home' => RouteServiceProvider::HOME,
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Fortify Routes Prefix / Subdomain
|
| Fortify Routes Prefix / Subdomain
|
||||||
|
|
|
||||||
|
|
@ -1 +1,56 @@
|
||||||
<h1>CRUD USERS</h1>
|
@extends('Templates/templateAdmin')
|
||||||
|
|
||||||
|
@section('Main-content')
|
||||||
|
<br><br>
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
|
||||||
|
<form method="POST" action="{{ route('register') }}">
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="name">Nome:</label>
|
||||||
|
<input type="text" class="form-control" id="name" name="name" value="{{$pend_users->pending_name}}" readonly>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="email">E-mail:</label>
|
||||||
|
<input type="email" class="form-control" id="email" name="email" value="{{$pend_users->pending_email}}" readonly>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="user_phone">Telemovel:</label>
|
||||||
|
<input type="number" class="form-control" id="user_phone" name="user_phone" value="{{$pend_users->pending_phone}}" readonly>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="user_nif">NIF:</label>
|
||||||
|
<input type="text" class="form-control" id="user_nif" name="user_nif" value="{{$pend_users->pending_nif}}" readonly>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="user_type">Tipo de usuário:</label>
|
||||||
|
<select class="form-control" name="user_type" id="user_type">
|
||||||
|
<option value="Cliente" selected>Cliente</option>
|
||||||
|
<option value="Administrador">Administrador</option>
|
||||||
|
<option value="Super_Administrador">Super Administrador</option>
|
||||||
|
<option value="Gestor_Obra">Gestor Obra</option>
|
||||||
|
<option value="Tecnicos">Tecnicos</option>
|
||||||
|
<option value="inspetor">inspetor</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="password">Senha:</label>
|
||||||
|
<input type="password" class="form-control" id="password" name="password" value="{{$pend_users->pending_password}}" readonly>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary btn-block">Registrar</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endsection
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ class="fas fa-bars"></i></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="info">
|
<div class="info">
|
||||||
@if (Auth::check())
|
@if (Auth::check())
|
||||||
<a href="{{ 'usersProfiles' }}" class="d-block">{{ Auth::user()->user_type }}
|
<a href="{{ route('usersProfiles')}}" class="d-block">{{ Auth::user()->user_type }}
|
||||||
</a>
|
</a>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,29 @@
|
||||||
<!DOCTYPE html>
|
@extends('Templates/templateAdmin')
|
||||||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
|
||||||
<head>
|
@section('Main-content')
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<title>{{ config('app.name', 'Laravel') }} - Verificar e-mail</title>
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="container mt-5">
|
<div class="container mt-5">
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">Verificar seu endereço de e-mail</div>
|
<div class="card-header">Email de Verificacao enviado</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@if (session('status') == 'verification-link-sent')
|
{{-- @if (session('status') == 'verification-link-sent')
|
||||||
<div class="alert alert-success" role="alert">
|
<div class="alert alert-success" role="alert">
|
||||||
Um novo link de verificação foi enviado para o endereço de e-mail fornecido durante o registro.
|
Um novo link de verificação foi enviado para o endereço de e-mail fornecido durante o registro.
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif --}}
|
||||||
<p>Antes de prosseguir, verifique seu e-mail para obter o link de verificação. Se você não recebeu o e-mail, clique no botão abaixo para solicitar outro.</p>
|
|
||||||
|
<p>Um email de verificacao foi enviado para o utilizador de acordo com o email Cadastado.</p>
|
||||||
<form method="POST" action="{{ route('verification.send') }}">
|
<form method="POST" action="{{ route('verification.send') }}">
|
||||||
@csrf
|
@csrf
|
||||||
<button type="submit" class="btn btn-primary">Reenviar link de verificação</button>
|
<button type="submit" class="btn btn-primary">Reenviar link de verificação</button>
|
||||||
</form>
|
</form>
|
||||||
|
<a href="{{route('CreateUsers')}}" class="btn btn-primary">Voltar</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
|
||||||
</html>
|
@endsection
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@
|
||||||
<table class="table table-bordered table-striped justify-content-center">
|
<table class="table table-bordered table-striped justify-content-center">
|
||||||
<thead class="text-center">
|
<thead class="text-center">
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>Numero</th>
|
||||||
<th>Nome</th>
|
<th>Nome</th>
|
||||||
<th>Email</th>
|
<th>Email</th>
|
||||||
<th>Verificar</th>
|
<th>Verificar</th>
|
||||||
|
|
@ -45,9 +46,11 @@
|
||||||
<tbody class="text-center">
|
<tbody class="text-center">
|
||||||
@foreach ($pend_users as $pend_user)
|
@foreach ($pend_users as $pend_user)
|
||||||
<tr>
|
<tr>
|
||||||
|
<td>{{ $pend_user->id }}</td>
|
||||||
<td>{{ $pend_user->pending_name }}</td>
|
<td>{{ $pend_user->pending_name }}</td>
|
||||||
<td>{{ $pend_user->pending_email }}</td>
|
<td>{{ $pend_user->pending_email }}</td>
|
||||||
<td><a href=""><i class="fa-solid fa-eye text-primary"></i></a></td>
|
<td><a href="{{ route('ShowPendingUser', ['id' => $pend_user->id]) }}"><i
|
||||||
|
class="fa-solid fa-eye text-primary"></i></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
124
routes/web.php
124
routes/web.php
|
|
@ -37,16 +37,25 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Route::middleware(['auth', 'verified'])->group(function () {
|
Route::middleware(['auth', 'verified'])->group(function () {
|
||||||
|
|
||||||
|
|
||||||
// Rotas protegidas que exigem verificação de e-mail
|
// Rotas protegidas que exigem verificação de e-mail
|
||||||
|
|
||||||
Route::get('/', function () {
|
Route::get('/', function () {
|
||||||
return view('Admin/index');
|
return view('Admin/index');
|
||||||
})->name('home');
|
})->name('home');
|
||||||
|
|
||||||
|
// Route::get('/', function () {
|
||||||
|
// return view('Admin/index');
|
||||||
|
// })->name('home');
|
||||||
|
|
||||||
// Route::get('formulario', function () {
|
// Route::get('formulario', function () {
|
||||||
// return view('email/formAdmin');
|
// return view('email/formAdmin');
|
||||||
// })->name('formulario');
|
// })->name('formulario');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Create Users with Super Admin
|
| Create Users with Super Admin
|
||||||
|
|
@ -57,15 +66,15 @@
|
||||||
| be assigned to the "web" middleware group. Make something great!
|
| be assigned to the "web" middleware group. Make something great!
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
Route::get('/CreateUsers', [Pending_UserController::class, 'mostrar'])->name('CreateUsers');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get('formulario', function () {
|
// Route::get('formulario', function () {
|
||||||
return view('email/FormAdmin');
|
// return view('email/FormAdmin');
|
||||||
})->name('formulario');
|
// })->name('formulario');
|
||||||
|
|
||||||
|
|
||||||
Route::post('formulario/receive', [Pending_UserController::class, 'store'])->name('criarUser');
|
// Route::post('formulario/receive', [Pending_UserController::class, 'store'])->name('criarUser');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -79,37 +88,57 @@
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
Route::middleware(['auth', 'verified', 'checksuperadmin'])->group(function () {
|
Route::middleware(['auth', 'verified', 'checksuperadmin'])->group(function () {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Rotas protegidas que exigem verificação de e-mail e user_type Super_Admin
|
// Rotas protegidas que exigem verificação de e-mail e user_type Super_Admin
|
||||||
Route::get('/register', [RegisteredUserController::class, 'create'])
|
// Route::get('/register', [RegisteredUserController::class, 'create'])
|
||||||
->name('register');
|
// ->name('register');
|
||||||
Route::post('/register', [RegisteredUserController::class, 'store']);
|
// Route::post('/register', [RegisteredUserController::class, 'store']);
|
||||||
|
|
||||||
|
|
||||||
|
Route::get('usersProfiles', [userController::class, 'UserProfile'])->name('usersProfiles');
|
||||||
Route::get('usersProfiles', [userController::class, 'UserProfile'] )-> name('usersProfiles');
|
|
||||||
|
|
||||||
// Rota responsavel por enviar o formulario
|
|
||||||
Route::post('enviar-formulario', [FormController::class, 'enviarEmail'])->name('enviar.formulario');
|
Route::post('enviar-formulario', [FormController::class, 'enviarEmail'])->name('enviar.formulario');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| CRUD - users
|
| CRUD - users
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| Definition routes to implement the CRUD model
|
| Definition routes to implement the CRUD model
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Route::get('users/ListUsers', [userController::class, 'ListUsers'])->name('users.list');
|
Route::get('users/ListUsers', [userController::class, 'ListUsers'])->name('users.list');
|
||||||
|
Route::get('users/{id}', [userController::class, 'show'])->name('users.Show');
|
||||||
|
Route::get('users/{id}/edit', [userController::class, 'edit'])->name('users.edit');
|
||||||
|
Route::put('users/{user}', [userController::class, 'update'])->name('users.update');
|
||||||
|
Route::delete('users/{user}', [UserController::class, 'destroy'])->name('users.destroy');
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Create Users with Super Admin
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here is where you can register web routes for your application. These
|
||||||
|
| routes are loaded by the RouteServiceProvider and all of them will
|
||||||
|
| be assigned to the "web" middleware group. Make something great!
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
Route::get('/CreateUsers', [Pending_UserController::class, 'ListPendingUsers'])->name('CreateUsers');
|
||||||
|
|
||||||
|
Route::get('/CreateUsers/{id}',[Pending_UserController::class, 'ShowFormUser'])->name('ShowPendingUser');
|
||||||
|
|
||||||
|
Route::get('formulario', function () {
|
||||||
|
return view('email/FormAdmin');
|
||||||
|
})->name('formulario');
|
||||||
|
|
||||||
|
Route::post('formulario/receive', [Pending_UserController::class, 'store'])->name('criarUser');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get('users/{id}', [userController::class, 'show'])->name('users.Show');
|
|
||||||
|
|
||||||
Route::get('users/{id}/edit',[userController::class, 'edit'])->name('users.edit');
|
|
||||||
|
|
||||||
Route::put('users/{user}', [userController::class, 'update'])->name('users.update');
|
|
||||||
|
|
||||||
Route::delete('users/{user}', [UserController::class, 'destroy'])->name('users.destroy');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -128,41 +157,4 @@
|
||||||
// } else {
|
// } else {
|
||||||
// return 'Failed to send email';
|
// return 'Failed to send email';
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
|
|
||||||
// Route::get('/forgot-password', [ForgotPasswordController::class, 'showLinkRequestForm'])->name('password.request');
|
|
||||||
|
|
||||||
// Route::post('/forgot-password', [ForgotPasswordController::class, 'sendResetLinkEmail'])->name('password.email');
|
|
||||||
|
|
||||||
// Route::get('/reset-password/{token}', [ResetPasswordController::class, 'showResetForm'])->name('password.reset');
|
|
||||||
// Route::post('/reset-password', [ResetPasswordController::class, 'reset'])->name('password.update')
|
|
||||||
|
|
||||||
|
|
||||||
// Route::post('/reset-password', [ResetPasswordController::class, 'reset'])->name('password.update');
|
|
||||||
// Route::get('/forgot-password', [PasswordResetLinkController::class, 'create'])->middleware(['guest'])->name('password.request');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Route::get('/email/verify/{id}/{hash}', function (EmailVerificationRequest $request) {
|
|
||||||
// $request->fulfill();
|
|
||||||
|
|
||||||
// return redirect('/');
|
|
||||||
// })->middleware(['auth', 'signed'])->name('verification.verify');
|
|
||||||
|
|
||||||
|
|
||||||
// Route::get('/email/verify', function () {
|
|
||||||
// return view('auth.verify-email');
|
|
||||||
// })->middleware('auth')->name('verification.notice');
|
|
||||||
|
|
||||||
// Route::get('/email/verify/{id}/{hash}', function (EmailVerificationRequest $request) {
|
|
||||||
// $request->fulfill();
|
|
||||||
|
|
||||||
// return redirect('/');
|
|
||||||
// })->middleware(['auth', 'signed'])->name('verification.verify');
|
|
||||||
|
|
||||||
// Route::post('/email/verification-notification', function (Request $request) {
|
|
||||||
// $request->user()->sendEmailVerificationNotification();
|
|
||||||
|
|
||||||
// return back()->with('status', 'verification-link-sent');
|
|
||||||
// })->middleware(['auth', 'throttle:6,1'])->name('verification.send');
|
|
||||||
Loading…
Reference in New Issue
Block a user