Strapi: Can't login to my dashboard beacuase always show 'Email is already taken'

Created on 23 May 2018  路  43Comments  路  Source: strapi/strapi




Informations

  • Node.js version: v10.1.0
  • npm version: v5.6.0
  • Strapi version: 3.0.0-alpha.12.2
  • Database: MongoDB
  • Operating system: Linux

What is the current behavior?
can't login to my app.
I login and work on my app yesterday but today when I want to login to my app I see setup page again.
I try to fill setup form again. but it's always return Email is already taken.
See below gif for more info:
strapi 4

Can you help me?

Steps to reproduce the problem
I don't know :disappointed:

What is the expected behavior?
I want to login or if any error happens please correct error message.

Suggested solutions

medium bug

All 43 comments

Same issue, the first time register the admin when go to logout an relogin show again the register

I also try to remove database completely and setup again but it's still return Email is already taken :thinking:

@mnlbox this is a duplicate of https://github.com/strapi/strapi/issues/1235.

@lauriejim this issue should be closed and further troubleshooting should be done in the linked issue.

OK, I think it's maybe related but why show Email is already taken error? In related issue you said that it's related to internet speed. :thinking:

@mnlbox what browser are you using? Can you try using Chrome until we release this [patch}(https://github.com/strapi/strapi/pull/1222/files).

A quick solution would be to add the code from the PR then run the following commands in your app (I can't guarantee that it will work if you're using an OS different from mac..., If you struggle DM me on slack).

// Create a new strapi app
$ strapi new my-app2
// We will need only the admin, so in order to prevent any bug from happening when trying to build the admin we're going to remove the plugins folder
$ cd my-app && rm -rf plugins
// Open the admin/admin/src/containers/AdminPage/index.js file and apply the modifications

// At the root of your app
$ npm run setup

Then copy the admin folder from my-app2 into your existing app (my-app) and it should be working fine.

Hello @mnlbox , please follow the issue template so we can get a better understanding about the origin of your bug.
I will reopen your issue as soon as it follows the templating guidelines.
Thank you.

Informations are missing

@lauriejim excuse me man. I copy my node, npm, strapi, ... versions from another issue but I forget to paste it. I update my question, could you reopen this issue?

Suggestion: Please add latest version of Node, NPM, ... as a comment in issue template.

@soupette I'm using Firefox.
I'm using strapi 12.2 and you merge PR #1222 so why this error happens? :thinking:

@mnlbox good it's a good question!

The error is happening because I prevent the plugins from being loaded if the user is not logged in, therefore if the browser is slow the condition hasAdminUser is always false so you're always redirected to the register page.

@soupette it's my Chromium experience:
strapi 5

@soupette I don't think the browser is the main cause in this case, as I generally only use chrome and have noticed the same issue on both windows, linux, and mac.

@mnlbox the email error is normal as the email exists in the database, this is an issue with the redirect settings of the admin panel and not related to the information is being stored.

If you use something like Studio3T (Mongo) or HeidiSQL (MySQL) you'll see that your user is in fact in the database. Hence why that error is popping up.

@derrickmehaffy I check and I haven't any user with that email.
I just randomly create tons of email and always it's return Email is already taken. I'm sure that it's message wrong.

@mnlbox Can you give me a screenshot of your mongoDB with the important bits blacked out (really would rather not see password hashes)

Given my testing has been on MySQL but I can see the users listed in my database. The issue is coming from the adminUI and its redirections

@derrickmehaffy I try to completely drop and recreate my database with db.dropDatabase() but it's still return Email is already taken. I told that I'm sure that I haven't that users.

You dropped your entire database or just that table sorry I don't know what you call it in Mongo (can't stand the database personally :stuck_out_tongue: )

If you dropped the entire database you will need to restart strapi. As there is no database and there is likely a console error saying it can't connect.

Yes I drop and restart Strapi but it's again return Email is already taken.

@lauriejim please reopen this issue until fix. Thanks man :wink:

@soupette Thanks, that fix the issue

@mnlbox can you show me your user model?

@soupette This is my user model:

{
  "connection": "default",
  "info": {
    "name": "user",
    "description": ""
  },
  "attributes": {
    "username": {
      "type": "string",
      "minLength": 3,
      "unique": true,
      "configurable": false,
      "required": true
    },
    "email": {
      "type": "email",
      "minLength": 6,
      "configurable": false,
      "required": true
    },
    "provider": {
      "type": "string",
      "configurable": false
    },
    "password": {
      "type": "password",
      "minLength": 6,
      "configurable": false,
      "private": true
    },
    "resetPasswordToken": {
      "type": "string",
      "configurable": false,
      "private": true
    },
    "role": {
      "model": "role",
      "via": "users",
      "plugin": "users-permissions",
      "configurable": false
    },
    "firstname": {
      "type": "string",
      "required": true
    },
    "lastname": {
      "type": "string",
      "required": true
    }
  },
  "collectionName": "users-permissions_user"
}

@soupette told me, @mnlbox you have to remove additional attributes (firstname and lastname) requirement.

But I want this field as a required :disappointed:

@mnlbox what about registering the first admin user and then set it back to true?

The other options would be to modify the refister form so it displays firstname and lastname

I am also having this issue both on firefox and chrome, it seems when I registered my admin yesterday it did make the change and now I am locked out of the application, what should I do?

You'll need to make the modifications listed previously on the issue

I read them but did not understand, do I have to generate a new project and copy the admin folder? Isn't it possible to fix directly my project instead?

@mig4ng what is your OS?

@soupette Arch Linux

@mig4ng I think it will be easier if you take the admin folder from this project. It's an app that I pushed with the fix from above. So you don't have to rebuild the admin

@soupette thanks! When I try it I'll leave here some feedback

This ticket is referencing several issues tho. The slowness has nothing to do with the required fields or that admin suddenly redirects you to register forever...

@raulriera just as a quick test, use chrome and try and visit your site, if it redirects you to login, hit the back button twice. See if it drops you on the login page.

@raulriera just as a quick test, use chrome and try and visit your site, if it redirects you to login, hit the back button twice. See if it drops you on the login page.

I'll try that the next time it happens, unable to reproduce it without "waiting a few days until admin starts doing that"

This is caused by the analytics plugin, if you're not using it just disable it and voila!

thanks @soupette! It worked for me, if anyone is having this issue too on any unix based OS just go to the directory above your project, clone the @soupette project, remove the admin/admin folder in your project and copy the admin/admin folder from the @soupette project to yours

Step by step:

  1. Go to your project and cd ..
  2. Clone @soupette project with git clone https://github.com/soupette/fix-strapi-login.git
  3. Remove your admin/admin folder with rm -rf {YOUR_PROJECT_PATH}/admin/admin
  4. Copy the @soupette admin/admin folder to your project with cp -r fix-strapi-login/admin/admin {YOUR_PROJECT_PATH}/admin

And you are done

@derrickmehaffy you are right, hitting the back button twice takes me to the login page. But I second the opinion I saw somewhere else that we should simply remove the redirect and link the two pages together... Being able to go from login to register anytime I want by having http links in them

@raulriera yeah thats what I thought, although it seems there might be other issues related to this as others have stated their admin user is not in the database (which I find odd, personally I think this is just related to this redirect issue and the user does exist there.) That being said, I don't use MongoDB and MySQL is far easier to check with. I still get the issue from time to time with @mig4ng and @soupette's fix but it's hard to pin down the cause. It has to be with some change between 12.1.3 and 12.2

why this issue is closed since it is not resolved. I have tried all the ways listed but that didn't solved. Please help

@sanchit-aneja Did you add some required field to the existing user model?

What you can do is set some default value to your user model.

Anyway, I going to make this form more dynamic so it can take in account any added required field.

I'm reopening it.

The other way would be to add a default value to the required fields.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dannydtk picture dannydtk  路  43Comments

lucaperret picture lucaperret  路  36Comments

LeBovin picture LeBovin  路  47Comments

dsheyp picture dsheyp  路  46Comments

niallobrien picture niallobrien  路  47Comments