summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris Cornutt <enygma@phpdeveloper.org>2015-02-18 11:22:27 -0500
committerChris Cornutt <enygma@phpdeveloper.org>2015-02-18 11:22:27 -0500
commitc28bf9f85ffe9b68cc6ce415ec176e56c82d1cc2 (patch)
treeb51ba163688db09579c8d34fcd53447e48b7c691 /src
parent56d93558faf2b54e03bdb60f9fec3fad7fc297f2 (diff)
downloadgatekeeper-c28bf9f85ffe9b68cc6ce415ec176e56c82d1cc2.zip
gatekeeper-c28bf9f85ffe9b68cc6ce415ec176e56c82d1cc2.tar.gz
gatekeeper-c28bf9f85ffe9b68cc6ce415ec176e56c82d1cc2.tar.bz2
adding the addSecurityQuestion method to the UserModel
Diffstat (limited to 'src')
-rw-r--r--src/Psecio/Gatekeeper/UserModel.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/Psecio/Gatekeeper/UserModel.php b/src/Psecio/Gatekeeper/UserModel.php
index 1705460..f294587 100644
--- a/src/Psecio/Gatekeeper/UserModel.php
+++ b/src/Psecio/Gatekeeper/UserModel.php
@@ -464,4 +464,24 @@ class UserModel extends \Psecio\Gatekeeper\Model\Mysql
}
return $return;
}
+
+ /**
+ * Add a new security question to the current user
+ *
+ * @param array $data Security question data
+ * @return boolean Result of save operation
+ */
+ public function addSecurityQuestion(array $data)
+ {
+ if (!isset($data['question']) || !isset($data['answer'])) {
+ throw new \InvalidArgumentException('Invalid question/answer data provided.');
+ }
+
+ $question = new SecurityQuestionModel($this->getDb(), array(
+ 'question' => $data['question'],
+ 'answer' => $data['answer'],
+ 'userId' => $this->id
+ ));
+ return $this->getDb()->save($question);
+ }
} \ No newline at end of file