Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Edgar Arroyo 19 posts 161 karma points
    Apr 27, 2019 @ 03:39
    Edgar Arroyo
    0

    Moved site now I can't login, invalid password

    Is there a way to reset the password for user id -1? I have seen admin password reset on v7 but nothing on v8. I am stuck with a non-working password. How can I avoid this when I need to move the website?

  • Marc Goodson 2155 posts 14406 karma points MVP 9x c-trib
    Apr 27, 2019 @ 10:45
    Marc Goodson
    1

    Hi Edgar

    A couple of things... you may not be able to login after the move of your site, if your site can't connect to your database - are you using a separate SQL server or SQL CE?, and if using SQL Server, has your database moved too? and can your new site location connect successfully to the database?

    Secondly, the password is stored as a hash in the database, in theory, the hash algorithm type, used to generate this has 'could' be different between environments, particularly if a different version of the .net framework is used for the site. There is a detailed explanation here:

    https://shazwazza.com/post/umbraco-passwords-and-aspnet-machine-keys

    ...but I think in V8 the 'hash algorithm' used for the password is also stored in the database for each user, so this shouldn't be an issue!

    Finally in V8 the UserLogin and UserPassword details are still stored in the database, so executing the following SQL against the db:

    SELECT TOP (1000) [id]
          ,[userDisabled]
          ,[userNoConsole]
          ,[userName]
          ,[userLogin]
          ,[userPassword]
          ,[passwordConfig]
          ,[userEmail]
          ,[userLanguage]
          ,[securityStampToken]
          ,[failedLoginAttempts]
          ,[lastLockoutDate]
          ,[lastPasswordChangeDate]
          ,[lastLoginDate]
          ,[emailConfirmedDate]
          ,[invitedDate]
          ,[createDate]
          ,[updateDate]
          ,[avatar]
          ,[tourData]
      FROM [dbo].[umbracoUser]
    

    will allow you to find your -1 user, and check if they are locked out...

    enter image description here

    You can then update this row in the db accordingly with an UPDATE statement

    for example:

    UPDATE umbracoUser set userdisabled=0, userLogin='[email protected]', userPassword='k8xXdoQ5Tzv8HwDzq7ivTQ==8FubB0cjfwpEnKQCZcQ7Pk16Dt+WxDlILG2/fZ4G0RI=', passwordConfig='{"hashAlgorithm":"HMACSHA256"}',securityStampToken=NULL, lastLockoutDate=NULL, userNoConsole=0, failedLoginAttempts=NULL where id=-1
    

    should reset the login to be: (perform a site restart/application pool recycle first)

    UserName: [email protected] Password: abc123abc123

    regards

    Marc

  • Edgar Arroyo 19 posts 161 karma points
    Apr 27, 2019 @ 21:20
    Edgar Arroyo
    1

    Ok, thanks. I will try this when I get a chance. I reinstalled it on the new machine and copied all the models, controllers, partial views, templates and document types. I also had to add the Members changes (added fields like First Name, Last Name, Address 1 + 2, City, State (dropdown with all 50+ states), Zip Code and Phone. Wasn't fun but wasn't impossible. Good thing I am setting up a new website and I didn't have any members yet. When I get a chance, I will backup the existing website and database, then I will restore the old backups and try this and report back that way we can have a post with a solution.

    Thank you for your time.

  • Edgar Arroyo 19 posts 161 karma points
    May 18, 2019 @ 19:37
    Edgar Arroyo
    0

    I ended up reinstalling it. Never had a chance to test this, sorry, and thank you for your help.

  • Filip Wallberg 1 post 71 karma points
    Jan 26, 2020 @ 11:42
    Filip Wallberg
    0

    I have the exact same problem. Moved the site from my local machine to Azure , the site is up and running but I cannot log in to the back-end. Tried the steps above but didn't work for me.

    Does anyone have an idea on how to get it to work?

  • Petras Surna 90 posts 144 karma points
    Feb 06, 2020 @ 11:47
    Petras Surna
    0

    Would love to know the answer to this I have the same problem

  • Steve Morgan 1348 posts 4457 karma points c-trib
    Feb 06, 2020 @ 11:50
    Steve Morgan
    0

    Petras this has got me out of jail a few times.

    https://our.umbraco.com/packages/developer-tools/umbraco-admin-reset/

    HTH

    Steve

  • Steve Morgan 1348 posts 4457 karma points c-trib
    Feb 06, 2020 @ 11:52
  • Petras Surna 90 posts 144 karma points
    Feb 06, 2020 @ 12:49
    Petras Surna
    1

    Fixed it locally and on Azure. I tried a number of approaches, sending email, using the admin password reset dll, and a number fo SQL statements. All on Umbraco 8.5.3

    Nothing worked but the email looked like it may have if I kept going.

    I then decided to add a user programmatically using this:

    private void CreateUser()
    {
      // Create a new user
      string email = "[email protected]";
      var newUser =  Services.UserService.CreateUserWithIdentity(email, email);
      // Get user group as IReadOnlyUserGroup
      var userGroup = Services.UserService.GetUserGroupByAlias("admin") as IReadOnlyUserGroup;
      // Add the userGroup to the newUser
      newUser.AddGroup(userGroup);
      // Set the user's password
      string password = "ASd$%fHJ!";
      newUser.RawPasswordValue = (Membership.Providers["UsersMembershipProvider"] as UsersMembershipProvider).HashPasswordForStorage(password); ;
      // Save the new user
      Services.UserService.Save(newUser);
    }
    

    And this did give me another admin user! Very hacky but I got back in. I can't see the original admin user but will clean that up later when I get emails working.

Please Sign in or register to post replies

Write your reply to:

Draft