WillyJimmyDev / simple-quiz

A simple quiz administration written in PHP with a MySQL backend. Uses Bootstrap 3 and Slim PHP micro framework
http://elanman.com/simple-quiz/
Apache License 2.0
165 stars 73 forks source link

users forgotten password #16

Closed staverniti closed 9 years ago

staverniti commented 9 years ago

Hi,

i have an issue where the user has forgotten the password. is there away to have a forgotten password form? or somehow to reset it in MYSLQ? i've logged into PHPmy admin and removed the hash in hope to login but that doesn't work.

any thoughts?

thank you

WillyJimmyDev commented 9 years ago

Hi,

There isn't an easy way for a user to change/reset their password at the moment. I've just implemented the 'change password' feature for the Admin user but still need to do it for regular users. The password hashes are generated using the password_hash(). A temporary way to do it would be to generate a new route and just echo out the password_hash() for a hard coded string:

$app->get('/passwordreset/', function () {

    echo password_hash('newpassword', 1);
});

Visit /passwordreset in your browser and copy the displayed hash into the password field in phpmyadmin. Sorry it's a bit of a cludge but it is on my todo list.

staverniti commented 9 years ago

Hi ElanMan

Thanks for your prompt reply, i've edited the public.php with all the routes and it looks like below, however i get a 404 page not found, it's probably something simple i've missed but i cant spot it?

<?php $app->get('/', function () use ($app) { $simple = $app->simple; $quizzes = $simple->getQuizzes(); $categories = $simple->getCategories();

$session = $app->session;

$app->render('index.php', array('quizzes' => $quizzes, 'categories' => $categories, 'session' => $session));

});

$app->get('/passwordreset/', function () {

echo password_hash('TesTinG', 1);

});

$app->get('/requirements/', function () use ($app) {

$installer = $app->installer;
$requirements = $installer->getRequirements();
$simple = $app->simple;
$categories = $simple->getCategories();

$app->render('requirements.php', array( 'categories' => $categories,'requirements' => $requirements));

});

i thought maybe i needed to render a php for it so i tried adding in this line but made no difference $app->render('password.php');

WillyJimmyDev commented 9 years ago

Hi, I've just tested it on my set up and it works fine. Try adding another route and echoing something out. You don't need to render a file. If you still get a 404 after creating a new route, make sure you are editing the correct file (sounds silly but I've done it in the past!); i.e. are you working on local pc and not uploading the code to your server for example...

staverniti commented 9 years ago

Hi ElanMan,

Was def user error and your technique worked a charm. what i was doing wrong is i was doing http://mywebaddres/passwordreset it needed to be http://mywebaddres/induction/passwordreset

too add to give more background on the issue if anyone else is having problems, the reason why i have /induction is because i don't have ElanMan's "public dir files" in the root of my web server, i instead renamed the "public" folder to "induction" and kept the files in there, then i changed the URL Rewrite to point to this directory. a bit backwards i know but i'm hosting 2 sites from the server

thanks again for your help!

WillyJimmyDev commented 9 years ago

Glad you got it sorted out.