Example #1
0
    public function sendPW()
    {
        $sql = 'SELECT fldUserID FROM tblUser WHERE fldUser=?';
        if (($id = DB::oneValue(DB::DEF, $sql, Request::get('fldEmail'))) === false) {
            $msg = 'This email does not exist on this system.<br>' . 'Either choose a new email address or register as new customer.' . $this->forgotPassword();
        } else {
            $pw = Password::passGen(10, Password::MEDIUM);
            if (DB::driver() == DB::MYSQL) {
                $sql = 'UPDATE tblUser SET fldPassword=PASSWORD(?) WHERE fldUserID=?';
                DB::exec(DB::DEF, $sql, [$pw, $id]);
            } else {
                $sql = 'UPDATE tblUser SET fldPassword=? WHERE fldUserID=?';
                DB::exec(DB::DEF, $sql, [hash('md5', $pw), $id]);
            }
            // Update the Database with the new Password combo
            $boss = Cfg::get('boss');
            $desc = Cfg::get('desc');
            // create the email message to notify about a password request
            $body = '<h3>User requested password<br>Email: <b>%s</b></h3><br>From %s';
            Mailer::envelope()->format(Mailer::HTML_TEXT)->from(Request::get('fldEmail'))->to($boss)->subject('User requested password')->body(sprintf($body, Request::get('fldEmail'), $desc))->send();
            $body = <<<TXT
Message from %s

Here are your login details

Password: %s

Regards
%s
TXT;
            // create the email message to notify the user of his/her login details
            Mailer::envelope()->from($boss)->to(Request::get('fldEmail'))->subject('Login Request ' . $desc)->body(sprintf($body, $desc, $pw, $desc))->send();
            $msg = 'Soon you will receive an email that will contain your login details.';
        }
        return Widget::popupWrapper($msg, -1);
    }
Example #2
0
 public function __construct($value = null, $hatch = 14)
 {
     parent::__construct();
     $this->value = $value == null ? Password::passGen(6, Password::UPPER_ALPHA) : $value;
     $this->hatch = $hatch;
 }