{"id":12163,"date":"2022-05-26T10:00:00","date_gmt":"2022-05-26T01:00:00","guid":{"rendered":"https:\/\/www.gigas-jp.com\/appnews\/?p=12163"},"modified":"2022-05-25T19:45:21","modified_gmt":"2022-05-25T10:45:21","slug":"laravel-auth-%e6%a9%9f%e8%83%bd%e3%81%a8middleware%e3%81%ae%e8%a8%ad%e5%ae%9a1","status":"publish","type":"post","link":"https:\/\/www.gigas-jp.com\/appnews\/archives\/12163","title":{"rendered":"[Laravel] Auth \u6a5f\u80fd\u3068Middleware\u306e\u8a2d\u5b9a(1)"},"content":{"rendered":"\n<p>\u4eca\u56de\u306fLaravel\u6a19\u6e96\u306e\u8a8d\u8a3c\u6a5f\u80fd\u3068Middleware\u306b\u3088\u308b\u8a8d\u8a3c\u30c1\u30a7\u30c3\u30af\u6a5f\u80fd\u306b\u3064\u3044\u3066\u306e\u60c5\u5831\u3092<br>\u30b7\u30a7\u30a2\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<h4>Laravel\u6a19\u6e96\u306e\u8a8d\u8a3c\u6a5f\u80fd\u306e\u78ba\u8a8d<\/h4>\n\n\n\n<p>Laravel\u74b0\u5883\u306b\u3066\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u3067users\u30c6\u30fc\u30d6\u30eb\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p><strong>php artisan migrate<\/strong><\/p>\n\n\n\n<p>Laravel\u306f\u6a19\u6e96\u306e\u72b6\u614b\u3067\u306f\u3053\u306e\u30c6\u30fc\u30d6\u30eb\u306e\u30ab\u30e9\u30e0<br>\u300cemail\u300d\u300cpassword\u300d\u3092\u4f7f\u7528\u3057\u3066\u30ed\u30b0\u30a4\u30f3\u8a8d\u8a3c\u3092\u304a\u3053\u306a\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u8a8d\u8a3c\u51e6\u7406\u78ba\u8a8d\u7528\u306busers\u30c6\u30fc\u30d6\u30eb\u306b\u4ee5\u4e0b\u306e\u30ec\u30b3\u30fc\u30c9\u3092\u767b\u9332\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"714\" height=\"59\" src=\"https:\/\/www.gigas-jp.com\/appnews\/wp-content\/uploads\/sites\/4\/2022\/05\/login_info1.png\" alt=\"\" class=\"wp-image-12165\" \/><\/figure>\n\n\n\n<p>password\u30ab\u30e9\u30e0\u3078\u306e\u767b\u9332\u3067\u3059\u304chush\u5316\u3057\u305fpassword\u3092\u767b\u9332\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br>\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u3066password\u3092hush\u5316\u3057\u3066\u767b\u9332\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p><strong>$hush_pw = password_hash(&#8216;test1&#8217;, PASSWORD_DEFAULT);<\/strong><\/p>\n\n\n\n<p>\u3064\u304e\u306bLaravel\u6a19\u6e96\u306e\u8a8d\u8a3c\u6a5f\u80fd\u306e\u52d5\u4f5c\u78ba\u8a8d\u3092\u304a\u3053\u306a\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p><strong><mark style=\"background-color:#8ed1fc\" class=\"has-inline-color has-black-color\">\u300cemail\u300d\u300cpassword\u300d\u306b\u6b63\u3057\u3044\u5024\u3092\u8a2d\u5b9a\u3057\u305f\u5834\u5408\uff1a<\/mark><\/strong><\/p>\n\n\n\n<p><strong>$credentials = [&#8216;email&#8217;=&gt;&#8217;test1&#8217;, &#8216;password&#8217;=&gt;&#8217;test1&#8217;];<br>dd(\\Auth::guard(&#8216;web&#8217;)-&gt;attempt($credentials));<\/strong><\/p>\n\n\n\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<br><strong>true<\/strong><\/p>\n\n\n\n<p><strong><mark style=\"background-color:#8ed1fc\" class=\"has-inline-color has-black-color\">\u300cemail\u300d\u300cpassword\u300d\u306b\u8aa4\u3063\u305f\u5024\u3092\u8a2d\u5b9a\u3057\u305f\u5834\u5408\uff1a<\/mark><\/strong><\/p>\n\n\n\n<p><strong>$credentials = [&#8216;email&#8217;=&gt;&#8217;test1&#8217;, &#8216;password&#8217;=&gt;&#8217;test2&#8217;];<br>dd(\\Auth::guard(&#8216;web&#8217;)-&gt;attempt($credentials));<\/strong><\/p>\n\n\n\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<br><strong>false<\/strong><\/p>\n\n\n\n<p>\u6b21\u56de\u306f\u30ed\u30b0\u30a4\u30f3ID\u3068\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u6a19\u6e96\u306eusers\u30c6\u30fc\u30d6\u30eb\u3084\u3001\u4e88\u3081\u6c7a\u3081\u3089\u308c\u305f\u30ab\u30e9\u30e0\u3067\u306f\u306a\u304f\u3001<br>\u4efb\u610f\u306e\u30ab\u30e9\u30e0\u3092\u8a8d\u8a3c\u306b\u4f7f\u7528\u3059\u308b\u4f8b\u3092\u7d39\u4ecb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u6728\u66dc\u65e5\u62c5\u5f53\uff1anishida<\/p>\n<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"none\" href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/12163\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/https:\/\/www.gigas-jp.com\/appnews\/archives\/12163\" class=\"hatena-bookmark-button\" data-hatena-bookmark-title=\"[Laravel] Auth \u6a5f\u80fd\u3068Middleware\u306e\u8a2d\u5b9a(1)\" data-hatena-bookmark-layout=\"standard\" title=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\"> <img src=\"\/\/b.hatena.ne.jp\/images\/entry-button\/button-only@2x.png\" alt=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\" width=\"20\" height=\"20\" style=\"border: none;\" \/><\/a><script type=\"text\/javascript\" src=\"\/\/b.hatena.ne.jp\/js\/bookmark_button.js\" charset=\"utf-8\" async=\"async\"><\/script><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/12163\" data-text=\"[Laravel] Auth \u6a5f\u80fd\u3068Middleware\u306e\u8a2d\u5b9a(1)\" data-via=\"GIGASJAPAN_APPS\" data-lang=\"ja\">Tweet<\/a><\/div>\n            <div class=\"wsbl_facebook_like\"><div id=\"fb-root\"><\/div><fb:like href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/12163\" layout=\"button_count\" action=\"like\" width=\"100\" share=\"false\" show_faces=\"false\" ><\/fb:like><\/div>\n            <div class=\"wsbl_facebook_send\"><div id=\"fb-root\"><\/div><fb:send href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/12163\" colorscheme=\"light\" ><\/fb:send><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u56de\u306fLaravel\u6a19\u6e96\u306e\u8a8d\u8a3c\u6a5f\u80fd\u3068Middleware\u306b\u3088\u308b\u8a8d\u8a3c\u30c1\u30a7\u30c3\u30af\u6a5f\u80fd\u306b\u3064\u3044\u3066\u306e\u60c5\u5831\u3092\u30b7\u30a7\u30a2\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[100],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/12163"}],"collection":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/comments?post=12163"}],"version-history":[{"count":9,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/12163\/revisions"}],"predecessor-version":[{"id":12174,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/12163\/revisions\/12174"}],"wp:attachment":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/media?parent=12163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/categories?post=12163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/tags?post=12163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}