{"id":1672,"date":"2024-12-02T18:01:36","date_gmt":"2024-12-02T18:01:36","guid":{"rendered":"https:\/\/editjournal.redakt.eu\/faxmodem\/?p=1672"},"modified":"2024-12-02T18:03:04","modified_gmt":"2024-12-02T18:03:04","slug":"authentication-is-required-to-continue-component","status":"publish","type":"post","link":"https:\/\/editjournal.redakt.eu\/faxmodem\/blog\/development\/cakephp\/quick-bites\/authentication-is-required-to-continue-component\/","title":{"rendered":"&#8220;Authentication is required to continue&#8221; when loading Authentication component"},"content":{"rendered":"<p>If you use cakedc\/users  or cakephp\/authentication and want to programmatically log in a newly created user, you will have to use <code>setIdentity()<\/code> on Authentication component, and for that you will have to load it into your controller. But if you do it wrong, you will get this error:<\/p>\n<blockquote>\n<p>Authentication is required to continue<br \/>\nAuthentication\\Authenticator\\UnauthenticatedException<\/p>\n<\/blockquote>\n<p>To fix, you need to load the component telling it not to require the presence of any identity:<\/p>\n<pre><code>$this->loadComponent('Authentication.Authentication', ['requireIdentity' => false]);<\/code><\/pre>\n<p>More information and references:<\/p>\n<ul>\n<li>source code: <a href=\"https:\/\/github.com\/cakephp\/authentication\/blob\/6b6a2efb7f8b5f6e1c0d53f3fe79c690f29a0aa2\/src\/Controller\/Component\/AuthenticationComponent.php#L177C32-L177C47\">https:\/\/github.com\/cakephp\/authentication\/blob\/6b6a2efb7f8b5f6e1c0d53f3fe79c690f29a0aa2\/src\/Controller\/Component\/AuthenticationComponent.php#L177C32-L177C47<\/a><\/li>\n<li>documentation: <a href=\"https:\/\/book.cakephp.org\/authentication\/3\/en\/migration-from-the-authcomponent.html#checking-identities\">https:\/\/book.cakephp.org\/authentication\/3\/en\/migration-from-the-authcomponent.html#checking-identities<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>If you use cakedc\/users or cakephp\/authentication and want to programmatically log in a newly created user, you will have to use setIdentity() on Authentication component, and for that you will have to load it into your controller. But if you do it wrong, you will get this error: Authentication is required to continue Authentication\\Authenticator\\UnauthenticatedException To&hellip; <a class=\"more-link\" href=\"https:\/\/editjournal.redakt.eu\/faxmodem\/blog\/development\/cakephp\/quick-bites\/authentication-is-required-to-continue-component\/\">Continue reading <span class=\"screen-reader-text\">&#8220;Authentication is required to continue&#8221; when loading Authentication component<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1234],"tags":[],"class_list":["post-1672","post","type-post","status-publish","format-standard","hentry","category-quick-bites","entry"],"_links":{"self":[{"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/posts\/1672","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/comments?post=1672"}],"version-history":[{"count":2,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/posts\/1672\/revisions"}],"predecessor-version":[{"id":1675,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/posts\/1672\/revisions\/1675"}],"wp:attachment":[{"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/media?parent=1672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/categories?post=1672"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/editjournal.redakt.eu\/faxmodem\/wp-json\/wp\/v2\/tags?post=1672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}