Skip to content

Commit efd42d5

Browse files
committed
- Fix grotesque authentication error.
1 parent d4e1f95 commit efd42d5

File tree

2 files changed

+41
-30
lines changed

2 files changed

+41
-30
lines changed

.circleci/config.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@ jobs:
2727
paths:
2828
- ./vendor
2929

30-
- restore_cache:
31-
keys:
32-
- node-v1-{{ checksum "package.json" }}
33-
- node-v1-
34-
- run: yarn install
35-
- save_cache:
36-
key: node-v1-{{ checksum "package.json" }}
37-
paths:
38-
- node_modules
30+
# Disable these steps for the moment
31+
# There are no tests that require javascript
32+
#
33+
#- restore_cache:
34+
# keys:
35+
# - node-v1-{{ checksum "package.json" }}
36+
# - node-v1-
37+
#- run: yarn install
38+
#- save_cache:
39+
# key: node-v1-{{ checksum "package.json" }}
40+
# paths:
41+
# - node_modules
3942

4043
- run: composer test

app/Http/Controllers/Auth/LoginController.php

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44

55
use App\Http\Controllers\Controller;
66
use Illuminate\Foundation\Auth\AuthenticatesUsers;
7+
use Illuminate\Support\Facades\Validator;
78
use Illuminate\Http\Request;
89
use App\Helper;
910

10-
define('LOGIN_REDIRECT_TO', Helper::getDotEnvFileVar('LARAVEL_SURVEY_PREFIX_URL') . '/dashboard');
11-
1211
class LoginController extends Controller
1312
{
1413
/*
@@ -27,39 +26,48 @@ class LoginController extends Controller
2726
}
2827

2928
// https://stackoverflow.com/a/40887817
30-
public function logout(Request $request)
31-
{
29+
public function logout(Request $request) {
30+
$user = \Auth::user();
31+
$farewell = 'See you later!';
32+
if($user):
33+
$farewell = 'See you later ' . $user->name . '!';
34+
endif;
35+
3236
$this->performLogout($request);
37+
38+
$request->session()->flash('success', $farewell);
3339
return redirect()->route('home');
3440
}
3541

36-
/**
37-
* Where to redirect users after login.
38-
*
39-
* @var string
40-
*/
41-
protected $redirectTo = LOGIN_REDIRECT_TO;
42-
4342
/**
4443
* Create a new controller instance.
4544
*
4645
* @return void
4746
*/
48-
public function __construct()
49-
{
47+
public function __construct() {
5048
$this->middleware('guest', ['except' => 'logout']);
5149
}
5250

53-
public function validate(Request $request, array $rules, array $messages = [], array $customAttributes = []) {
54-
if(Helper::isGoogleReCaptchaEnabled()):
55-
$rules['g-recaptcha-response'] = 'required|google_recaptcha';
51+
protected function sendLoginResponse(Request $request) {
52+
if(!Helper::isGoogleReCaptchaEnabled()):
53+
return $this->goToDashboard();
5654
endif;
5755

58-
return parent::validate(
59-
$request,
60-
$rules,
61-
$messages,
62-
$customAttributes
56+
$validator = Validator::make(
57+
$request->all(),
58+
[
59+
'g-recaptcha-response' => 'required|google_recaptcha'
60+
]
6361
);
62+
63+
if($validator->fails()):
64+
return $this->logout($request)->withErrors($validator)->withInput();
65+
endif;
66+
67+
return $this->goToDashboard();
68+
}
69+
70+
protected function goToDashboard() {
71+
return redirect()->route('dashboard');
6472
}
6573
}

0 commit comments

Comments
 (0)