Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: kolinger/square-framework
base: 6ded9699ab
...
head fork: kolinger/square-framework
compare: 1256ead58e
  • 3 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
View
42 Application/UI/Form.php
@@ -0,0 +1,42 @@
+<?php
+
+/**
+ * This file is part of the Square CMS
+ *
+ * Copyright (c) 2011, 2012 Tomáš Kolinger <tomas@kolinger.name>
+ *
+ * For the full copyright and license information, please view the file license.txt that was distributed with this source code.
+ */
+
+namespace Square\Application\UI;
+
+
+
+/**
+ * @author Tomáš Kolinger <tomas@kolinger.name>
+ */
+class Form extends \Nette\Application\UI\Form
+{
+
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setup();
+ $this->onSuccess[] = callback($this, 'process');
+ }
+
+
+
+ protected function setup()
+ {
+ }
+
+
+ /**
+ * @param Form $form
+ */
+ public function process(self $form)
+ {
+ }
+
+}
View
8 Application/UI/Presenter.php
@@ -24,6 +24,12 @@ class Presenter extends \Nette\Application\UI\Presenter
const CACHE_NAMESPACE = 'Square.Presenter.Autowire';
/**
+ * @var \Nette\Localization\ITranslator
+ * @autowire
+ */
+ protected $translator;
+
+ /**
* @var array
*/
private $autowire = array();
@@ -60,7 +66,7 @@ public function getTitle()
*/
public function setTitle($title)
{
- $this->title = $title;
+ $this->title = $this->translator->translate($title);
}
View
21 Utils/Password.php
@@ -62,8 +62,9 @@ public function __construct($hash = NULL)
public function setPassword($password = NULL)
{
$this->salt = Strings::random();
- $this->password = $password === NULL ? Strings::random() : $password;
- return $this->password;
+ $password = $password === NULL ? Strings::random() : $password;
+ $this->password = hash($this->algorithm, $this->salt . $password);
+ return $password;
}
@@ -81,13 +82,20 @@ public function setAlgorithm($algorithm)
/**
+ * @param string $password
* @return string
*/
- public function getHash()
+ public function getHash($password = NULL)
{
$hash = $this->algorithm . self::DELIMITER
- . $this->salt . self::DELIMITER
- . hash($this->algorithm, $this->salt . $this->password);
+ . $this->salt . self::DELIMITER;
+
+ if ($password === NULL) {
+ $hash .= $this->password;
+ } else {
+ $hash .= hash($this->algorithm, $this->salt . $password);
+ }
+
return $hash;
}
@@ -117,7 +125,8 @@ public function compare($value)
if ($value instanceof Password) {
return $this->getHash() === $value->getHash();
} else {
- return $this->getHash() === $value;
+ dump($this->getHash(), $this->getHash($value));
+ return $this->getHash() === $this->getHash($value);
}
}

No commit comments for this range

Something went wrong with that request. Please try again.