-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from cjsaylor/2.4.2
2.4.2
- Loading branch information
Showing
9 changed files
with
256 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
.project | ||
|
||
app/Vendor/ | ||
app/Plugin/DebugKit | ||
app/Plugin/GChart | ||
|
||
# config | ||
app/Config/environment.php | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
use Mailgun\Mailgun; | ||
|
||
App::uses('Component', 'Controller'); | ||
|
||
Class CustomEmailComponent extends Component { | ||
|
||
const SEND_OK = 200; | ||
|
||
public function getMailer() { | ||
return new Mailgun(Configure::read('Email.mailgun.api_key')); | ||
} | ||
|
||
public function send($to, $subject, $template, $data, $type = 'text') { | ||
$body = $this->evaluate(APP . "/View/Emails/$type/$template.ctp", $data); | ||
$result = $this->getMailer()->sendMessage(Configure::read('Email.mailgun.domain'), array( | ||
'from' => 'Boxmeup Team <[email protected]>', | ||
'to' => $to, | ||
'subject' => $subject, | ||
'text' => $body | ||
)); | ||
return $result->http_response_code === static::SEND_OK; | ||
} | ||
|
||
/** | ||
* Get the rendered output of a ctp file. | ||
* | ||
* @param string $filePath | ||
* @param array $data | ||
* @return string | ||
*/ | ||
protected function evaluate($filePath, $data = array()) { | ||
extract($data); | ||
ob_start(); | ||
include $filePath; | ||
return ob_get_clean(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ class UsersController extends AppController { | |
|
||
public $name = 'Users'; | ||
|
||
public $components = array('Email'); | ||
public $components = array('CustomEmail'); | ||
|
||
protected $ssl = array( | ||
'login', 'signup', 'account', 'reset_password', 'auth' | ||
|
@@ -148,19 +148,21 @@ public function forgot_password() { | |
$secretKey = ClassRegistry::init('Api.ApiUser')->getSecretKey($apiKey); | ||
$dynKey = base64_encode(date('c')); | ||
$hash = sha1($dynKey . $secretKey); | ||
$this->Email->to = $this->request->data['User']['email']; | ||
$this->Email->subject = 'Boxmeup Password Recovery'; | ||
$this->Email->replyTo = '[email protected]'; | ||
$this->Email->from = 'Boxmeup App <[email protected]>'; | ||
$this->Email->template = 'forgot_password'; | ||
$this->Email->sendAs = 'text'; | ||
$this->set(array( | ||
'password' => $new_password, | ||
'api_key' => $apiKey, | ||
'dynamic_key' => $dynKey, | ||
'hash' => $hash | ||
)); | ||
$this->Email->send(); | ||
$sent = $this->CustomEmail->send( | ||
$this->request->data['User']['email'], | ||
'Boxmeup Password Recovery', | ||
'forgot_password', | ||
array( | ||
'password' => $new_password, | ||
'api_key' => $apiKey, | ||
'dynamic_key' => $dynKey, | ||
'hash' => $hash | ||
) | ||
); | ||
if (!$sent) { | ||
$this->Session->setFlash(__('Failed to send recovery email.'), 'notification/error'); | ||
$this->redirect('/users/forgot_password'); | ||
} | ||
} | ||
$this->Session->setFlash(__('Successfully sent recovery request.'), 'notification/success'); | ||
$this->redirect('/login'); | ||
|
Submodule DebugKit
deleted from
e314ca
Submodule GChart
deleted from
ad3769
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.