Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Can't login as admin in production #1054

Description

@hankeyyh

Problem

I follow the production deployment,deploy on cloudflare, add admin secret

echo "[email protected]" | wrangler secret put ADMIN_EMAIL --env production
echo "your-secure-password" | wrangler secret put ADMIN_PASSWORD --env production
openssl rand -base64 32 | wrangler secret put JWT_SECRET --env production
openssl rand -base64 32 | wrangler secret put BETTER_AUTH_SECRET --env production

But when i try to login, it reports Invalid email or password.

Goal

Login as admin in production.

Effort

I check remote auth_user, auth_account tables,no entries found. Then i use the sql from seed-admin.ts

INSERT INTO auth_user (id, email, first_name, last_name, role, is_active, created_at, updated_at, name) VALUES(xxx)
INSERT INTO auth_account (id, user_id, account_id, provider_id, password, created_at, updated_at) VALUES(xxx)

Now it reports You do not have permission to access this area. I think it's because the missing of rbac record. But seed-admin.ts use rbac service to add user role. I don't know how to deal with it in sql.

const rbac = new RbacService(env.DB)
await rbac.ensureSystemRbacSeed()
await rbac.addUserRoleByName(odid, 'admin')

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions