Ejemplo n.º 1
0
 /** @noinspection PhpUnusedPrivateMethodInspection
  * @param Request $request
  *
  * @return bool
  */
 private function sendNewPassword(Request $request)
 {
     $user_id = Validator::sanitizeText($request->post('user_id'));
     if (!$user_id) {
         throw new UnexpectedValueException();
     }
     $repo = new UserRepository($this->db);
     $user = $repo->where('id', '=', $user_id)->findSingle();
     $password = $this->auth->generatePassword();
     //print_r('new pw is '.$password); // TODO remove this
     $this->auth->setPassword($user->getName(), $password);
     $subject = 'Your password at ' . Request::createUrl() . ' was reset!';
     $message = 'Greetings,' . "\n\n" . $this->auth->getCurrentUser()->getName() . ' has reset your password for you at ' . Request::createUrl() . '.' . "\n\n";
     $message .= 'The new temporary password is: ' . $password . "\n";
     $message .= "\n" . 'Please change your password soon at ' . Request::createUrl(array('p' => 'user')) . '!';
     if (MailHandler::sendMail($user->getMail(), $subject, $message)) {
         return true;
     } else {
         $this->errors[] = 'The mail to the user could not be sent';
         return false;
     }
 }
Ejemplo n.º 2
0
                        $stmt->execute(array($name, $mail, $hash));
                        $user_id = $pdo->lastInsertId();
                        $pdo->exec('INSERT INTO users_roles (user_id, role_id) VALUES (' . $user_id . ', 1);');
                    } catch (PDOException $e) {
                        $error = true;
                        echo '<p class="error">' . $e->getMessage() . '</p>';
                    }
                    if ($error) {
                        echo '<p>Oops, this should not happen!</p>';
                    } else {
                        $subject = 'An account at ' . Config::ROOT_URL . ' was created for you!';
                        $message = 'Greetings, the installation script created an account for you at ' . Config::ROOT_URL . '.' . "\n\n";
                        $message .= 'Username: '******'Mail: ' . $mail . "\n";
                        $message .= 'Temporary password: '******'<p class="ok">Email was send! The installation is now complete.</p>';
                            echo '<h2>Delete this install directory!</h2><p>If you do not do this, everybody can screw up your installation.</p>';
                        } else {
                            echo '<p class="error">The email could not be sent!</p>';
                        }
                    }
                }
            }
        }
    }
}
?>
</body>
</html>
<?php