php artisan vendor:publish --provider="Statikbe\\GoogleAuthenticate\\GoogleAuthenticateServiceProvider" --tag="views"
- Templates
- Remove the home.blade.php file
- Copy the dashboard.blade.php, login.blade.php & register.blade.php files to the views/auth folder.
Update your composer.json
file to require "statikbe/laravel-google-authenticate": "^4.0"
.
If you published any of the v3 files you can republish them to get the renamed versions. This can be done with the following commands:
php artisan vendor:publish --provider="Statikbe\\GoogleAuthenticate\\GoogleAuthenticateServiceProvider" --tag="config"
php artisan vendor:publish --provider="Statikbe\\GoogleAuthenticate\\GoogleAuthenticateServiceProvider" --tag="views"
php artisan vendor:publish --provider="Statikbe\\GoogleAuthenticate\\GoogleAuthenticateServiceProvider" --tag="lang"
- Config parameters
- Copy the relevant content (changes you might have made) of
google-auth.php
togoogle-authenticate.php
- Remove
google-auth.php
- Copy the relevant content (changes you might have made) of
- Templates
- Copy the
home.blade.php
,login.blade.php
®ister.blade.php
files from theresources/views/vendor/statikbe
folder to the newly created folderresources/view/vendor/google-authenticate
folder - Remove the view files situated in
resources/views/vendor/statikbe
- Copy the
- Translations
- Copy your translations from the files in the
lang/vendor/statikbe
folder and paste them in the newly created files made in thelang/vendor/google-authenticate
folder - Remove the
lang/vendor/statikbe
folder
- Copy your translations from the files in the
We are not using the roles in version 4 anymore. This is to keep the package less opinionated.
If you were using the roles setting in version 3 you might want to move that logic to the created
event of your user.
For example:
//Add this in your Auth model
protected static function boot()
{
parent::boot();
self::created(function(User $model){
//get user's mail domain
$emailArray = explode('@', $model->email);
$emailDomain = $emailArray[1];
switch ($emailDomain){
case 'statik.be':
$model->assignRole(\Spatie\Permission\Models\Role::firstOrCreate(['name' => 'admin']));
//Add any other domain or role to the switch
}
});
}
WARNING This code is not secure if you are not validating emails. If this is the case you should first check if the registration came from a social login before assigning a role.
- Laravel 5.8 installed
- Statikbe\laravel-google-authenticate 2.x installed
-
Update your
composer.json
file to require"statikbe/laravel-google-authenticate": "^3.1.0"
. Then runcomposer update
. -
In your
config/google-auth.php
update to the correct version; here you can find the 3.1.0 version. You will have to change how you want your roles to be granted using theroles
array. This will include adding domains to the array or leaving the array empty if anyone can receive the role. -
Remove
AUTH_ROLE_ADMIN
,AUTH_ROLE_DOMAIN
andAUTH_REDIRECT_URL
from you.env
file. (You can add these values to the config file you just updated.) -
the vendor views map has been changed from
Statikbe
tostatikbe
. (This is only relevant if you published the package views before.) -
Done!