Answers.Body: <p>Craft 3.6.10 is out now with a fix for <a href="https://github.com/craftcms/cms/issues/7657" rel="nofollow noreferrer">#7657</a>. Note that the fix is not retroactive, so if you already have multiple sites in your project config YAML with <code>primary: true</code>, you should run <code>php craft project-config/rebuild</code> to fix that.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-09T20:17:56.923Z
Answers.LastActivityDate: 2021-03-09T20:24:30.707Z
Answers.LastEditDate: 2021-03-09T20:24:30.707Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>Because of a bug (<a href="https://github.com/craftcms/cms/issues/7657" rel="nofollow noreferrer">https://github.com/craftcms/cms/issues/7657</a>), I got locked out from admin because no site seemed to be marked as primary in the DB, even though one of the site files clearly had a primary:true setting.</p>
  <p>This is using latest craft as of writing, 3.6.9.</p>
  <p>Changing the primary site directly in the sites-table will cause the problem (WEIRD!), logging me out and refusing to log me in again. This doesn't happen in my dev environment when switching the primary site, so I'm not sure what's up here...</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-03-09T11:42:45.583Z
Comments.Text: When you say that you can't log back in, do you have an error message? Can you add a screenshot? Have you tried clearing your cookies or logging in from a private browsing tab?
Comments.UserDisplayName: nstCactus
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-03-09T12:56:49.270Z
Comments.Text: The error message is that the user doesn't exist. Can't reset email either, clearing browser data doesn't make a difference. Switching sites in the admin does far more than just updating the site table it seems, and in some odd occurences this state can happen even when applying project.yaml changes. 
  
  However, I restored a backup and tried it again (via `craft project-config/apply --force`) and it successfully managed to switch primary site so I'm all good now.
Comments.UserDisplayName: jishi
Tags: <project.yaml>
Title: Why can't I log in anymore when I change primary site manually in database?
ThreadText: # Why can't I log in anymore when I change primary site manually in database?
  
  (Asked by: username_0 on 2021-03-08)
  
  Because of a bug (<https://github.com/craftcms/cms/issues/7657>), I got locked out from admin because no site seemed to be marked as primary in the DB, even though one of the site files clearly had a primary:true setting.
  
  This is using latest craft as of writing, 3.6.9.
  
  Changing the primary site directly in the sites-table will cause the problem (WEIRD!), logging me out and refusing to log me in again. This doesn't happen in my dev environment when switching the primary site, so I'm not sure what's up here...
  
  **Tags:** project.yaml
  
  > **Comments:**
  > **username_1**: When you say that you can't log back in, do you have an error message? Can you add a screenshot? Have you tried clearing your cookies or logging in from a private browsing tab?  
  > **username_0**: The error message is that the user doesn't exist. Can't reset email either, clearing browser data doesn't make a difference. Switching sites in the admin does far more than just updating the site table it seems, and in some odd occurences this state can happen even when applying project.yaml changes.   However, I restored a backup and tried it again (via `craft project-config/apply --force`) and it successfully managed to switch primary site so I'm all good now.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2021-03-09. Score: 2
  
  Craft 3.6.10 is out now with a fix for [#7657](https://github.com/craftcms/cms/issues/7657). Note that the fix is not retroactive, so if you already have multiple sites in your project config YAML with `primary: true`, you should run `php craft project-config/rebuild` to fix that.
  
  
  ---
  
  