質問編集履歴
3
訂正!
test
CHANGED
File without changes
|
test
CHANGED
@@ -68,7 +68,7 @@
|
|
68
68
|
|
69
69
|
|
70
70
|
|
71
|
-
$user = Socilite::driver('twitter')->user();
|
71
|
+
$user = Socialite::driver('twitter')->user();
|
72
72
|
|
73
73
|
|
74
74
|
|
@@ -337,3 +337,15 @@
|
|
337
337
|
}
|
338
338
|
|
339
339
|
```
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
mypage.blade.php内のfacadeがスペルもミスでした。
|
344
|
+
|
345
|
+
誤Socilite 正Socialite
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
しかし訂正後は以下のエラーが発生しました。
|
350
|
+
|
351
|
+
Object of class Laravel\Socialite\One\User could not be converted to string (View: /var/www/html/dev/lara/resources/views/mypage.blade.php)
|
2
composer\.json
test
CHANGED
File without changes
|
test
CHANGED
@@ -317,3 +317,23 @@
|
|
317
317
|
|
318
318
|
|
319
319
|
また、公式のドキュメントでは、Socialiteを利用する際に、composer.jsonに記述を加えるような表現はないと思うのですが、composer.jsonに記述を追加する必要があるのでしょうか・・・・?
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
composer.jsonは以下の通りです。
|
326
|
+
|
327
|
+
composer.json
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
```ここに言語を入力
|
332
|
+
|
333
|
+
"require": {
|
334
|
+
|
335
|
+
"laravel/socialite": "^2.0"
|
336
|
+
|
337
|
+
}
|
338
|
+
|
339
|
+
```
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -82,8 +82,6 @@
|
|
82
82
|
|
83
83
|
?>
|
84
84
|
|
85
|
-
コード
|
86
|
-
|
87
85
|
```
|
88
86
|
|
89
87
|
|
@@ -91,3 +89,231 @@
|
|
91
89
|
|
92
90
|
|
93
91
|
認証済みユーザの情報を取得し、出力したいのですが、どこが間違っているのでしょうか?
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
#####追記######
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
ソーシャル認証のコントローラは以下のようになっています。
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
SocialauthController.php
|
116
|
+
|
117
|
+
```php
|
118
|
+
|
119
|
+
<?php
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
namespace App\Http\Controllers\Auth;
|
124
|
+
|
125
|
+
use Socialite;
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
use App\User;
|
130
|
+
|
131
|
+
use Validator;
|
132
|
+
|
133
|
+
use App\Http\Controllers\Controller;
|
134
|
+
|
135
|
+
use Illuminate\Foundation\Auth\ThrottlesLogins;
|
136
|
+
|
137
|
+
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
class SocialauthController extends Controller
|
146
|
+
|
147
|
+
{
|
148
|
+
|
149
|
+
/*
|
150
|
+
|
151
|
+
|--------------------------------------------------------------------------
|
152
|
+
|
153
|
+
| Registration & Login Controller
|
154
|
+
|
155
|
+
|--------------------------------------------------------------------------
|
156
|
+
|
157
|
+
|
|
158
|
+
|
159
|
+
| This controller handles the registration of new users, as well as the
|
160
|
+
|
161
|
+
| authentication of existing users. By default, this controller uses
|
162
|
+
|
163
|
+
| a simple trait to add these behaviors. Why don't you explore it?
|
164
|
+
|
165
|
+
|
|
166
|
+
|
167
|
+
*/
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
/**
|
178
|
+
|
179
|
+
* Create a new authentication controller instance.
|
180
|
+
|
181
|
+
*
|
182
|
+
|
183
|
+
* @return void
|
184
|
+
|
185
|
+
*/
|
186
|
+
|
187
|
+
public function __construct()
|
188
|
+
|
189
|
+
{
|
190
|
+
|
191
|
+
$this->middleware('guest', ['except' => 'getLogout']);
|
192
|
+
|
193
|
+
}
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
/**
|
198
|
+
|
199
|
+
* Get a validator for an incoming registration request.
|
200
|
+
|
201
|
+
*
|
202
|
+
|
203
|
+
* @param array $data
|
204
|
+
|
205
|
+
* @return \Illuminate\Contracts\Validation\Validator
|
206
|
+
|
207
|
+
*/
|
208
|
+
|
209
|
+
protected function validator(array $data)
|
210
|
+
|
211
|
+
{
|
212
|
+
|
213
|
+
return Validator::make($data, [
|
214
|
+
|
215
|
+
'name' => 'required|max:255',
|
216
|
+
|
217
|
+
'email' => 'required|email|max:255|unique:users',
|
218
|
+
|
219
|
+
'password' => 'required|confirmed|min:6',
|
220
|
+
|
221
|
+
]);
|
222
|
+
|
223
|
+
}
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
/**
|
228
|
+
|
229
|
+
* Create a new user instance after a valid registration.
|
230
|
+
|
231
|
+
*
|
232
|
+
|
233
|
+
* @param array $data
|
234
|
+
|
235
|
+
* @return User
|
236
|
+
|
237
|
+
*/
|
238
|
+
|
239
|
+
protected function create(array $data)
|
240
|
+
|
241
|
+
{
|
242
|
+
|
243
|
+
return User::create([
|
244
|
+
|
245
|
+
'name' => $data['name'],
|
246
|
+
|
247
|
+
'email' => $data['email'],
|
248
|
+
|
249
|
+
'password' => bcrypt($data['password']),
|
250
|
+
|
251
|
+
]);
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
/**
|
258
|
+
|
259
|
+
* ユーザーをGitHubの認証ページヘリダイレクト
|
260
|
+
|
261
|
+
*
|
262
|
+
|
263
|
+
* @return Response
|
264
|
+
|
265
|
+
*/
|
266
|
+
|
267
|
+
public function redirectToProvider()
|
268
|
+
|
269
|
+
{
|
270
|
+
|
271
|
+
return Socialite::driver('twitter')->redirect();
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
/**
|
278
|
+
|
279
|
+
* ユーザーの情報をtwitterから取得
|
280
|
+
|
281
|
+
*
|
282
|
+
|
283
|
+
* @return Response
|
284
|
+
|
285
|
+
*/
|
286
|
+
|
287
|
+
public function handleProviderCallback()
|
288
|
+
|
289
|
+
{
|
290
|
+
|
291
|
+
$user = Socialite::driver('twitter')->user();
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
// $user->token;
|
296
|
+
|
297
|
+
}
|
298
|
+
|
299
|
+
}
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
```
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
ログインページにて認証が行われ、リダイレクトはされるのでSocialiteは機能しているような気がするのですが・・
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
また、公式のドキュメントでは、Socialiteを利用する際に、composer.jsonに記述を加えるような表現はないと思うのですが、composer.jsonに記述を追加する必要があるのでしょうか・・・・?
|