@@ -68,12 +68,14 @@ class TokensTable extends Table {
68
68
/**
69
69
* Stores new key in DB
70
70
*
71
+ * Checks if this key is already used (should be unique in table)
72
+ *
71
73
* @param string $type Type: necessary
72
74
* @param string|null $key Key: optional key, otherwise a key will be generated
73
75
* @param mixed|null $uid Uid: optional (if used, only this user can use this key)
74
76
* @param string|array|null $content Content: up to 255 characters of content may be added (optional)
75
- * NOW: checks if this key is already used (should be unique in table)
76
- * @return string key on SUCCESS , boolean false otherwise
77
+ *
78
+ * @return string|bool Key on success , boolean false otherwise
77
79
*/
78
80
public function newKey ($ type , $ key = null , $ uid = null , $ content = null ) {
79
81
if (!$ type ) {
@@ -118,7 +120,7 @@ public function newKey($type, $key = null, $uid = null, $content = null) {
118
120
* @param string $key : necessary
119
121
* @param mixed|null $uid : needs to be provided if this key has a user_id stored
120
122
* @param bool $treatUsedAsInvalid
121
- * @return array |false Content - if successfully used or if already used (used=1), FALSE else
123
+ * @return \Cake\ORM\Entity |false Content - if successfully used or if already used (used=1), FALSE else
122
124
*/
123
125
public function useKey ($ type , $ key , $ uid = null , $ treatUsedAsInvalid = false ) {
124
126
if (!$ type || !$ key ) {
@@ -128,7 +130,7 @@ public function useKey($type, $key, $uid = null, $treatUsedAsInvalid = false) {
128
130
if ($ uid ) {
129
131
$ options ['conditions ' ][$ this ->alias () . '.user_id ' ] = $ uid ;
130
132
}
131
- $ res = $ this ->find ('first ' , $ options );
133
+ $ res = $ this ->find ('all ' , $ options)-> first ( );
132
134
if (!$ res ) {
133
135
return false ;
134
136
}
0 commit comments