Skip to content

Commit fe27546

Browse files
authored
Merge pull request #30 from fundhuesped/second-fix-bot
Second fix bot
2 parents 94ce0c7 + adbf060 commit fe27546

File tree

213 files changed

+90119
-30217
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

213 files changed

+90119
-30217
lines changed

.DS_Store

2 KB
Binary file not shown.

.cloud/docker/Dockerfile

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
FROM php:7.4-fpm
2+
3+
# Installing dependencies
4+
RUN apt-get update && apt-get install -y --no-install-recommends \
5+
build-essential \
6+
default-mysql-client \
7+
libpng-dev \
8+
libjpeg62-turbo-dev \
9+
libfreetype6-dev \
10+
libmagickwand-dev \
11+
libzip-dev \
12+
libonig-dev \
13+
locales \
14+
zip \
15+
jpegoptim optipng pngquant gifsicle \
16+
&& pecl install imagick
17+
18+
# Clear cache
19+
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
20+
21+
# Installing extensions
22+
RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl bcmath opcache
23+
RUN docker-php-ext-enable imagick
24+
25+
# Installing composer
26+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
27+
28+
# Changing Workdir
29+
WORKDIR /application
30+
31+
# Add user for laravel application
32+
RUN groupadd -g 1000 www
33+
RUN useradd -u 1000 -ms /bin/bash -g www www
34+
35+
# Copy existing application directory contents
36+
COPY . /application
37+
38+
# Copy existing application directory permissions
39+
COPY --chown=www:www . /application
40+
41+
# Change current user to www
42+
USER www

.cloud/nginx/nginx.conf

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
server {
2+
listen 80;
3+
index index.php index.html index.htm;
4+
root /application/public; # default Laravel's entry point for all requests
5+
6+
access_log /var/log/nginx/access.log;
7+
error_log /var/log/nginx/error.log;
8+
9+
location / {
10+
# try to serve file directly, fallback to index.php
11+
try_files $uri /index.php?$args;
12+
}
13+
14+
location ~ \.php$ {
15+
fastcgi_index index.php;
16+
fastcgi_pass app:9000; # app es el servicio de docker-compose
17+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
18+
fastcgi_param PATH_INFO $fastcgi_path_info;
19+
include fastcgi_params;
20+
}
21+
}

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Donde
2+
Aplicación web que permite buscar lugares cercanos gratuitos de testeo de VIH y de distribución de preservativos.
3+
4+
# Instrucciones para la instalación del sistema
5+
6+
1. Clonar este repositorio al repositorio local de trabajo.
7+
2. Instalar dependencias necesarias para el entorno de desarrollo: php, nginx, mysql. También se puede realizar utilizando una máquina virtual (sobretodo en entornos como Windows) para mayor seguridad y facilidad, ya que no se requiere instalar las dependecias y cualquier problema se descarta el box, su uso recomendado. Ver laravel Homestead para más información https://laravel.com/docs/5.7/homestead.
8+
3. Crear el archivo .env en la carpeta raíz, necesario para asignar las variables de entorno del sistema.
9+
4. Crear la base de datos. Para esto, simplemente importar el último dump de producción disponible con alguna herramienta de administración de mysql. No hay necesidad de crear tablas, configurar la BD, sólo correr el script. Este paso es importante porque los dumps ya contienen algunas optimizaciones en la BD. Verificar si el script crea o no a priori la BD, sino debe crearse el schema primero.
10+
5. Servir (php serve) o levantar la máquina virtual.
11+
6. Probar!

app/Exceptions/Handler.php

+14-24
Original file line numberDiff line numberDiff line change
@@ -50,37 +50,27 @@ public function report(Exception $exception)
5050
* @return \Illuminate\Http\Response
5151
*/
5252
public function render($request, Exception $exception)
53-
{
54-
55-
56-
$list_desings_ids = array('23000', '500','300','310','404');
57-
58-
if ($exception instanceof CsvException) {
59-
return response()->view('errors.310', [], 300);
53+
{
54+
$list_errors = array('22','310','404','500','503','23000');
55+
if($exception instanceof \Illuminate\Auth\AuthenticationException){
56+
return parent::render($request, $exception);
57+
}
58+
else if ($exception instanceof CsvException) {
59+
return response()->view('errors.310', [], 500);
6060
}
6161
else if ($exception instanceof CustomException) {
62-
return response()->view('errors.importador', ['exception' => $exception], 300);
62+
return response()->view('errors.importador', ['exception' => $exception], 500);
6363
}
6464
else if ($exception instanceof ImporterException) {
65-
return response()->view('errors.importador', ['exception' => $exception], 300);
65+
return response()->view('errors.importador', ['exception' => $exception], 500);
6666
}
6767
else if ($exception instanceof QueryException) {
68-
return response()->view('errors.500', ['exception' => $exception], 300);
69-
70-
}
71-
else if ($exception instanceof HttpException) {
72-
return response()->view('errors.500', ['exception' => $exception], 300);
73-
68+
return response()->view('errors.500', ['exception' => $exception], 500);
7469
}
75-
else if(in_array($exception->getCode(), $list_desings_ids))
76-
{
77-
return response()->view('errors.' . $exception->getCode(), ['exception' => $exception]);
78-
79-
}
80-
else {
81-
return parent::render($request, $exception);
70+
else if(is_callable($exception, 'getStatusCode') || method_exists($exception, 'getStatusCode')){
71+
if(in_array($exception->getStatusCode(), $list_errors))
72+
return response()->view('errors.' . $exception->getStatusCode(), ['exception' => $exception],$exception->getStatusCode());
8273
}
83-
84-
74+
return parent::render($request, $exception);
8575
}
8676
}

app/Http/Controllers/AdminRESTController.php

+55
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use App\Http\Controllers\Controller;
1010
use Auth;
1111
use DB;
12+
use Hash;
13+
use Validator;
14+
1215
class AdminRESTController extends Controller
1316
{
1417

@@ -40,6 +43,58 @@ public function saveUserCountries($userId, Request $request)
4043
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
4144
return;
4245
}
46+
47+
public function changePassword(Request $request){
48+
49+
$input = $request->all();
50+
$rules = array(
51+
'userId' => 'required|exists:users,id',
52+
'new_password' => 'required|min:6|required_with:password_confirmation|same:password_confirmation',
53+
'password_confirmation' => 'required|min:6'
54+
);
55+
$messages = array(
56+
'required' => 'Complete los datos requeridos.',
57+
'exists' => 'El usuario ingresado no existe.',
58+
'required_with' => 'Las contraseñas deben coincidir.',
59+
'same' => 'Las contraseñas deben coincidir.',
60+
'min' => 'La contraseña debe poseer un mínimo de :min caracteres.'
61+
);
62+
63+
$validator = Validator::make($input,$rules,$messages);
64+
if ($validator->passes()){
65+
$id = $input['userId'];
66+
$user = User::where('id', $id)->first();
67+
$user->password = Hash::make($input['new_password']);
68+
$user->save();
69+
}
70+
71+
return $validator->messages();
72+
}
73+
74+
public function deleteUser(Request $request){
75+
76+
$input = $request->all();
77+
$rules = array(
78+
'userId' => 'required|exists:users,id'
79+
);
80+
$messages = array(
81+
'required' => 'El campo :attribute es requerido.',
82+
'exists' => 'El usuario ingresado no existe.'
83+
);
84+
85+
$validator = Validator::make($input,$rules,$messages);
86+
if ($validator->passes()){
87+
$id = $request['userId'];
88+
if($id == Auth::id()){//Cannot delete myself
89+
return -1;
90+
}
91+
$user = User::where('id', $id)->first();
92+
$user->delete();
93+
}
94+
95+
return $validator->messages();
96+
}
97+
4398
/**
4499
* Display a listing of the resource.
45100
*

app/Http/Controllers/Auth/AuthController.php

-5
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,10 @@
22

33
namespace App\Http\Controllers\Auth;
44

5-
use App\User;
65
use Validator;
7-
86
use Illuminate\Http\Request;
9-
107
use App\User;
118
use App\Http\Controllers\Controller;
12-
13-
149
use Illuminate\Contracts\Auth\Guard;
1510

1611
class AuthController extends Controller {

app/Http/Controllers/Auth/LoginController.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010

1111
use App\Http\Controllers\Controller;
12-
1312
use Illuminate\Foundation\Auth\AuthenticatesUsers;
1413
use Auth;
1514

@@ -33,7 +32,7 @@ class LoginController extends Controller
3332
*
3433
* @var string
3534
*/
36-
protected $redirectTo = '/home';
35+
protected $redirectTo = '/panel';
3736

3837
/**
3938
* Create a new controller instance.
@@ -46,7 +45,7 @@ public function __construct()
4645
}
4746

4847
public function logout(Request $request) {
49-
Auth::logout();
50-
return redirect('admin/login');
48+
Auth::logout();
49+
return redirect('admin/login');
5150
}
5251
}

0 commit comments

Comments
 (0)