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

Default user/password? #156

Closed
nro-bot opened this issue Feb 23, 2021 · 7 comments
Closed

Default user/password? #156

nro-bot opened this issue Feb 23, 2021 · 7 comments

Comments

@nro-bot
Copy link

nro-bot commented Feb 23, 2021

I have just done new docker setup, cannot log in to staff page. I see the default root user is "hunt" but not sure password ?

@nro-bot
Copy link
Author

nro-bot commented Feb 23, 2021

I have circumvented by creating a new user via the browser, then setting is_staffto true in the database, (UPDATE auth_user SET is_superuser = 't' WHERE id=2;) but I am guessing there is some default I'm missing? -- would be great to add to docs ^^

@dlareau
Copy link
Owner

dlareau commented Feb 23, 2021

Good call. Sorry again about that, glad you found a workaround. I'll probably just include the default in the docs, but know for the future that you can also use the "createsuperuser" command (https://docs.djangoproject.com/en/3.1/ref/django-admin/#createsuperuser) in a similar manner to the other two commands you just ran.

Also if you don't mind I'm gonna keep this open for a bit as a reminder to update the docs when I have a moment.

@nro-bot
Copy link
Author

nro-bot commented Feb 24, 2021

Yes of course, thanks for creating this! I can contrib to docs when I have a chance, in the meantime here are some notes for the workaround which I have tried to be fairly detailed:

To create user:
First

$ docker-compose up` # should see one of lines is as follows
[...]
Starting puzzlehunt_server_db_1    ... done
[...]

Second go to http://localhost/accounts/create/ & complete form.

Third give superuser permissions. Begin by logging into database.

docker exec -it puzzlehunt_server_db_1 psql -U user -W puzzlehunt_db

Note that after the after -U and -W is what you have put in .env
eg DB_NAME=puzzlehunt_db, and DB_USER=user are the defaults.
After press enter, will prompt for password - put what you have in DB_PASSWORD Meanwhile, the puzzlehunt_server_db_1 is a container started up by docker-compose (I think).

Next update user.

puzzlehunt_db=# \dt` will list tables. 
puzzlehunt_db=# \ UPDATE auth_user SET is_superuser = 't' WHERE id=2;` 

Note semicolon! If you want to check if you're giving to correct user

SELECT * FROM auth_user;

That is all, now you can login at localhost and should be able to edit hunts etc.

Note: You may verify docker container puzzlehunt_server_db_1 is running with

docker container ls

(or tab-complete may help)

django-admin createsuperuser is definitely a useful command to know! Though, the default clone/setup does not install django-admin and I had some difficulty figuring out how to get it to work with docker-exec. I will investigate a proper python setup in future.

@dlareau
Copy link
Owner

dlareau commented Feb 24, 2021

Thanks for the writeup of what you've done, it is good to have a well documented backup solution.

This is the part where I admit I don't know why the container doesn't have django-admin. I do know though that the manage.py file is the same as django-admin ( https://docs.djangoproject.com/en/3.1/ref/django-admin/ ) . This isn't something of my own doing, a blank django project will have a manage.py with all the features of django-admin. Either way, this is why the commands I gave you previously started with docker-compose exec app python3 /code/manage.py as it stands in for django-admin. Anyway, something along the lines of docker-compose exec app python3 /code/manage.py createsuperuser {{arguments_to_createsuperuser}} should work in the future and is what I will likely document.

@nro-bot
Copy link
Author

nro-bot commented Feb 26, 2021

Oh, nah you're right it does exist! I was using docker exec instead of docker-compose exec. So, my backup solution (and the documentation RIP) is not needed! I'm definitely less familiar with docker than you :)

p.s. two other notes (maybe this issue name should be documentation updates?) which I'll jot in less full than above which turned out to be a waste of time ...

  • note for puzzle creation: both link and display require zip or PDF files, not html. only difference is displaying to end user, one is in iframe, the other opens a new tab with just the html.
  • to make puzzles appear - change "puzzles solved needed" on puzzle page to 0. Then go to staff page, maangement, release initial puzzles
  • pre-puzzles: ? have not gotten to work yet\
  • "Linking an unzipped Dropbox folder for the resource link will also work"---> this appears to be outdated documentation?

@dlareau
Copy link
Owner

dlareau commented Mar 26, 2021

Closing this as the step for creating an admin user has been added to docs on dev branch to be released next version. The helpful items from the last comment will be copied into a new issue.

@dlareau dlareau closed this as completed Mar 26, 2021
@nro-bot
Copy link
Author

nro-bot commented Apr 2, 2021

linking for my ref via #160

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

2 participants