keith4220
keith4220

Guys, I'm new to OctoberCMS. I installed it on my hosting but I seem to have locked out the admin. There was only one password combination that it could have been so it's strange this happened. Anyone know how I can recover the admin password or reset the user? The mail wasn't configured yet so a 'reset' email wasn't sent.

ScDraft
ScDraft

if you can ssh-login to your server, you can run in october folder

php artisan october:down
php artisan october:up

It will be reduild all database, and users table too. So login and pass will reset to admin

alxy
alxy

Be careful with october:down as it will rebuild ALL database tables (including the ones for plugins). This will result in a data loss which is not really necessary in this case.

You could also do php artisan tinker And then create a superuser manualle like this:

$user = User::create([
            'email'                 => 'your@email.de',
            'login'                 => 'loginname',
            'password'              => 'password',
            'password_confirmation' => 'password',
            'first_name'            => 'firstname',
            'last_name'             => 'lastname',
            'permissions'           => ['superuser' => 1],
            'is_activated'          => true
        ]);

Alternatively you could rerun the user seeder. This will only work if your first user does not have the login name 'admin'. To di this, you need to run the following command:

php artisan db:seed --class=\Backend\Database\Seeds\SeedSetupAdmin

It will create an admin account with the combination admin:admin.

Last updated

keith4220
keith4220

Awesome. Thanks guys. In this case October:down worked well enough so thanks @D503, and I'll keep in mind the alternatives for the future. Thanks @Alxy

Utility
Utility

Hey, @alxy , thanks for the solution. It saved me!

Just to mention: it requires quotes in the command:

php artisan db:seed --class="\Backend\Database\Seeds\SeedSetupAdmin"

Meanwhile, before running, I also uncommentted in modules/backend/database/seeds/SeedSetupAdmin.php:

//        $group = UserGroup::create([
//            'name' => 'Admins'
//        ]);

and

//      $user->addGroup($group);

Last updated

frankemeks777627
frankemeks777627

You can run these queries if you don't have ssh-login. I have same issue on shared hosting and this worked for me.

NB: You can replace the following admin@domain.tld with your real email address , admin with your desired username, Admin with your first name and Person with your lastname. Your password remains 'admin', which you can change when you login


INSERT INTO `backend_users` (`id`, `first_name`, `last_name`, `login`, `email`, `password`, `activation_code`, `persist_code`, `reset_password_code`, `permissions`, `is_activated`, `activated_at`, `last_login`, `created_at`, `updated_at`) VALUES
(1, 'Admin', 'Person', 'admin', 'admin@domain.tld', '$2y$10$VOrmqckzw7JoQXsqUxB0mO65d3m.vwrkXlmzcktEaKAccqwnY/JF6', NULL, NULL, NULL, '{"superuser":1}', 1, NULL, NULL, '2015-05-08 07:55:26', '2015-05-08 07:55:26');

INSERT INTO `backend_users_groups` (`user_id`, `user_group_id`) VALUES
(1, 1);

INSERT INTO `backend_user_groups` (`id`, `name`, `permissions`, `created_at`, `updated_at`, `code`, `description`, `is_new_user_default`) VALUES
(1, 'Admins', NULL, '2015-05-08 07:55:25', '2015-05-08 07:55:25', 'admins', 'Default group for administrators', 1);

Last updated

LukeTowers
LukeTowers

Note that the officially recommended way of accomplishing this now is to use the php artisan october:passwd $username $password command to set $username's password to $password. See https://octobercms.com/docs/console/commands#change-backend-user-password-command for more info.

1-7 of 7