Skip to content

Commit

Permalink
Fixed two small issues, added one method on Authentication. See CHANG…
Browse files Browse the repository at this point in the history
…ELOG.md for details.
  • Loading branch information
Robin de Graaf committed Apr 2, 2017
1 parent 88babe4 commit 46dcd35
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Parable PHP Framework Changelog

### 0.9.4

__Changes__
- Added `generatePasswordHash()` to `\Parable\Auth\Authentication`.

__Bugfixes__
- Fixed issue in `\Parable\Auth\Authentication` where without authentication data, a non-existing array key was read. Now that's a reason to say someone isn't validated. This only happened when calling `authenticate` and the password validating correctly.
- `\Parable\Framework\Dispatcher` can now handle nested namespaced controllers for default template files. So `Controller\Subnamespace\Home` will attempt to load `app/view/Subnamespace/Home/action.phtml`.

### 0.9.3

__Bugfixes__
- `\Parable\Http\Values\GetSet` incorrectly set the local resource when using `setAll()`.

### 0.9.2

__Changes__
Expand Down
23 changes: 18 additions & 5 deletions src/Auth/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class Authentication
{
/** @var null|\Model\User */
/** @var null|\Model\Users */
protected $user;

/** @var \Parable\Framework\Toolkit */
Expand Down Expand Up @@ -38,8 +38,11 @@ public function initialize()
{
if ($this->checkAuthentication()) {
$data = $this->getAuthenticationData();
if (!isset($data['user_id'])) {
return false;
}
$userId = $data['user_id'];
$user = $this->toolkit->getRepository(\Model\User::class)->getById($userId);
$user = $this->toolkit->getRepository(\Model\Users::class)->getById($userId);
if (!$user) {
$this->setAuthenticated(false);
$this->setAuthenticationData([]);
Expand All @@ -51,6 +54,16 @@ public function initialize()
return false;
}

/**
* @param $password
*
* @return bool|string
*/
public function generatePasswordHash($password)
{
return password_hash($password, PASSWORD_DEFAULT);
}

/**
* Checks whether there's an auth session
*
Expand Down Expand Up @@ -116,11 +129,11 @@ public function getAuthenticationData()
/**
* Set the authenticated user entity
*
* @param \Model\User $user
* @param \Model\Users $user
*
* @return $this
*/
public function setUser(\Model\User $user)
public function setUser(\Model\Users $user)
{
$this->user = $user;
return $this;
Expand All @@ -129,7 +142,7 @@ public function setUser(\Model\User $user)
/**
* Return the user entity
*
* @return null|\Model\User
* @return null|\Model\Users
*/
public function getUser()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Framework/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class App
protected $database;

/** @var string */
protected $version = '0.9.2';
protected $version = '0.9.4';

public function __construct(
\Parable\Filesystem\Path $path,
Expand Down
4 changes: 3 additions & 1 deletion src/Framework/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ public function dispatch(\Parable\Routing\Route $route)
} else {
if ($controller) {
$reflection = new \ReflectionClass($controller);
$controllerName = str_replace('\\', '/', $reflection->getName());
$controllerName = str_replace('Controller/', '', $controllerName);
$templateFile = $this->path->getDir(
'app/View/' . $reflection->getShortName() . '/' . $route->action . '.phtml'
'app/View/' . $controllerName . '/' . $route->action . '.phtml'
);
}
}
Expand Down

0 comments on commit 46dcd35

Please sign in to comment.