質問編集履歴
1
誤字がありました
test
CHANGED
File without changes
|
test
CHANGED
@@ -274,236 +274,64 @@
|
|
274
274
|
|
275
275
|
|
276
276
|
|
277
|
-
###
|
277
|
+
### 試したソースコード Auth Controller.php
|
278
|
-
|
279
|
-
|
280
278
|
|
281
279
|
```php
|
282
280
|
|
283
281
|
|
284
282
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
<div class="alert alert-danger">
|
336
|
-
|
337
|
-
<ul style="">
|
338
|
-
|
339
|
-
@foreach ($errors->all() as $error)
|
340
|
-
|
341
|
-
<li>{{ $error }}</li>
|
342
|
-
|
343
|
-
@endforeach
|
344
|
-
|
345
|
-
</ul>
|
346
|
-
|
347
|
-
</div>
|
348
|
-
|
349
|
-
@endif
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
<div class="card-body">
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
<div class="form-group row">
|
358
|
-
|
359
|
-
<label class="col-md-4 col-form-label text-md-center" for="">ユーザ名</label>
|
360
|
-
|
361
|
-
<div class="col-md-6">
|
362
|
-
|
363
|
-
<input type="user_name" class="form-control" id="user_name" name="user_name" value="{{ old('user_name') }}" placeholder="" required>
|
364
|
-
|
365
|
-
</div>
|
366
|
-
|
367
|
-
</div>
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
<div class="form-group row">
|
374
|
-
|
375
|
-
<label class="col-md-4 col-form-label text-md-center" for="">メールアドレス</label>
|
376
|
-
|
377
|
-
<div class="col-md-6">
|
378
|
-
|
379
|
-
<input type="email" class="form-control" id="email" name="email" value="{{ old('email') }}" placeholder="" required>
|
380
|
-
|
381
|
-
</div>
|
382
|
-
|
383
|
-
</div>
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
<div class="form-group row">
|
390
|
-
|
391
|
-
<label class="col-md-4 col-form-label text-md-center" for="">パスワード</label>
|
392
|
-
|
393
|
-
<div class="col-md-6">
|
394
|
-
|
395
|
-
<input type="password" class="form-control" id="password" name="password" placeholder="" required>
|
396
|
-
|
397
|
-
<!--<span class="field-icon">
|
398
|
-
|
399
|
-
<i toggle="password-field" class="mdi mdi-eye toggle-password"></i>
|
400
|
-
|
401
|
-
</span>-->
|
402
|
-
|
403
|
-
</div>
|
404
|
-
|
405
|
-
</div>
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
<div class="form-group row">
|
410
|
-
|
411
|
-
<label class="col-md-4 col-form-label text-md-center" for="">確認用パスワード</label>
|
412
|
-
|
413
|
-
<div class="col-md-6">
|
414
|
-
|
415
|
-
<input type="password_confirmation" class="form-control" id="password_confirmation" name="password_confirmation" placeholder="" required>
|
416
|
-
|
417
|
-
</div>
|
418
|
-
|
419
|
-
</div>
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
<div class="text-center">
|
426
|
-
|
427
|
-
<button class="btn btn-primary" type="submit">新規登録</button>
|
428
|
-
|
429
|
-
</div>
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
</div>
|
434
|
-
|
435
|
-
</form>
|
436
|
-
|
437
|
-
</div>
|
438
|
-
|
439
|
-
</div>
|
440
|
-
|
441
|
-
</div>
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
</body>
|
283
|
+
|
284
|
+
|
285
|
+
/**
|
286
|
+
|
287
|
+
* ログイン処理
|
288
|
+
|
289
|
+
* @param App\Http\Requests\UserRequest
|
290
|
+
|
291
|
+
* $request
|
292
|
+
|
293
|
+
*/
|
294
|
+
|
295
|
+
public function login(UserRequest $request) {
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
$email = $request->email;
|
302
|
+
|
303
|
+
$users = DB::table('users')->select('password')->where('email',$email)->get();
|
304
|
+
|
305
|
+
$hash_password = $users;
|
306
|
+
|
307
|
+
$pass = $request->password;
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
if(Hash::check($pass,$hash_password)) {
|
312
|
+
|
313
|
+
//一致
|
314
|
+
|
315
|
+
\Session::flash('msg_success', 'ログイン成功しました');
|
316
|
+
|
317
|
+
return redirect()->route('home');
|
318
|
+
|
319
|
+
} else {
|
320
|
+
|
321
|
+
//一致しなかった時
|
322
|
+
|
323
|
+
\Session::flash('msg_error', 'ログイン失敗しました');
|
324
|
+
|
325
|
+
return back()->withErrors([
|
326
|
+
|
327
|
+
'msg_error' => 'メールアドレスかパスワードが間違っています',
|
328
|
+
|
329
|
+
]);
|
330
|
+
|
331
|
+
}
|
446
332
|
|
447
333
|
```
|
448
334
|
|
449
|
-
### 試したソースコード Auth Controller.php
|
450
|
-
|
451
|
-
```php
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
/**
|
458
|
-
|
459
|
-
* ログイン処理
|
460
|
-
|
461
|
-
* @param App\Http\Requests\UserRequest
|
462
|
-
|
463
|
-
* $request
|
464
|
-
|
465
|
-
*/
|
466
|
-
|
467
|
-
public function login(UserRequest $request) {
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
$email = $request->email;
|
474
|
-
|
475
|
-
$users = DB::table('users')->select('password')->where('email',$email)->get();
|
476
|
-
|
477
|
-
$hash_password = $users;
|
478
|
-
|
479
|
-
$pass = $request->password;
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
if(Hash::check($pass,$hash_password)) {
|
484
|
-
|
485
|
-
//一致
|
486
|
-
|
487
|
-
\Session::flash('msg_success', 'ログイン成功しました');
|
488
|
-
|
489
|
-
return redirect()->route('home');
|
490
|
-
|
491
|
-
} else {
|
492
|
-
|
493
|
-
//一致しなかった時
|
494
|
-
|
495
|
-
\Session::flash('msg_error', 'ログイン失敗しました');
|
496
|
-
|
497
|
-
return back()->withErrors([
|
498
|
-
|
499
|
-
'msg_error' => 'メールアドレスかパスワードが間違っています',
|
500
|
-
|
501
|
-
]);
|
502
|
-
|
503
|
-
}
|
504
|
-
|
505
|
-
```
|
506
|
-
|
507
335
|
|
508
336
|
|
509
337
|
現状として、seederで作成したユーザだとログインができます。
|