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

can i reset the password or salvage my links? #102

Open
jtabox opened this issue Jan 31, 2024 · 6 comments
Open

can i reset the password or salvage my links? #102

jtabox opened this issue Jan 31, 2024 · 6 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@jtabox
Copy link

jtabox commented Jan 31, 2024

Hey,

I'm running Benotes via Docker compose and today after rebooting the host computer it suddenly stopped working. Or rather, it works fine, but won't accept my credentials (that were working an hour ago, before the reboot).

There's nothing out of the ordinary in the docker logs from what I can see:

2024-01-31T21:14:24.266826401Z  Migrate database...
2024-01-31T21:14:25.471456709Z  Database migration completed.
2024-01-31T21:14:25.630778936Z  2024-01-31 21:14:25,630 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If you intend to run as root, you can set user=root in the config file to avoid this message.
2024-01-31T21:14:25.632624811Z  2024-01-31 21:14:25,632 INFO supervisord started with pid 16
2024-01-31T21:14:26.639066822Z  2024-01-31 21:14:26,638 INFO spawned: 'cron' with pid 17
2024-01-31T21:14:26.640972697Z  2024-01-31 21:14:26,640 INFO spawned: 'nginx' with pid 18
2024-01-31T21:14:26.642408050Z  2024-01-31 21:14:26,642 INFO spawned: 'php-fpm' with pid 19
2024-01-31T21:14:26.685616735Z  [31-Jan-2024 21:14:26] NOTICE: fpm is running, pid 19
2024-01-31T21:14:26.686362523Z  [31-Jan-2024 21:14:26] NOTICE: ready to handle connections
2024-01-31T21:14:27.687576920Z  2024-01-31 21:14:27,687 INFO success: cron entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2024-01-31T21:14:27.687594115Z  2024-01-31 21:14:27,687 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2024-01-31T21:14:27.687653620Z  2024-01-31 21:14:27,687 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2024-01-31T21:14:46.876243432Z  172.20.0.2 - - [31/Jan/2024:21:14:46 +0000] "GET /login HTTP/1.1" 200 812 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0" "10.0.10.10"

Is there some way to reset the password or at least salvage my links? Or is everything lost? I'm using sqlite as the database.

Edit: I can't use the "Forgot password" link, because the email I used is non-existent, I'm the only user of the program and it runs on my 2nd PC at home.

@fr0tt fr0tt added enhancement New feature or request question Further information is requested labels Feb 3, 2024
@fr0tt
Copy link
Owner

fr0tt commented Feb 3, 2024

Hey,

could potentially be caused by setting a (new) value for APP_KEY after account creation.
You made me think about creating a second option to reset passwords as a command, which I'm going to implement in the future.

Regardless in your case access you should fix it with the following commands:

docker compose exec --user application app sh
php artisan tinker
User::first()->update(['password' => Hash::make('myNewSuperPassword')]);

(The second and third command have to be executed inside your container. The third one sets a new password for the first user in your database.)

@jtabox
Copy link
Author

jtabox commented Feb 6, 2024

This seems to have worked indeed. Though now I have another issue, all the thumbnails have disappeared (or some are there, but definitely not as many as it was before). I tried doing php artisan thumbnail:generate and it asked me how many posts to "improve" (I guess it means to download thumbnail?), I replied all but its reply was:

24 potential posts found. This could take several minutes.
Process post 180...

Shouldn't it start from 1 ? Not to mention I don't have only 24 posts.

Edit: this is the thumbnails folder, it contains only the ones it created now.

/var/www/public/storage/thumbnails $ ls -la
total 1424
drwxr-xr-x    2 applicat applicat      4096 Feb  6 20:12 .
drwxrwxr-x    3 www-data www-data      4096 Feb  6 20:08 ..
-rw-r--r--    1 applicat applicat     85827 Feb  6 20:11 thumbnail_014f6f0205bc38df6a2de7b011b1fad3_197.jpg
-rw-r--r--    1 applicat applicat     61343 Feb  6 20:10 thumbnail_07ed508b08438d774822b848fa1998c3_192.jpg
...snip...
-rw-r--r--    1 applicat applicat    113936 Feb  6 20:12 thumbnail_f70299c7b5a1522d7b5994e525a8ef45_201.jpg
-rw-r--r--    1 applicat applicat     90396 Feb  6 20:12 thumbnail_ff9f49cd22ea53f5c9708c38d5a147eb_202.jpg

@fr0tt
Copy link
Owner

fr0tt commented Feb 10, 2024

The thumbnail command works differently. It visits every website with an actual browser and tries to make a screenshot of it. It only takes care of links that do not have a thumbnail in the database. All your old links have a thumbnail path stored in the database.
Just surprisingly your /var/www/public/storage/thumbnails folder does not have them anymore, for some reason.

This never happend before, to my knowledge, and I can only speculate. Did you somehow change your volume ? Have you checked if there are multiple volumes for this application (that are not containing the database) ?

Edit: Your original problem could be related to that. Could it theoretically be possible that you used no volume at the beginning?

@jtabox
Copy link
Author

jtabox commented Feb 10, 2024

I did a fresh reinstall of Docker for a completely unrelated issue, but it was after the first issue appeared. Though my Docker has been bugging out before that, so it might have played a role.

In regards to the 2nd issue with the thumbnails, the original volume with the thumbnails was deleted altogether with the Docker fresh reinstall, which was expected. The links and various posts survived with the rest of Benotes' database because they're in a remote database.

So I was hoping that Benotes would recreate the missing thumbnails, either automatically or I could trigger it manually, but it seems like it thinks the thumbnails are already created so it won't bother. I guess it writes this info in its database (of which thumbnails are already done)? Is there some way to trigger the recreation of thumbnails? I mean other than just deleting the database altogether and reimporting every link, but it's well over 300+ at this point, and trying to mass import them previously as HTML has always lead to error 500.

@johnchristopher
Copy link

docker compose exec --user application app sh
php artisan tinker
User::first()->update(['password', Hash::make('myNewSuperPassword')]);

I had to set an associative array. It returned true but without updating the value.

User::first()->update(['password' => Hash::make('myNewSuperPassword')]);

@fr0tt
Copy link
Owner

fr0tt commented Feb 17, 2024

It is not really designed for assuming the database still exists, yet all other files are lost.
You can either try again to import them and open another issue if there's in issue arising.
Otherwise you could manipulate the database by removing all thumbnail image paths from the database similar to how you changed your user's password:

docker compose exec --user application app sh
php artisan tinker
Post::whereNotNull('image_path')->update(['image_path' => null]);

Thanks @johnchristopher for pointing out my typo !

fr0tt added a commit that referenced this issue Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants