Skip to content
This repository

1.3 1685 #67

Closed
wants to merge 7 commits into from

2 participants

ceeram Mark Story
This page is out of date. Refresh to see the latest.
2  cake/libs/controller/components/auth.php
@@ -841,7 +841,7 @@ function &getModel($name = null) {
841 841
  */
842 842
 	function identify($user = null, $conditions = null) {
843 843
 		if ($conditions === false) {
844  
-			$conditions = null;
  844
+			$conditions = array();
845 845
 		} elseif (is_array($conditions)) {
846 846
 			$conditions = array_merge((array)$this->userScope, $conditions);
847 847
 		} else {
43  cake/tests/cases/libs/controller/components/auth.test.php
@@ -553,6 +553,49 @@ function testIsErrorOrTests() {
553 553
 	}
554 554
 
555 555
 /**
  556
+ * testIdentify method
  557
+ *
  558
+ * @access public
  559
+ * @return void
  560
+ */
  561
+	function testIdentify() {
  562
+		$this->AuthUser =& new AuthUser();
  563
+		$user['id'] = 1;
  564
+		$user['username'] = 'mariano';
  565
+		$user['password'] = Security::hash(Configure::read('Security.salt') . 'cake');
  566
+		$this->AuthUser->save($user, false);
  567
+
  568
+		$this->Controller->Auth->initialize($this->Controller);
  569
+		$this->Controller->Auth->userModel = 'AuthUser';
  570
+		$this->Controller->Auth->startup($this->Controller);
  571
+		$this->assertTrue($this->Controller->Auth->identify($user));
  572
+	}
  573
+
  574
+/**
  575
+ * testIdentifyWithConditions method
  576
+ *
  577
+ * @access public
  578
+ * @return void
  579
+ */
  580
+	function testIdentifyWithConditions() {
  581
+		$this->AuthUser =& new AuthUser();
  582
+		$user['id'] = 1;
  583
+		$user['username'] = 'mariano';
  584
+		$user['password'] = Security::hash(Configure::read('Security.salt') . 'cake');
  585
+		$this->AuthUser->save($user, false);
  586
+
  587
+		$this->Controller->Auth->initialize($this->Controller);
  588
+		$this->Controller->Auth->startup($this->Controller);
  589
+		$this->Controller->Auth->userModel = 'AuthUser';
  590
+
  591
+		$this->assertFalse($this->Controller->Auth->identify($user, array('AuthUser.id >' => 2)));
  592
+
  593
+		$this->Controller->Auth->userScope = array('id >' => 2);
  594
+		$this->assertFalse($this->Controller->Auth->identify($user));
  595
+		$this->assertTrue($this->Controller->Auth->identify($user, false));
  596
+	}
  597
+
  598
+/**
556 599
  * testLogin method
557 600
  *
558 601
  * @access public
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.