Skip to content

Commit

Permalink
fixed #369
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Jun 2, 2018
1 parent adc36b0 commit 23dbc97
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 11 additions & 1 deletion app/Listeners/Auth/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@ class Login
*/
public function handle(ILogin $event)
{
// Set company id
// Get first company
$company = $event->user->companies()->first();

// Logout if no company assigned
if (!$company) {
auth()->logout();

flash(trans('auth.error.no_company'))->error();

return redirect('auth/login');
}

// Set company id
session(['company_id' => $company->id]);

// Save user login time
Expand Down
5 changes: 4 additions & 1 deletion resources/lang/en-GB/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@
'current_email' => 'Current Email',
'reset' => 'Reset',
'never' => 'never',

'password' => [
'current' => 'Password',
'current_confirm' => 'Password Confirmation',
'new' => 'New Password',
'new_confirm' => 'New Password Confirmation',
],

'error' => [
'self_delete' => 'Error: Can not delete yourself!'
'self_delete' => 'Error: Can not delete yourself!',
'no_company' => 'Error: No company assigned to your account. Please, contact the system administrator.',
],

'failed' => 'These credentials do not match our records.',
Expand Down

0 comments on commit 23dbc97

Please sign in to comment.