cakephp:如何通过从url中读取新记录到用户表中

时间:2011-11-04 04:46:08

标签: jquery html cakephp

我对这个cakephp&我有一个修复问题的任务,我们在brandx& amp; cakephp的brandstores平台。

我有一个CakePHP模型 - 用户。我在本地存储这些系统和其他数据的一些数据,如果用户存在于表中,那么它允许登录到商店,但如果用户不存在于表中,那么它必须创建该用户&用户应登录到商店,而不是创建显示

的用户
  

我们系统中没有此ID的用户请与管理员联系,我正在尝试通过传递用户名&来创建新用户。 url中的密码如下所述:

"http://mystorename.domainname.com/pages/index/username:" + username + "/password:" + password);

如果我将新用户插入表中,则可以成功登录但无法创建新用户。

我无法找到实现这一目标的方法。我怎么能解决这个问题有人能告诉我该怎么做?对不起,我的英语不好。提前谢谢..

以下是代码,请帮助解决此问题

 if(!empty($user_data))          {      

                 if($user_data[$this->userModel]['active']==2)
                 {
                     $this->Session->setFlash('accout disabled');
                     return false;
                 }

                 $user_data_logged = $model->find('first',array('conditions'=>$login_filter));  
     if(!empty($user_data_logged))
                 {

                     $model->save(array(    'id'=>$user_data[$this->userModel]['id'], $this->fields['recent_login']=>date('Y-m-d H:i:s'),
     $this->fields['login_attempts']=>0 ) );

     $this->Session->write('Auth.'.$this->userModel,$user_data[$this->userModel]);
                     $status = $this->shout("LOGIN_SUCCESS",$points); 
                     $this->authRedirect();
                     return true;

                 }
                 else
                 {
                     $login_attempts_made = $user_data[$this->userModel][$this->fields['login_attempts']];

     $model->save(array( 'id'=>$user_data[$this->userModel]['id'],
     $this->fields['login_attempts']=>$login_attempts_made+1  ) );
     if($user_data[$this->userModel][$this->fields['login_attempts']]>=$this->max_login_attempts)

     {
                         $model->save(array(    'id'=>$user_data[$this->userModel]['id'], 'active'=>2 ) ); $this->Session->setFlash($this->max_login_attempts.'
     login attempts over... accout disabled');

     return false;
                     }

                 }
                     }       else        {
                 $employee_id = $data[$this->fields['username']];
                 $user_data = $model->create('first',array('conditions'=>array($this->fields['username']=>$data[$this->fields['username']],$this->fields['password']=>$data[$this->fields['password']])));  
                 $model->save(array($this->fields['username']=>$data[$this->fields['username']],$this->fields['password']=>$data[$this->fields['password']]));
                 //$this->Session->setFlash("$employee_id User with this employee id is not available in our system. for more details & registration
     contact admin@domain.com");            
    //$status =$this->shout("LOGIN_FAIL",$employee_id); 
     //return false;        
     }

1 个答案:

答案 0 :(得分:0)

执行此操作:"http://mystorename.domainname.com/pages/index/username:" + username + "/password:" + password);非常不安全。你不应该将这些人的密码不受保护地传递给那样的URL。

其他人可以访问他们的浏览器历史记录(甚至使用javascript)并查看他们的密码。

您想要记住用户的购物车,然后将用户定向到注册页面。 用户完成注册后,将购物车保存给他们。

然后他们可以随时退回到他们想要的状态。