Skip to content

Commit

Permalink
change name middleware auth
Browse files Browse the repository at this point in the history
disabled multiple clics on button save
  • Loading branch information
hectorarnau committed Jul 3, 2019
1 parent 1545395 commit 8b0b289
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/EditoraServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Omatech\Editora;

use Illuminate\Support\ServiceProvider;
use Omatech\Editora\Admin\Middleware\Auth;
use Omatech\Editora\Admin\Middleware\EditoraAuth;
use Omatech\Editora\Admin\Providers\HelperServiceProvider;

class EditoraServiceProvider extends ServiceProvider
Expand Down Expand Up @@ -34,7 +34,7 @@ public function boot()
public function register()
{
$this->app->register(HelperServiceProvider::class);
$this->app['router']->aliasMiddleware('auth', Auth::class);
$this->app['router']->aliasMiddleware('editoraAuth', EditoraAuth::class);

$this->mergeConfigFrom(
__DIR__.'/config/config.php',
Expand Down
4 changes: 2 additions & 2 deletions src/admin/accions/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Omatech\Editora\Admin\Accions;

use Omatech\Editora\Admin\Middleware\Auth;
use Omatech\Editora\Admin\Middleware\EditoraAuth;
use Omatech\Editora\Admin\Models\layout;


Expand All @@ -11,7 +11,7 @@ class AuthController extends BaseController
public function __construct()
{
$this->middleware([
Auth::class
EditoraAuth::class
]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/admin/accions/admin_login.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AdminLogin extends BaseController
public function render()
{
$security = new Security();
if ($security->login($_REQUEST['p_username'], $_REQUEST['p_password'])==1) {
if ($security->login($_REQUEST['p_username'], $_REQUEST['p_password'], $_REQUEST['u_lang'])==1) {
if (isset($_SESSION['last_page']) && $_SESSION['last_page']!='') {
redirect_action($_SESSION['last_page']);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Closure;
use Omatech\Editora\Admin\Models\Security;

class Auth
class EditoraAuth
{
/**
* Handle an incoming request.
Expand Down
4 changes: 2 additions & 2 deletions src/admin/models/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Security extends Model
{
public function login($p_username, $p_password)
public function login($p_username, $p_password, $u_lang=null)
{
$hasher = new BcryptHasher();

Expand All @@ -30,7 +30,7 @@ public function login($p_username, $p_password)
$_SESSION['rol_nom'] = $user['r_nom'];
$_SESSION['user_type'] = $user['tipus'];
$_SESSION['user_language'] = $user['language'];

$this->cacheClasses($user['id']);
$this->cleanUserInstances($user['id']);

Expand Down
13 changes: 8 additions & 5 deletions src/admin/utils/omputils.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,16 @@ function getRolName ($rol_id) {

///////////////////////////////////////////////////////////////////////////////////////////
function getDefaultLanguage() {
if (isset($_REQUEST['u_lang'])) $lg=control_idioma($_REQUEST['u_lang']);
elseif (isset($_COOKIE['u_language'])) $lg=control_idioma($_COOKIE['u_language']);
else $lg=control_idioma('');
if (isset($_REQUEST['u_lang'])) {
$lg=control_idioma($_REQUEST['u_lang']);
}elseif (isset($_COOKIE['u_language'])) {
$lg=control_idioma($_COOKIE['u_language']);
}else{
$lg=control_idioma('');
}
setcookie('u_language', control_idioma($lg), -1 , '/', DOMAIN_SERVER);
$_SESSION['u_lang']=$lg;



return $lg;
}

Expand Down
2 changes: 1 addition & 1 deletion src/admin/views/pages/instance.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
@if($p_mode=='V')
<a href="{{route('editora.action', 'edit_instance/?p_pagina=1&p_class_id='.$instance['class_id'].'&p_inst_id='.$instance['id'])}}" class="btn clr-secondary"><span class="btn-text">Editar</span></a>
@elseif($p_mode=='U' || $p_mode=='I')
<a onclick="document.getElementById('Form1').submit();" class="btn clr-secondary"><span class="btn-text">Guardar</span></a>
<a onclick="document.getElementById('Form1').submit(); $(this).attr('disabled','disabled');" class="btn clr-secondary"><span class="btn-text">Guardar</span></a>
@endif
</div>
</div>
Expand Down

0 comments on commit 8b0b289

Please sign in to comment.