dev-master
9999999-devdang nhap bang tai khoan google
MIT
The Requires
by hoang hiep
Wallogit.com
2017 © Pedro Peláez
dang nhap bang tai khoan google
thêm routes.php vào laravel qua method boot :, (*1)
if (! $this->app->routesAreCached()) { require DIR.'/routes.php'; }, (*2)
<?php, (*3)
return [, (*4)
'h3'=>
[
'driver' => 'local',
'root' => app_path('/'),
'visibility' => 'public',
]
];
public function register() { $this->mergeConfigFrom( DIR.'/config/filesystems.php', 'filesystems.disks' ); }, (*5)
Route::get('hoanghiep/add-routes',function(){, (*6)
if(Storage::disk('h3')->exists("Http/routes.php")){
Storage::disk("h3")->append('Http/routes.php',
'Route::get(\'auth/google\',["middleware"=>"web", "uses"=> \'Auth\GoogleController@redirectToProvider\']); '); Storage::disk("h3")->append('Http/routes.php', 'Route::get(\'auth/google/callback\', ["middleware"=>"web","uses"=> \'Auth\GoogleController@handleProviderCallback\']); ');, (*7)
}
});, (*8)
// sau khi chạy url hoanghiep/add-routes này đoạn lệnh sẽ kiểm tra file routes.php đã tồn tại trong app/Http/routes.php, (*9)
vào thực hiện thêm mới 2 route 'auth/google - auth/google/callback\ vào file đó., (*10)
Trong provider class tại method boot() thêm đoạn sau :, (*11)
$this->publishes([ DIR.("/Auth/GoogleController.php")=> app_path("/Http/Controllers/Auth/GoogleController.php"),, (*12)
])
Chạy lệnh để xuất bản file controller : php artisan vendor:publish, (*13)
Như vậy khi chạy lệnh controller sẽ được tạo ra., (*14)
thêm file cấu hình của google bằng cách tạo ra một file trong gói vừa tải tên là service.php trong đó chứa :, (*15)
<?php, (*16)
return [, (*17)
'google'=>[ 'client_id' => '15561597118-vv58u5dtkm10uni08kv471ltjb1od40m.apps.googleusercontent.com', 'client_secret' => '_1Ojx13UdmPMkTadUrClA9Cw', 'redirect' => 'http://localhost/laravel/auth/google/callback', ]
];, (*18)
sau đó thêm đoạn code này vào provider :, (*19)
$this->mergeConfigFrom( DIR.'/config/services.php', 'services' );, (*20)
Như vậy là đã gộp file cấu hình vào file config thành công kiểm tra kết quả bằng cách, (*21)
vào method boot hoặc route chạy đoạn, (*22)
dd(config('services'));
hoặc, (*23)
dd(config('services.google'));
Để tùy chỉnh thông tin của serve google bạn vào file 'services' trong package/config/services.php, (*24)
Để chạy thử tính năng : bạn chạy 2 url auth/google và auth/google/callback nếu url ko tồn tại thì chạy url để khởi tạo url đó : hoanghiep/add-routes, (*25)
dang nhap bang tai khoan google
MIT