質問編集履歴
3
コードを追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -172,4 +172,13 @@
|
|
172
172
|
'View' => Illuminate\Support\Facades\View::class,
|
173
173
|
// 'Socialite' => Laravel\Socialite\Facades\Socialite::class,
|
174
174
|
],
|
175
|
+
```
|
176
|
+
|
177
|
+
■services.php
|
178
|
+
```ここに言語を入力
|
179
|
+
'facebook' => [
|
180
|
+
'client_id' => env('FB_CLIENT_ID'),
|
181
|
+
'client_secret' => env('FB_CLIENT_SECRET'),
|
182
|
+
'redirect' => env('FB_URL'),
|
183
|
+
],
|
175
184
|
```
|
2
コード追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,7 +11,9 @@
|
|
11
11
|
■エラーが出ている場所
|
12
12
|
C:\xampp\htdocs\laravel\app\Http\Controllers\Auth\LoginController.php:26
|
13
13
|
|
14
|
-
■LoginController
|
14
|
+
■LoginController
|
15
|
+
```ここに言語を入力
|
16
|
+
<?php
|
15
17
|
|
16
18
|
namespace App\Http\Controllers\Auth;
|
17
19
|
|
@@ -70,8 +72,11 @@
|
|
70
72
|
}
|
71
73
|
}
|
72
74
|
```
|
75
|
+
|
76
|
+
|
73
77
|
■app.php
|
78
|
+
|
74
|
-
```
|
79
|
+
```ここに言語を入力
|
75
80
|
'providers' => [
|
76
81
|
|
77
82
|
/*
|
1
コードの追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,11 +11,160 @@
|
|
11
11
|
■エラーが出ている場所
|
12
12
|
C:\xampp\htdocs\laravel\app\Http\Controllers\Auth\LoginController.php:26
|
13
13
|
|
14
|
-
■エラーが出ているコード
|
15
|
-
|
14
|
+
■LoginController```<?php
|
16
15
|
|
16
|
+
namespace App\Http\Controllers\Auth;
|
17
|
+
|
18
|
+
use App\Http\Controllers\Controller;
|
19
|
+
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
20
|
+
|
21
|
+
use Socialite;
|
22
|
+
use App\User;
|
23
|
+
use Auth;
|
24
|
+
|
25
|
+
class LoginController extends Controller
|
26
|
+
{
|
27
|
+
use AuthenticatesUsers;
|
28
|
+
|
29
|
+
protected $redirectTo = '/home';
|
30
|
+
|
31
|
+
public function __construct()
|
17
32
|
{
|
33
|
+
$this->middleware('guest')->except('logout');
|
34
|
+
}
|
18
35
|
|
36
|
+
//ログインボタンからリンク
|
37
|
+
public function socialLogin($social)
|
38
|
+
{
|
19
39
|
return Socialite::driver($social)->redirect();
|
40
|
+
}
|
20
41
|
|
42
|
+
//Callback処理
|
43
|
+
public function handleProviderCallback($social)
|
44
|
+
{
|
45
|
+
//ソーシャルサービス(情報)を取得
|
46
|
+
$userSocial = Socialite::driver($social)->stateless()->user();
|
47
|
+
//emailで登録を調べる
|
48
|
+
$user = User::where(['email' => $userSocial->getEmail()])->first();
|
49
|
+
|
50
|
+
//登録(email)の有無で分岐
|
51
|
+
if($user){
|
52
|
+
|
53
|
+
//登録あればそのままログイン(2回目以降)
|
54
|
+
Auth::login($user);
|
55
|
+
return redirect('/home');
|
56
|
+
|
57
|
+
}else{
|
58
|
+
|
59
|
+
//なければ登録(初回)
|
60
|
+
$newuser = new User;
|
61
|
+
$newuser->name = $userSocial->getName();
|
62
|
+
$newuser->email = $userSocial->getEmail();
|
63
|
+
$newuser->save();
|
64
|
+
|
65
|
+
//そのままログイン
|
66
|
+
Auth::login($newuser);
|
67
|
+
return redirect('/home');
|
68
|
+
|
21
|
-
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}
|
72
|
+
```
|
73
|
+
■app.php
|
74
|
+
```
|
75
|
+
'providers' => [
|
76
|
+
|
77
|
+
/*
|
78
|
+
* Laravel Framework Service Providers...
|
79
|
+
*/
|
80
|
+
Illuminate\Auth\AuthServiceProvider::class,
|
81
|
+
Illuminate\Broadcasting\BroadcastServiceProvider::class,
|
82
|
+
Illuminate\Bus\BusServiceProvider::class,
|
83
|
+
Illuminate\Cache\CacheServiceProvider::class,
|
84
|
+
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
|
85
|
+
Illuminate\Cookie\CookieServiceProvider::class,
|
86
|
+
Illuminate\Database\DatabaseServiceProvider::class,
|
87
|
+
Illuminate\Encryption\EncryptionServiceProvider::class,
|
88
|
+
Illuminate\Filesystem\FilesystemServiceProvider::class,
|
89
|
+
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
|
90
|
+
Illuminate\Hashing\HashServiceProvider::class,
|
91
|
+
Illuminate\Mail\MailServiceProvider::class,
|
92
|
+
Illuminate\Notifications\NotificationServiceProvider::class,
|
93
|
+
Illuminate\Pagination\PaginationServiceProvider::class,
|
94
|
+
Illuminate\Pipeline\PipelineServiceProvider::class,
|
95
|
+
Illuminate\Queue\QueueServiceProvider::class,
|
96
|
+
Illuminate\Redis\RedisServiceProvider::class,
|
97
|
+
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
|
98
|
+
Illuminate\Session\SessionServiceProvider::class,
|
99
|
+
Illuminate\Translation\TranslationServiceProvider::class,
|
100
|
+
Illuminate\Validation\ValidationServiceProvider::class,
|
101
|
+
Illuminate\View\ViewServiceProvider::class,
|
102
|
+
// Laravel\Socialite\SocialiteServiceProvider::class,
|
103
|
+
|
104
|
+
/*
|
105
|
+
* Package Service Providers...
|
106
|
+
*/
|
107
|
+
|
108
|
+
/*
|
109
|
+
* Application Service Providers...
|
110
|
+
*/
|
111
|
+
App\Providers\AppServiceProvider::class,
|
112
|
+
App\Providers\AuthServiceProvider::class,
|
113
|
+
// App\Providers\BroadcastServiceProvider::class,
|
114
|
+
App\Providers\EventServiceProvider::class,
|
115
|
+
App\Providers\RouteServiceProvider::class,
|
116
|
+
|
117
|
+
],
|
118
|
+
|
119
|
+
/*
|
120
|
+
|--------------------------------------------------------------------------
|
121
|
+
| Class Aliases
|
122
|
+
|--------------------------------------------------------------------------
|
123
|
+
|
|
124
|
+
| This array of class aliases will be registered when this application
|
125
|
+
| is started. However, feel free to register as many as you wish as
|
126
|
+
| the aliases are "lazy" loaded so they don't hinder performance.
|
127
|
+
|
|
128
|
+
*/
|
129
|
+
|
130
|
+
'aliases' => [
|
131
|
+
|
132
|
+
'App' => Illuminate\Support\Facades\App::class,
|
133
|
+
'Arr' => Illuminate\Support\Arr::class,
|
134
|
+
'Artisan' => Illuminate\Support\Facades\Artisan::class,
|
135
|
+
'Auth' => Illuminate\Support\Facades\Auth::class,
|
136
|
+
'Blade' => Illuminate\Support\Facades\Blade::class,
|
137
|
+
'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
|
138
|
+
'Bus' => Illuminate\Support\Facades\Bus::class,
|
139
|
+
'Cache' => Illuminate\Support\Facades\Cache::class,
|
140
|
+
'Config' => Illuminate\Support\Facades\Config::class,
|
141
|
+
'Cookie' => Illuminate\Support\Facades\Cookie::class,
|
142
|
+
'Crypt' => Illuminate\Support\Facades\Crypt::class,
|
143
|
+
'DB' => Illuminate\Support\Facades\DB::class,
|
144
|
+
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
|
145
|
+
'Event' => Illuminate\Support\Facades\Event::class,
|
146
|
+
'File' => Illuminate\Support\Facades\File::class,
|
147
|
+
'Gate' => Illuminate\Support\Facades\Gate::class,
|
148
|
+
'Hash' => Illuminate\Support\Facades\Hash::class,
|
149
|
+
'Http' => Illuminate\Support\Facades\Http::class,
|
150
|
+
'Lang' => Illuminate\Support\Facades\Lang::class,
|
151
|
+
'Log' => Illuminate\Support\Facades\Log::class,
|
152
|
+
'Mail' => Illuminate\Support\Facades\Mail::class,
|
153
|
+
'Notification' => Illuminate\Support\Facades\Notification::class,
|
154
|
+
'Password' => Illuminate\Support\Facades\Password::class,
|
155
|
+
'Queue' => Illuminate\Support\Facades\Queue::class,
|
156
|
+
'Redirect' => Illuminate\Support\Facades\Redirect::class,
|
157
|
+
'Redis' => Illuminate\Support\Facades\Redis::class,
|
158
|
+
'Request' => Illuminate\Support\Facades\Request::class,
|
159
|
+
'Response' => Illuminate\Support\Facades\Response::class,
|
160
|
+
'Route' => Illuminate\Support\Facades\Route::class,
|
161
|
+
'Schema' => Illuminate\Support\Facades\Schema::class,
|
162
|
+
'Session' => Illuminate\Support\Facades\Session::class,
|
163
|
+
'Storage' => Illuminate\Support\Facades\Storage::class,
|
164
|
+
'Str' => Illuminate\Support\Str::class,
|
165
|
+
'URL' => Illuminate\Support\Facades\URL::class,
|
166
|
+
'Validator' => Illuminate\Support\Facades\Validator::class,
|
167
|
+
'View' => Illuminate\Support\Facades\View::class,
|
168
|
+
// 'Socialite' => Laravel\Socialite\Facades\Socialite::class,
|
169
|
+
],
|
170
|
+
```
|