Skip to content

Commit

Permalink
Translations added
Browse files Browse the repository at this point in the history
  • Loading branch information
sander3 committed Jun 17, 2018
1 parent 6fa02bc commit bb004b3
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 11 deletions.
10 changes: 10 additions & 0 deletions resources/lang/en/messages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

return [

'link_sent' => 'We have e-mailed your magic link!',
'authenticated' => 'You have logged in successfully.',
'user' => "We can't find a user with that e-mail address.",
'signature' => 'This magic link is invalid.',

];
10 changes: 10 additions & 0 deletions resources/lang/nl/messages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

return [

'link_sent' => 'We hebben je een magische link gemaild!',
'authenticated' => 'Je bent succesvol ingelogd.',
'user' => 'We kunnen geen gebruiker met dat e-mailadres vinden.',
'signature' => 'Deze magische link is ongeldig.',

];
17 changes: 17 additions & 0 deletions src/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class AuthServiceProvider extends ServiceProvider
public function boot()
{
$this->registerRoutes();
$this->registerTranslations();
}

/**
Expand All @@ -33,6 +34,18 @@ protected function registerRoutes()
});
}

/**
* Register the magic authentication translations.
*
* @return void
*/
protected function registerTranslations()
{
$this->loadTranslationsFrom(
__DIR__ . '/../resources/lang', 'magic-auth'
);
}

/**
* Register the application services.
*
Expand Down Expand Up @@ -67,6 +80,10 @@ protected function offerPublishing()
$this->publishes([
__DIR__ . '/../config/magic-auth.php' => config_path('magic-auth.php'),
], 'magic-auth-config');

$this->publishes([
__DIR__ . '/../resources/lang' => resource_path('lang/vendor/magic-auth'),
], 'magic-auth-lang');
}
}
}
1 change: 0 additions & 1 deletion src/AuthenticatesUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ protected function authenticated(
*/
protected function sendFailedLoginResponse(string $response)
{
// To-do: create translation files:
return redirect($this->redirectPath())
->withErrors(['email' => __($response)]);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Contracts/LinkBroker.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ interface LinkBroker
*
* @var string
*/
const MAGIC_LINK_SENT = 'magic.link_sent';
const MAGIC_LINK_SENT = 'magic-auth::messages.link_sent';

/**
* Constant representing a successful magic login.
*
* @var string
*/
const USER_AUTHENTICATED = 'magic.authenticated';
const USER_AUTHENTICATED = 'magic-auth::messages.authenticated';

/**
* Constant representing the user not found response.
*
* @var string
*/
const INVALID_USER = 'magic.user';
const INVALID_USER = 'magic-auth::messages.user';

/**
* Constant representing an invalid signature.
*
* @var string
*/
const INVALID_SIGNATURE = 'magic.signature';
const INVALID_SIGNATURE = 'magic-auth::messages.signature';

/**
* Send a magic link to a user.
Expand Down
7 changes: 2 additions & 5 deletions src/Http/Controllers/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ class LoginController extends Controller
/**
* Where to redirect users after login.
*
* @return string
* @var string
*/
public function redirectTo()
{
return '/home'; // To-do: create a config option
}
protected $redirectTo = '/login';
}
1 change: 0 additions & 1 deletion src/SendsMagicLinkEmails.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ protected function validateEmail(Request $request)
*/
protected function sendMagicLinkResponse(string $response)
{
// To-do: create translation files:
return back()->with('status', __($response));
}

Expand Down

0 comments on commit bb004b3

Please sign in to comment.