ソースを参照

user shell fix

euromark 12 年 前
コミット
80242cdbf3
2 ファイル変更10 行追加11 行削除
  1. 7 10
      Console/Command/UserShell.php
  2. 3 1
      View/Helper/CommonHelper.php

+ 7 - 10
Console/Command/UserShell.php

@@ -6,7 +6,6 @@ if (!defined('CLASS_USER')) {
 
 App::uses('AppShell', 'Console/Command');
 App::uses('ComponentCollection', 'Controller');
-//App::uses('AuthExtComponent', 'Tools.Controller/Component');
 
 /**
  * Create a new user from CLI
@@ -32,7 +31,6 @@ class UserShell extends AppShell {
 			App::import('Component', 'Auth');
 			$this->Auth = new AuthComponent(new ComponentCollection());
 		}
-		//ConnectionManager::sourceList()
 
 		while (empty($username)) {
 			$username = $this->in(__('Username (2 characters at least)'));
@@ -74,14 +72,14 @@ class UserShell extends AppShell {
 		}
 
 		$this->out('');
-		$pwd = $this->Auth->password($password);
-
+		$this->User->Behaviors->load('Tools.Passwordable', array('confirm' => false));
+		//$this->User->validate['pwd']
 		$data = array('User' => array(
-			'password' => $pwd,
+			'pwd' => $password,
 			'active' => 1
 		));
 		if (!empty($username)) {
-			$usernameField = $this->User->displayField; //'username';
+			$usernameField = $this->User->displayField;
 			$data['User'][$usernameField] = $username;
 		}
 		if (!empty($email)) {
@@ -111,18 +109,17 @@ class UserShell extends AppShell {
 		}
 
 		$this->out('');
-		$continue = $this->in(__('Continue? '), array('y', 'n'), 'n');
+		$continue = $this->in(__('Continue?'), array('y', 'n'), 'n');
 		if ($continue !== 'y') {
 			return $this->error('Not Executed!');
 		}
 
 		$this->out('');
 		$this->hr();
-		if ($this->User->save($data)) {
-			$this->out('User inserted! ID: ' . $this->User->id);
-		} else {
+		if (!$this->User->save($data)) {
 			return $this->error('User could not be inserted (' . print_r($this->User->validationErrors, true) . ')');
 		}
+		$this->out('User inserted! ID: ' . $this->User->id);
 	}
 
 }

+ 3 - 1
View/Helper/CommonHelper.php

@@ -682,7 +682,9 @@ piwikTracker.enableLinkTracking();
 	 * @return array roles
 	 */
 	public function roleNamesTranslated($value) {
-		if (empty($value)) { return array(); }
+		if (empty($value)) {
+			return array();
+		}
 		$ret = array();
 		$translate = (array)Configure::read('Role');
 		if (is_array($value)) {