Skip to content

Commit

Permalink
fix namespace psr4 + load location of user
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Bohollo Sáez committed May 21, 2020
1 parent 46fd9e3 commit 750b2cc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
],
"autoload": {
"psr-4": {
"Omatech\\Mage\\": "src"
"Omatech\\Mage\\": "src",
"Omatech\\Mage\\App\\": "src/app",
"Omatech\\Mage\\Database\\Seeds\\": "src/database/seeds"
}
},
"extra": {
Expand Down
8 changes: 8 additions & 0 deletions src/app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,13 @@ protected function authenticated(Request $request, $user)
if ($hasPermission == false) {
throw new UnauthorizedException($user);
}

if (auth()->check() == true || auth()->guard('mage')->check() == true) {
$user = auth()->user() ?? auth()->guard('mage')->user();
}

if (isset($user->language)) {
session(['locale' => $user->language]);
}
}
}
2 changes: 2 additions & 0 deletions src/app/Http/Middleware/SetLocale.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class SetLocale
*/
public function handle($request, Closure $next)
{
$locale = null;

foreach (config('mage.translations.available_locales') as $locale) {
if ($locale['locale'] == session('locale')) {
$locale = session('locale');
Expand Down

0 comments on commit 750b2cc

Please sign in to comment.