Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access the Django Admin #63

Open
leo9226 opened this issue Jan 20, 2021 · 3 comments
Open

Access the Django Admin #63

leo9226 opened this issue Jan 20, 2021 · 3 comments

Comments

@leo9226
Copy link

leo9226 commented Jan 20, 2021

Is it possible to access the Django Admin as a superuser (independent of any registered Shopify shop/account) and see all configured tables in the Django Admin section?

I am trying to set up the Django Admin as per documentation, but whenever I attempt to access the Admin section (localhost:8000/admin/), it asks me for a Shopify Shop name and password. Even if I type in the correct shop address and password, I cannot gain access.

Has anyone stumbled across this issue and knows what the issue here is or what I am not seeing?

Thanks a lot and stay healthy!

@stlk
Copy link
Collaborator

stlk commented Jan 29, 2021

I'm pretty sure there's a way but I don't have any recommendations. We've been using store marked as superuser to get to admin and then switched to auth0 using social-auth-app-django.

@stlk
Copy link
Collaborator

stlk commented Mar 3, 2024

So while trying to do this for myself I discovered that you need to use custom user manager.

class UserManager(BaseUserManager):

    def create_user(self, myshopify_domain, password=None):
        """
        Creates and saves a ShopUser with the given domain and password.
        """
        if not myshopify_domain:
            raise ValueError('ShopUsers must have a myshopify domain')

        user = self.model(myshopify_domain=myshopify_domain)

        user.set_password(password)
        user.save(using=self._db)
        return user

    def create_superuser(self, myshopify_domain, password):
        """
        Creates and saves a ShopUser with the given domains and password.
        """
        return self.create_user(myshopify_domain, password)


class AuthAppShopUser(AbstractShopUser, PermissionsMixin):

    objects = UserManager()
    ...

@arslandevpy
Copy link

arslandevpy commented Apr 4, 2024

@leo9226
Yes, possible to access the Django Admin as a superuser.
Add this code of line in AUTH_USER_MODEL.

USERNAME_FIELD = 'email'

def check_password(self, raw_password):
    return True

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants