質問編集履歴

3

コードを追記

2020/06/02 05:03

投稿

jetstream
jetstream

スコア65

test CHANGED
File without changes
test CHANGED
@@ -347,3 +347,21 @@
347
347
  ],
348
348
 
349
349
  ```
350
+
351
+
352
+
353
+ ■services.php
354
+
355
+ ```ここに言語を入力
356
+
357
+ 'facebook' => [
358
+
359
+ 'client_id' => env('FB_CLIENT_ID'),
360
+
361
+ 'client_secret' => env('FB_CLIENT_SECRET'),
362
+
363
+ 'redirect' => env('FB_URL'),
364
+
365
+ ],
366
+
367
+ ```

2

コード追記

2020/06/02 05:03

投稿

jetstream
jetstream

スコア65

test CHANGED
File without changes
test CHANGED
@@ -24,7 +24,11 @@
24
24
 
25
25
 
26
26
 
27
- ■LoginController```<?php
27
+ ■LoginController
28
+
29
+ ```ここに言語を入力
30
+
31
+ <?php
28
32
 
29
33
 
30
34
 
@@ -142,198 +146,204 @@
142
146
 
143
147
  ```
144
148
 
149
+
150
+
151
+
152
+
145
153
  ■app.php
146
154
 
155
+
156
+
157
+ ```ここに言語を入力
158
+
159
+ 'providers' => [
160
+
161
+
162
+
163
+ /*
164
+
165
+ * Laravel Framework Service Providers...
166
+
167
+ */
168
+
169
+ Illuminate\Auth\AuthServiceProvider::class,
170
+
171
+ Illuminate\Broadcasting\BroadcastServiceProvider::class,
172
+
173
+ Illuminate\Bus\BusServiceProvider::class,
174
+
175
+ Illuminate\Cache\CacheServiceProvider::class,
176
+
177
+ Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
178
+
179
+ Illuminate\Cookie\CookieServiceProvider::class,
180
+
181
+ Illuminate\Database\DatabaseServiceProvider::class,
182
+
183
+ Illuminate\Encryption\EncryptionServiceProvider::class,
184
+
185
+ Illuminate\Filesystem\FilesystemServiceProvider::class,
186
+
187
+ Illuminate\Foundation\Providers\FoundationServiceProvider::class,
188
+
189
+ Illuminate\Hashing\HashServiceProvider::class,
190
+
191
+ Illuminate\Mail\MailServiceProvider::class,
192
+
193
+ Illuminate\Notifications\NotificationServiceProvider::class,
194
+
195
+ Illuminate\Pagination\PaginationServiceProvider::class,
196
+
197
+ Illuminate\Pipeline\PipelineServiceProvider::class,
198
+
199
+ Illuminate\Queue\QueueServiceProvider::class,
200
+
201
+ Illuminate\Redis\RedisServiceProvider::class,
202
+
203
+ Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
204
+
205
+ Illuminate\Session\SessionServiceProvider::class,
206
+
207
+ Illuminate\Translation\TranslationServiceProvider::class,
208
+
209
+ Illuminate\Validation\ValidationServiceProvider::class,
210
+
211
+ Illuminate\View\ViewServiceProvider::class,
212
+
213
+ // Laravel\Socialite\SocialiteServiceProvider::class,
214
+
215
+
216
+
217
+ /*
218
+
219
+ * Package Service Providers...
220
+
221
+ */
222
+
223
+
224
+
225
+ /*
226
+
227
+ * Application Service Providers...
228
+
229
+ */
230
+
231
+ App\Providers\AppServiceProvider::class,
232
+
233
+ App\Providers\AuthServiceProvider::class,
234
+
235
+ // App\Providers\BroadcastServiceProvider::class,
236
+
237
+ App\Providers\EventServiceProvider::class,
238
+
239
+ App\Providers\RouteServiceProvider::class,
240
+
241
+
242
+
243
+ ],
244
+
245
+
246
+
247
+ /*
248
+
249
+ |--------------------------------------------------------------------------
250
+
251
+ | Class Aliases
252
+
253
+ |--------------------------------------------------------------------------
254
+
255
+ |
256
+
257
+ | This array of class aliases will be registered when this application
258
+
259
+ | is started. However, feel free to register as many as you wish as
260
+
261
+ | the aliases are "lazy" loaded so they don't hinder performance.
262
+
263
+ |
264
+
265
+ */
266
+
267
+
268
+
269
+ 'aliases' => [
270
+
271
+
272
+
273
+ 'App' => Illuminate\Support\Facades\App::class,
274
+
275
+ 'Arr' => Illuminate\Support\Arr::class,
276
+
277
+ 'Artisan' => Illuminate\Support\Facades\Artisan::class,
278
+
279
+ 'Auth' => Illuminate\Support\Facades\Auth::class,
280
+
281
+ 'Blade' => Illuminate\Support\Facades\Blade::class,
282
+
283
+ 'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
284
+
285
+ 'Bus' => Illuminate\Support\Facades\Bus::class,
286
+
287
+ 'Cache' => Illuminate\Support\Facades\Cache::class,
288
+
289
+ 'Config' => Illuminate\Support\Facades\Config::class,
290
+
291
+ 'Cookie' => Illuminate\Support\Facades\Cookie::class,
292
+
293
+ 'Crypt' => Illuminate\Support\Facades\Crypt::class,
294
+
295
+ 'DB' => Illuminate\Support\Facades\DB::class,
296
+
297
+ 'Eloquent' => Illuminate\Database\Eloquent\Model::class,
298
+
299
+ 'Event' => Illuminate\Support\Facades\Event::class,
300
+
301
+ 'File' => Illuminate\Support\Facades\File::class,
302
+
303
+ 'Gate' => Illuminate\Support\Facades\Gate::class,
304
+
305
+ 'Hash' => Illuminate\Support\Facades\Hash::class,
306
+
307
+ 'Http' => Illuminate\Support\Facades\Http::class,
308
+
309
+ 'Lang' => Illuminate\Support\Facades\Lang::class,
310
+
311
+ 'Log' => Illuminate\Support\Facades\Log::class,
312
+
313
+ 'Mail' => Illuminate\Support\Facades\Mail::class,
314
+
315
+ 'Notification' => Illuminate\Support\Facades\Notification::class,
316
+
317
+ 'Password' => Illuminate\Support\Facades\Password::class,
318
+
319
+ 'Queue' => Illuminate\Support\Facades\Queue::class,
320
+
321
+ 'Redirect' => Illuminate\Support\Facades\Redirect::class,
322
+
323
+ 'Redis' => Illuminate\Support\Facades\Redis::class,
324
+
325
+ 'Request' => Illuminate\Support\Facades\Request::class,
326
+
327
+ 'Response' => Illuminate\Support\Facades\Response::class,
328
+
329
+ 'Route' => Illuminate\Support\Facades\Route::class,
330
+
331
+ 'Schema' => Illuminate\Support\Facades\Schema::class,
332
+
333
+ 'Session' => Illuminate\Support\Facades\Session::class,
334
+
335
+ 'Storage' => Illuminate\Support\Facades\Storage::class,
336
+
337
+ 'Str' => Illuminate\Support\Str::class,
338
+
339
+ 'URL' => Illuminate\Support\Facades\URL::class,
340
+
341
+ 'Validator' => Illuminate\Support\Facades\Validator::class,
342
+
343
+ 'View' => Illuminate\Support\Facades\View::class,
344
+
345
+ // 'Socialite' => Laravel\Socialite\Facades\Socialite::class,
346
+
347
+ ],
348
+
147
349
  ```
148
-
149
- 'providers' => [
150
-
151
-
152
-
153
- /*
154
-
155
- * Laravel Framework Service Providers...
156
-
157
- */
158
-
159
- Illuminate\Auth\AuthServiceProvider::class,
160
-
161
- Illuminate\Broadcasting\BroadcastServiceProvider::class,
162
-
163
- Illuminate\Bus\BusServiceProvider::class,
164
-
165
- Illuminate\Cache\CacheServiceProvider::class,
166
-
167
- Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
168
-
169
- Illuminate\Cookie\CookieServiceProvider::class,
170
-
171
- Illuminate\Database\DatabaseServiceProvider::class,
172
-
173
- Illuminate\Encryption\EncryptionServiceProvider::class,
174
-
175
- Illuminate\Filesystem\FilesystemServiceProvider::class,
176
-
177
- Illuminate\Foundation\Providers\FoundationServiceProvider::class,
178
-
179
- Illuminate\Hashing\HashServiceProvider::class,
180
-
181
- Illuminate\Mail\MailServiceProvider::class,
182
-
183
- Illuminate\Notifications\NotificationServiceProvider::class,
184
-
185
- Illuminate\Pagination\PaginationServiceProvider::class,
186
-
187
- Illuminate\Pipeline\PipelineServiceProvider::class,
188
-
189
- Illuminate\Queue\QueueServiceProvider::class,
190
-
191
- Illuminate\Redis\RedisServiceProvider::class,
192
-
193
- Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
194
-
195
- Illuminate\Session\SessionServiceProvider::class,
196
-
197
- Illuminate\Translation\TranslationServiceProvider::class,
198
-
199
- Illuminate\Validation\ValidationServiceProvider::class,
200
-
201
- Illuminate\View\ViewServiceProvider::class,
202
-
203
- // Laravel\Socialite\SocialiteServiceProvider::class,
204
-
205
-
206
-
207
- /*
208
-
209
- * Package Service Providers...
210
-
211
- */
212
-
213
-
214
-
215
- /*
216
-
217
- * Application Service Providers...
218
-
219
- */
220
-
221
- App\Providers\AppServiceProvider::class,
222
-
223
- App\Providers\AuthServiceProvider::class,
224
-
225
- // App\Providers\BroadcastServiceProvider::class,
226
-
227
- App\Providers\EventServiceProvider::class,
228
-
229
- App\Providers\RouteServiceProvider::class,
230
-
231
-
232
-
233
- ],
234
-
235
-
236
-
237
- /*
238
-
239
- |--------------------------------------------------------------------------
240
-
241
- | Class Aliases
242
-
243
- |--------------------------------------------------------------------------
244
-
245
- |
246
-
247
- | This array of class aliases will be registered when this application
248
-
249
- | is started. However, feel free to register as many as you wish as
250
-
251
- | the aliases are "lazy" loaded so they don't hinder performance.
252
-
253
- |
254
-
255
- */
256
-
257
-
258
-
259
- 'aliases' => [
260
-
261
-
262
-
263
- 'App' => Illuminate\Support\Facades\App::class,
264
-
265
- 'Arr' => Illuminate\Support\Arr::class,
266
-
267
- 'Artisan' => Illuminate\Support\Facades\Artisan::class,
268
-
269
- 'Auth' => Illuminate\Support\Facades\Auth::class,
270
-
271
- 'Blade' => Illuminate\Support\Facades\Blade::class,
272
-
273
- 'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
274
-
275
- 'Bus' => Illuminate\Support\Facades\Bus::class,
276
-
277
- 'Cache' => Illuminate\Support\Facades\Cache::class,
278
-
279
- 'Config' => Illuminate\Support\Facades\Config::class,
280
-
281
- 'Cookie' => Illuminate\Support\Facades\Cookie::class,
282
-
283
- 'Crypt' => Illuminate\Support\Facades\Crypt::class,
284
-
285
- 'DB' => Illuminate\Support\Facades\DB::class,
286
-
287
- 'Eloquent' => Illuminate\Database\Eloquent\Model::class,
288
-
289
- 'Event' => Illuminate\Support\Facades\Event::class,
290
-
291
- 'File' => Illuminate\Support\Facades\File::class,
292
-
293
- 'Gate' => Illuminate\Support\Facades\Gate::class,
294
-
295
- 'Hash' => Illuminate\Support\Facades\Hash::class,
296
-
297
- 'Http' => Illuminate\Support\Facades\Http::class,
298
-
299
- 'Lang' => Illuminate\Support\Facades\Lang::class,
300
-
301
- 'Log' => Illuminate\Support\Facades\Log::class,
302
-
303
- 'Mail' => Illuminate\Support\Facades\Mail::class,
304
-
305
- 'Notification' => Illuminate\Support\Facades\Notification::class,
306
-
307
- 'Password' => Illuminate\Support\Facades\Password::class,
308
-
309
- 'Queue' => Illuminate\Support\Facades\Queue::class,
310
-
311
- 'Redirect' => Illuminate\Support\Facades\Redirect::class,
312
-
313
- 'Redis' => Illuminate\Support\Facades\Redis::class,
314
-
315
- 'Request' => Illuminate\Support\Facades\Request::class,
316
-
317
- 'Response' => Illuminate\Support\Facades\Response::class,
318
-
319
- 'Route' => Illuminate\Support\Facades\Route::class,
320
-
321
- 'Schema' => Illuminate\Support\Facades\Schema::class,
322
-
323
- 'Session' => Illuminate\Support\Facades\Session::class,
324
-
325
- 'Storage' => Illuminate\Support\Facades\Storage::class,
326
-
327
- 'Str' => Illuminate\Support\Str::class,
328
-
329
- 'URL' => Illuminate\Support\Facades\URL::class,
330
-
331
- 'Validator' => Illuminate\Support\Facades\Validator::class,
332
-
333
- 'View' => Illuminate\Support\Facades\View::class,
334
-
335
- // 'Socialite' => Laravel\Socialite\Facades\Socialite::class,
336
-
337
- ],
338
-
339
- ```

1

コードの追記

2020/06/02 04:57

投稿

jetstream
jetstream

スコア65

test CHANGED
File without changes
test CHANGED
@@ -24,18 +24,316 @@
24
24
 
25
25
 
26
26
 
27
+ ■LoginController```<?php
28
+
29
+
30
+
31
+ namespace App\Http\Controllers\Auth;
32
+
33
+
34
+
35
+ use App\Http\Controllers\Controller;
36
+
37
+ use Illuminate\Foundation\Auth\AuthenticatesUsers;
38
+
39
+
40
+
41
+ use Socialite;
42
+
27
- ■エラーが出ているコード
43
+ use App\User;
44
+
28
-
45
+ use Auth;
46
+
47
+
48
+
49
+ class LoginController extends Controller
50
+
51
+ {
52
+
53
+ use AuthenticatesUsers;
54
+
55
+
56
+
57
+ protected $redirectTo = '/home';
58
+
59
+
60
+
29
- public function socialLogin($social)
61
+ public function __construct()
30
-
31
-
32
62
 
33
63
  {
34
64
 
35
-
65
+ $this->middleware('guest')->except('logout');
66
+
67
+ }
68
+
69
+
70
+
71
+ //ログインボタンからリンク
72
+
73
+ public function socialLogin($social)
74
+
75
+ {
36
76
 
37
77
  return Socialite::driver($social)->redirect();
38
78
 
39
-
40
-
41
79
  }
80
+
81
+
82
+
83
+ //Callback処理
84
+
85
+ public function handleProviderCallback($social)
86
+
87
+ {
88
+
89
+ //ソーシャルサービス(情報)を取得
90
+
91
+ $userSocial = Socialite::driver($social)->stateless()->user();
92
+
93
+ //emailで登録を調べる
94
+
95
+ $user = User::where(['email' => $userSocial->getEmail()])->first();
96
+
97
+
98
+
99
+ //登録(email)の有無で分岐
100
+
101
+ if($user){
102
+
103
+
104
+
105
+ //登録あればそのままログイン(2回目以降)
106
+
107
+ Auth::login($user);
108
+
109
+ return redirect('/home');
110
+
111
+
112
+
113
+ }else{
114
+
115
+
116
+
117
+ //なければ登録(初回)
118
+
119
+ $newuser = new User;
120
+
121
+ $newuser->name = $userSocial->getName();
122
+
123
+ $newuser->email = $userSocial->getEmail();
124
+
125
+ $newuser->save();
126
+
127
+
128
+
129
+ //そのままログイン
130
+
131
+ Auth::login($newuser);
132
+
133
+ return redirect('/home');
134
+
135
+
136
+
137
+ }
138
+
139
+ }
140
+
141
+ }
142
+
143
+ ```
144
+
145
+ ■app.php
146
+
147
+ ```
148
+
149
+ 'providers' => [
150
+
151
+
152
+
153
+ /*
154
+
155
+ * Laravel Framework Service Providers...
156
+
157
+ */
158
+
159
+ Illuminate\Auth\AuthServiceProvider::class,
160
+
161
+ Illuminate\Broadcasting\BroadcastServiceProvider::class,
162
+
163
+ Illuminate\Bus\BusServiceProvider::class,
164
+
165
+ Illuminate\Cache\CacheServiceProvider::class,
166
+
167
+ Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
168
+
169
+ Illuminate\Cookie\CookieServiceProvider::class,
170
+
171
+ Illuminate\Database\DatabaseServiceProvider::class,
172
+
173
+ Illuminate\Encryption\EncryptionServiceProvider::class,
174
+
175
+ Illuminate\Filesystem\FilesystemServiceProvider::class,
176
+
177
+ Illuminate\Foundation\Providers\FoundationServiceProvider::class,
178
+
179
+ Illuminate\Hashing\HashServiceProvider::class,
180
+
181
+ Illuminate\Mail\MailServiceProvider::class,
182
+
183
+ Illuminate\Notifications\NotificationServiceProvider::class,
184
+
185
+ Illuminate\Pagination\PaginationServiceProvider::class,
186
+
187
+ Illuminate\Pipeline\PipelineServiceProvider::class,
188
+
189
+ Illuminate\Queue\QueueServiceProvider::class,
190
+
191
+ Illuminate\Redis\RedisServiceProvider::class,
192
+
193
+ Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
194
+
195
+ Illuminate\Session\SessionServiceProvider::class,
196
+
197
+ Illuminate\Translation\TranslationServiceProvider::class,
198
+
199
+ Illuminate\Validation\ValidationServiceProvider::class,
200
+
201
+ Illuminate\View\ViewServiceProvider::class,
202
+
203
+ // Laravel\Socialite\SocialiteServiceProvider::class,
204
+
205
+
206
+
207
+ /*
208
+
209
+ * Package Service Providers...
210
+
211
+ */
212
+
213
+
214
+
215
+ /*
216
+
217
+ * Application Service Providers...
218
+
219
+ */
220
+
221
+ App\Providers\AppServiceProvider::class,
222
+
223
+ App\Providers\AuthServiceProvider::class,
224
+
225
+ // App\Providers\BroadcastServiceProvider::class,
226
+
227
+ App\Providers\EventServiceProvider::class,
228
+
229
+ App\Providers\RouteServiceProvider::class,
230
+
231
+
232
+
233
+ ],
234
+
235
+
236
+
237
+ /*
238
+
239
+ |--------------------------------------------------------------------------
240
+
241
+ | Class Aliases
242
+
243
+ |--------------------------------------------------------------------------
244
+
245
+ |
246
+
247
+ | This array of class aliases will be registered when this application
248
+
249
+ | is started. However, feel free to register as many as you wish as
250
+
251
+ | the aliases are "lazy" loaded so they don't hinder performance.
252
+
253
+ |
254
+
255
+ */
256
+
257
+
258
+
259
+ 'aliases' => [
260
+
261
+
262
+
263
+ 'App' => Illuminate\Support\Facades\App::class,
264
+
265
+ 'Arr' => Illuminate\Support\Arr::class,
266
+
267
+ 'Artisan' => Illuminate\Support\Facades\Artisan::class,
268
+
269
+ 'Auth' => Illuminate\Support\Facades\Auth::class,
270
+
271
+ 'Blade' => Illuminate\Support\Facades\Blade::class,
272
+
273
+ 'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
274
+
275
+ 'Bus' => Illuminate\Support\Facades\Bus::class,
276
+
277
+ 'Cache' => Illuminate\Support\Facades\Cache::class,
278
+
279
+ 'Config' => Illuminate\Support\Facades\Config::class,
280
+
281
+ 'Cookie' => Illuminate\Support\Facades\Cookie::class,
282
+
283
+ 'Crypt' => Illuminate\Support\Facades\Crypt::class,
284
+
285
+ 'DB' => Illuminate\Support\Facades\DB::class,
286
+
287
+ 'Eloquent' => Illuminate\Database\Eloquent\Model::class,
288
+
289
+ 'Event' => Illuminate\Support\Facades\Event::class,
290
+
291
+ 'File' => Illuminate\Support\Facades\File::class,
292
+
293
+ 'Gate' => Illuminate\Support\Facades\Gate::class,
294
+
295
+ 'Hash' => Illuminate\Support\Facades\Hash::class,
296
+
297
+ 'Http' => Illuminate\Support\Facades\Http::class,
298
+
299
+ 'Lang' => Illuminate\Support\Facades\Lang::class,
300
+
301
+ 'Log' => Illuminate\Support\Facades\Log::class,
302
+
303
+ 'Mail' => Illuminate\Support\Facades\Mail::class,
304
+
305
+ 'Notification' => Illuminate\Support\Facades\Notification::class,
306
+
307
+ 'Password' => Illuminate\Support\Facades\Password::class,
308
+
309
+ 'Queue' => Illuminate\Support\Facades\Queue::class,
310
+
311
+ 'Redirect' => Illuminate\Support\Facades\Redirect::class,
312
+
313
+ 'Redis' => Illuminate\Support\Facades\Redis::class,
314
+
315
+ 'Request' => Illuminate\Support\Facades\Request::class,
316
+
317
+ 'Response' => Illuminate\Support\Facades\Response::class,
318
+
319
+ 'Route' => Illuminate\Support\Facades\Route::class,
320
+
321
+ 'Schema' => Illuminate\Support\Facades\Schema::class,
322
+
323
+ 'Session' => Illuminate\Support\Facades\Session::class,
324
+
325
+ 'Storage' => Illuminate\Support\Facades\Storage::class,
326
+
327
+ 'Str' => Illuminate\Support\Str::class,
328
+
329
+ 'URL' => Illuminate\Support\Facades\URL::class,
330
+
331
+ 'Validator' => Illuminate\Support\Facades\Validator::class,
332
+
333
+ 'View' => Illuminate\Support\Facades\View::class,
334
+
335
+ // 'Socialite' => Laravel\Socialite\Facades\Socialite::class,
336
+
337
+ ],
338
+
339
+ ```