I have to combine two array into single inside Json encode. my code is,
// Controller
$email = $this->input->get('email');
$pass = $this->input->get('password');
$enc_pass = 0;
$get_pass = $this->select->selectData($email);
if(!empty($get_pass)) {
foreach($get_pass as $password)
$enc_pass = $password['user_password'];
$dec_pass = $this->encrypt->decode($enc_pass);
if($pass == $dec_pass) {
$details = array('tag' => 'login', 'status' => 'true');
echo json_encode(array_merge($get_pass, $details));
}
else {
$details = array('tag' => 'login', 'status' => 'false', 'error_msg' => 'Incorrect Email or Password');
echo json_encode($details);
}
}
else {
$details = array('tag' => 'login', 'status' => 'false', 'error_msg' => 'Incorrect Email or Password');
echo json_encode($details);
}
// Model
public function selectData($email) {
$query = $this->db->query('SELECT * FROM tbl_user WHERE email = "'.$email.'"');
$count = $query->num_rows();
if($count > 0)
return $result = $query->result_array();
else
return 0;
}
Now the output for the above code is,
{"0":{"user_id":"1","user_name":"Jithin Varghese","user_email":"jithinvarghese111#gmail.com","user_phone":"9947732296","user_status":"1"},"tag":"login","status":"true"}
Required output is,
{"user_id":"1","user_name":"Jithin Varghese","user_email":"jithinvarghese111#gmail.com","user_phone":"9947732296","user_status":"1","tag":"login","status":"true"}
How to get the required output. I have tried a lot. How to implement this.
Thankyou.
Related
i want to write a API for updating data in sql. I am using CI for it.I am new to this field.while i have written it is not working in localhost itself .Can anyone help me? I am attaching my controller and model here.it is showing an error like this page is not working
function editprofile($id,$data) {
$this->db->where(array('user_id' => $id));
$this->db->update('registrationdetails', $data);
if(!empty($id))
{
$result = true;
} else {
$result = false;
}
return $result;
}
public function updateuser()
{
$adminId = 1;
$AUTHENTIC_KEY = "4u0IOxa1YTwNo38QjArD9ysW6PgVnbX7vtlJ";
$user_id=2;
$firstname ="aiswarya";
$lastname ="mathew";
$email ="aiswarya#gmail.com";
$password ="aiswarya";
$confirmpassword ="aiswarya";
$contactnumber ="999999999";
$gender ="female";
$address ="canada";
$department ="cse";
$designation ="swe";
$Admindetails = $this->common->CheckValidAdmin($adminId,$AUTHENTIC_KEY);
if($Admindetails != false)
{
$validAdmin = array('authentication_key' => $Admindetails->authentication_key,
'admin_id' => $Admindetails->id
);
$data = array();
$data = array('firstname'=>$firstname,'lastname'=>$lastname,'email'=>$email,'password'=>$password,'confirmpassword'=>$confirmpassword,'contactnumber'=>$contactnumber,'gender'=>$gender,'address'=>$address,'department'=>$department,'designation'=>$designation);
$status = $this->user->editprofile($user_id,$data);
if($status == true)
{
$response = array('status' => 200,
'message' => 'updated successfully',
'admin_details' => $validAdmin
);
} else {
$response = array('status' => 404,
'message' => 'unable to add, please try again',
'admin_details' => $validAdmin);
}
} else {
$response = array('status' => 404,
'message' => 'Authentication Failed');
}
echo json_encode($response);
}
function editprofile($data) {
if(!empty($data['user_id']))
{
$this->db->where(array('user_id' => $data['user_id']));
$this->db->update('registrationdetails', $data);
$result = true;
} else {
$result = false;
}
return $result;
}
public function updateuser()
{
$data['adminId'] = 1;
$data['AUTHENTIC_KEY'] = "4u0IOxa1YTwNo38QjArD9ysW6PgVnbX7vtlJ";
$data['user_id']=2;
$data['firstname'] ="aiswarya";
$data['lastname'] ="mathew";
$data['email'] ="aiswarya#gmail.com";
$data['password'] ="aiswarya";
$data['confirmpassword'] ="aiswarya";
$data['contactnumber'] ="999999999";
$data['gender'] ="female";
$data['address'] ="canada";
$data['department'] ="cse";
$data['designation'] ="swe";
$Admindetails = $this->common->CheckValidAdmin($data['adminId'],$data['AUTHENTIC_KEY']);
if($Admindetails != false)
{
$validAdmin = array('authentication_key' => $Admindetails->authentication_key,
'admin_id' => $Admindetails->id);
$status = $this->user->editprofile($data);
if($status == true)
{
$response = array('status' => 200,
'message' => 'updated successfully',
'admin_details' => $validAdmin
);
} else {
$response = array('status' => 404,
'message' => 'unable to add, please try again',
'admin_details' => $validAdmin);
}
} else {
$response = array('status' => 404,
'message' => 'Authentication Failed');
}
echo json_encode($response);
}
I am trying to fetch data from database in code-igniter .Bur this loop return only one loop .
$userchatData = $this->db->get($this->db->dbprefix('usres_chat'))->result_array();
foreach($userchatData as $key => $userdata)
{
$userdatas[]= array(
'chat_id' => $userdata['chat_id'],
'chat_from' => $userdata['chat_from'],
'created_date' => $userdata['created_date']
);
}
$data['ChatdatabyId'] = $userdatas;
$data['responseCode'] = '200';
$data['responseMessage'] = 'User listing successfully';
echo json_encode($data);
You need to define $userdatas=array(); outside the loop. It is inside the loop that's why it overrides the data and returns the last record.
$userchatData = $this->db->get($this->db->dbprefix('usres_chat'))->result_array();
$userdatas = array();
foreach($userchatData as $key => $userdata){
$userdatas[]= array(
'chat_id' => $userdata['chat_id'],
'chat_from' => $userdata['chat_from'],
'created_date' => $userdata['created_date']
);
}
$data['ChatdatabyId'] =$userdatas;
$data['responseCode'] = '200';
$data['responseMessage'] = 'User listing successfully';
echo json_encode($data);
Hope this will help you :
$userchatData = $this->db->get($this->db->dbprefix('usres_chat'))->result_array();
foreach($userchatData as $key => $userdata)
{
$userdatas[$key]['chat_id'] = $userdata['chat_id'];
$userdatas[$key]['chat_from'] = $userdata['chat_from'];
$userdatas[$key]['created_date'] = $userdata['created_date'];
}
/*print_r($userdatas); output here*/
$data['ChatdatabyId'] = $userdatas;
$data['responseCode'] = '200';
$data['responseMessage'] = 'User listing successfully';
}
echo json_encode($data);
I am trying to connect to a different database. I have a script for creating a new instance from an SQL file. I am creating users by inserting into the main database table and then using the same database as the master login table with all the users. I am trying to login to another database and use that database. I am getting a blank home page on trying to login to another database and also in some cases I am not able to connect to another database at all and end up using the same master db. I am storing the company name in a session and using it in all model files and connecting to the db. I tried everything but nothing seems to work. My controller model and view files are as follows:
model: mod_login.php
<?php
class mod_login extends CI_Model{
var $myTables;
#print_r($this->db->last_query());
function __construct(){
parent::__construct();
$companyName = $companyName = $this->session->userdata('company');
$otherdb = $this->load->database("$companyName", TRUE);
$this->myTables=$this->config->item('myTables');
$this->load->helper('cookie');
}
function validate_admin_login(){
$this->form_validation->set_rules('username', 'Username', 'trim|required');
$this->form_validation->set_rules('userpass', 'Password', 'trim|required');
if ($this->form_validation->run() == TRUE){
return $this->check_admin_login();
}else{
return validation_errors();
}
}
function check_cookie_login(){
$this->db->where('username', trim($this->input->cookie('uusername')));
$this->db->where('userpass ', sha1(trim($this->input->cookie('userpass'))));
$this->db->where('status', '1');
$this->db->where('deleted', '0');
$this->db->select('*');
$query = $this->db->get($this->myTables['users']);
if($query->num_rows() > 0){
$row = $query->row();
$this->db->where('userid', $row->id);
$this->db->select('firstname,lastname,profileimage');
$query1 = $this->db->get($this->myTables['users_details']);
$row1 = $query1->row();
$newdata = array(
'is_admin_logged_in' => true,
'admin_user_name' => $row->username,
'admin_userpass' => $row->userpass,
'admin_id'=>$row->id,
'admin_lastlogin'=>date("d-m-Y H:i:s",$row->lastlogin),
'admin_lastloginip'=>$row->lastloginip,
'lastrefresh'=>time()
);
$this->session->set_userdata($newdata);
$this->update_admin_login_time($this->session->userdata('admin_id'));
$this->admin_init_elements->set_global_user($row->username,$row->userpass);
if($this->input->post('remember'))
{
$cookie = array('name' => 'username','value' => $row->username,'expire' => time()+7600,'secure' => false);
$this->input->set_cookie($cookie);
}
$name = $row1->firstname.' '.$row1->lastname;
$cookie1 = array('name' => 'name','value' => $name,'expire' => time()+7600,'secure' => false);
$this->input->set_cookie($cookie1);
$cookie2 = array('name' => 'image','value' => $row1->profileimage,'expire' => time()+7600,'secure' => false);
$this->input->set_cookie($cookie2);
return 'Login Successful';
}else{
}
}
function check_admin_login(){
$this->db->where('username', trim($this->input->post('username')));
$this->db->where('userpass ', sha1(trim($this->input->post('userpass'))));
$this->db->where('status', '1');
$this->db->where('deleted', '0');
$this->db->select('*');
$query = $this->db->get($this->myTables['users']);
if($query->num_rows() > 0){
$row = $query->row();
$this->db->where('userid', $row->id);
$this->db->select('firstname,lastname,profileimage,company');
//$query1 = $this->db->query("Select * from pr_users_details where userid = '".$row->id."'");
$query1 = $this->db->get($this->myTables['users_details']);
$row1 = $query1->row();
$newdata = array(
'is_admin_logged_in' => true,
'admin_user_name' => $row->username,
'admin_userpass' => $row->userpass,
'admin_id'=>$row->id,
'admin_lastlogin'=>date("d-m-Y H:i:s",$row->lastlogin),
'admin_lastloginip'=>$row->lastloginip,
'lastrefresh'=>time(),
'company'=>$row1->company
);
$company = $row1->company;
$this->session->set_userdata($newdata);
$companyName = $this->session->userdata('company');
$otherdb = $this->load->database("$companyName", TRUE);
echo "<pre>";
print_r($this->session->all_userdata());
echo "</pre>";
$this->update_admin_login_time($this->session->userdata('admin_id'));
$this->admin_init_elements->set_global_user($row->username,$row->userpass);
if($this->input->post('remember'))
{
$cookie = array('name' => 'username','value' => $row->username,'expire' => time()+7600,'secure' => false);
$this->input->set_cookie($cookie);
}
$name = $row1->firstname.' '.$row1->lastname;
$cookie1 = array('name' => 'name','value' => $name,'expire' => time()+7600,'secure' => false);
$this->input->set_cookie($cookie1);
$cookie2 = array('name' => 'image','value' => $row1->profileimage,'expire' => time()+7600,'secure' => false);
$this->input->set_cookie($cookie2);
return 'Login Successful';
}else{
return 'Incorrect Username or Password.';
}
}
Controller: login.php
<?php
class login extends CI_Controller
{
var $data;
function __construct() {
parent::__construct();
$this->load->helper('cookie');
$is_admin_logged_in = $this->admin_init_elements->admin_logged_in_status();
global $USER;
if($is_admin_logged_in == TRUE){
redirect('home');
//;
}
//populate viewfor header / footer elements
$this->admin_init_elements->init_elements('N');
$this->load->model('mod_login');
}
function index(){
//if Admin already logged in, send to Admin home
$this->data['message']='';
$this->data['msg_class'] = '';
$post_array=$this->input->post();
$data['old_images']=$this->mod_common->getBgImages();
if($this->input->cookie('remember') == 'on')
{
//echo $this->input->cookie('username');
$this->data['message']=strip_tags($this->mod_login->check_cookie_login());
if($this->data['message']=='Login Successful'){
$this->data['msg_class'] = 'sukses';
redirect('home');
}else{
$this->data['msg_class'] = 'gagal';
}
}
if($this->input->post('action')=='adminLogin'){
//print_r($this->input->post()); die;
if(isset($post_array['remember'])){
$username_cookie= array(
'name' => 'uusername',
'value' => $post_array['username'],
'expire' => '865000',
'secure' => FALSE
);
$password_cookie= array(
'name' => 'userpass',
'value' => $post_array['userpass'],
'expire' => '865000',
'secure' => FALSE
);
$remember_cookie= array(
'name' => 'remember',
'value' => 'on',
'expire' => '865000',
'secure' => FALSE
);
$this->input->set_cookie($username_cookie);
$this->input->set_cookie($password_cookie);
$this->input->set_cookie($remember_cookie);
//die;
}
else
{
if($this->input->cookie('remember') == 'on')
{
if($this->input->cookie('uusername') != $post_array['username'])
{
delete_cookie("remember");
delete_cookie("uusername");
delete_cookie("userpass");
}
}
}
$this->data['message']=strip_tags($this->mod_login->validate_admin_login());
if($this->data['message']=='Login Successful'){
$this->data['msg_class'] = 'sukses';
redirect('home');
}else{
$this->data['msg_class'] = 'gagal';
}
} /*else if(isset()){
}*/
///////////////////////
$this->data['cookieRemember'] = $this->input->cookie('remember');
$this->data['cookieUsername'] = $this->input->cookie('username');
$this->data['cookiePassword'] = $this->input->cookie('userpass');
//echo $this->data['cookieRemember'];echo $this->data['cookieUsername']; echo $this->data['cookiePassword'];
//////////////////////
$this->data['cookiename'] = $this->input->cookie('name', false);
$this->data['cookieimage'] = $this->input->cookie('image', false);
$sess_msg = $this->session->userdata('session_msg');
$session_msg_class = $this->session->userdata('session_msg_class');
if(isset($sess_msg) && $sess_msg!= ''){
$this->data['message']=$sess_msg;
$this->data['msg_class'] = $session_msg_class!=''?$session_msg_class:'gagal';
}
//render full layout, specific to this function
$this->load->view('login', $this->data);
}
View: home.php
<?php
class home extends CI_Controller
{
var $data;
function __construct() {
parent::__construct();
//populate viewfor header / footer elements
$this->admin_init_elements->init_elements();
#$this->load->model('admin_m');
}
function index(){
$data = array();
//if Admin already logged in, send to Admin home
#$this->data['maincontent'] = $this->load->view('maincontents/gridview',$data,TRUE);
$data['lastlogin_details'] = $this->admin_lastlogin_details();
$this->data['maincontent'] = $this->load->view('maincontents/dashboard',$data,true);
//render full layout, specific to this function
$this->load->view('layout', $this->data);
}
function admin_lastlogin_details(){
$lastlogin_det['lastlogin'] = $this->session->userdata('admin_lastlogin');
$lastlogin_det['lastloginip'] = $this->session->userdata('admin_lastloginip');
return $lastlogin_det;
}
It displays the home.php but it displays a blank page without errors
I have a form and it's been bugging for a while now, when i have all the information filled up in the forms it seems to insert it very quick, however if one or more fields are empty it doesn't work at all
the query i am using to insert into the database is. i am trying to figure out if i can use Insert_delay and maybe it will solve the problem? any possible solutions or changes i need to do
function student($param1 = '', $param2 = '', $param3 = '')
{
if ($this->session->userdata('admin_login') != 1)
redirect('login', 'refresh');
if ($param1 == 'create') {
$data['name'] = $this->input->post('name');
$data['sex'] = $this->input->post('sex');
$data['address'] = $this->input->post('address');
$data['phone'] = $this->input->post('phone');
$data['email'] = $this->input->post('email');
$data['password'] = $this->input->post('password');
$data['year'] = $this->input->post('year');
$data['rate'] = $this->input->post('rate');
$data['class_id'] = $this->input->post('class_id');
$data['class_id2'] = $this->input->post('class_id2');
$data['class_id3'] = $this->input->post('class_id3');
$data['class_id4'] = $this->input->post('class_id4');
$data['parent_id'] = $this->input->post('parent_id');
$data['roll'] = $this->input->post('roll');
$this->db->insert_('student', $data);
$student_id = $this->db->insert_id();
$this->session->set_flashdata('flash_message' , get_phrase('Student_added_successfully'));
$this->email_model->account_opening_email('student', $data['email']); //SEND EMAIL ACCOUNT OPENING EMAIL
redirect(base_url() . 'index.php?admin/student_add/' . $data['class_id'], 'refresh');
In controller
function student($param1, $param2 $param3 )
{
if ($this->session->userdata('admin_login') != 1)
{
redirect('login', 'refresh');
}
else
{
if($param1 == 'create') {
$result = $this->model_name->insert_data();
if ($result != FALSE) {
$email => $this->input->post('email');
$confirm = $this->email_model->account_opening_email('student', $email); # do same as insert
if ($confirm != FALSE) {
$this->session->set_flashdata('flash_message' , get_phrase('Student_added_successfully'));
redirect(base_url() . 'index.php?admin/student_add/' . $data['class_id'], 'refresh');
}
else
{
echo "Mail send failed";
}
}
else
{
echo "param1 is not create";
}
}
}
}
In Model
public function insert_data()
{
# to isert data, I add them in to one array
$data = array(
'name' => $this->input->post('name'),
'sex' => $this->input->post('sex'),
'address' => $this->input->post('address'),
'phone' => $this->input->post('phone'),
'email' => $this->input->post('email'),
'password' => $this->input->post('password'),
'year' => $this->input->post('year'),
'rate' => $this->input->post('rate'),
'class_id' => $this->input->post('class_id'),
'class_id2' => $this->input->post('class_id2'),
'class_id3' => $this->input->post('class_id3'),
'class_id4' => $this->input->post('class_id4'),
'parent_id' => $this->input->post('parent_id'),
'roll' => $this->input->post('roll')
);
if (!$this->db->insert('student', $data)) {
# insert FAILED
return FALSE;
}
else{
# insert SUCCESS
$slast_id = $this->db->insert_id(); # get last insert ID
return = $slast_id;
}
}
I want the auth component to allow user to login entrying either username or email.
In my users table, both fields - userName and userEmail are unique.
At time of registration, the password is generated like:
sha1($username.$password);
The problem is that user is not able to login using email.
App Controller
var $components = array('Auth');
public function beforeFilter(){
if(isset($this->params['prefix']) && $this->params['prefix'] == 'webadmin') {
$this->Auth->userModel = 'Admin';
$this->Auth->logoutRedirect = $this->Auth->loginAction = array('prefix' => 'webadmin', 'controller' => 'login', 'action' => 'index');
$this->Auth->loginError = 'Invalid Username/Password Combination!';
$this->Auth->authError = 'Please login to proceed further!';
$this->Auth->flashElement = "auth.front.message";
$this->Auth->loginRedirect = array('prefix'=>'webadmin', 'controller'=>'dashboard', 'action'=>'index');
}
else{
$this->layout="front";
//$this->Auth->autoRedirect = false;
// $this->Auth->logoutRedirect = $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
// $this->Auth->loginRedirect = array('controller'=>'blogs', 'action'=>'index');
$this->Auth->fields = array(
'username' => 'userName',
'password' => 'password'
);
$this->Auth->userScope = array('User.status'=>1);
$this->Auth->loginError = "The username/email and password you entered doesn't match our records.";
$this->Auth->authError = 'Please login to view this page!';
$this->Auth->flashElement = "auth.front.message";
$this->Auth->loginRedirect = array('controller'=>'profiles', 'action'=>'index');
}
Users Controller: the login function goes like:
if(!empty($this->data))
{
// Try to login with Email
if (!empty($this->Auth->data)) {
// save username entered in the login form
$username = $this->Auth->data['User']['userName'];
// find a user by e-mail
$find_by_email = $this->User->find('first', array(
'conditions' => array('userEmail' => $this->Auth->data['User']['userName']),
'fields' => 'userName'));
// found
if (!empty($find_by_email))
{
$this->Auth->data['User']['userName'] = $find_by_email['User']['userName'];
$this->data['User']['password']=$this->Auth->data['User']['password'];
if (!$this->Auth->login($this->data)) {
// login failed
// bring back the username entered in the login form
$this->Auth->data['User']['username'] = $username;
} else {
$this->Session->delete('Message.auth');
// redirect
if ($this->Auth->autoRedirect) {
$this->redirect($this->Auth->redirect(), null, true);
}
}
}
}
}
Auth.php:(I have made some changes here in the way password is generated as I am using the cakephp session to auto-login to SMF forum.)
function login($data = null) {
$data['User.password'] = sha1(strtolower($data['User.userName']) . $_POST['data']['User']['password']);
$this->__setDefaults();
$this->_loggedIn = false;
if (empty($data)) {
$data = $this->data;
}
if ($user = $this->identify($data)) {
$this->Session->write($this->sessionKey, $user);
$this->_loggedIn = true;
}
return $this->_loggedIn;
}
I took help from this link, but I am not getting username in $data['User.userName'] in auth.php, I getting email here, so the password goes wrong and results in login failure.
Please help.
You have error in the conditions, it should be:
'conditions' => array('userEmail' => $this->Auth->data['User']['email']),
You are checking the username .
The only way I could make it work is by modifying auth.php in cake.
App Controller
I added this to the code in before filter:
$this->Auth->fields = array(
'username' => 'userName',
'email'=>'userEmail',
'password' => 'password'
);
Users Controller I removed all the extra code.
Auth.php
I made changes to the identify function to check email after encrypting the password in //the way I wanted.
function identify($user = null, $conditions = null) {
if ($conditions === false) {
$conditions = array();
} elseif (is_array($conditions)) {
$conditions = array_merge((array)$this->userScope, $conditions);
} else {
$conditions = $this->userScope;
}
$model =& $this->getModel();
if (empty($user)) {
$user = $this->user();
if (empty($user)) {
return null;
}
} elseif (is_object($user) && is_a($user, 'Model')) {
if (!$user->exists()) {
return null;
}
$user = $user->read();
$user = $user[$model->alias];
} elseif (is_array($user) && isset($user[$model->alias])) {
$user = $user[$model->alias];
}
if (is_array($user) && (isset($user[$this->fields['username']]) || isset($user[$model->alias . '.' . $this->fields['username']]))) {
if (isset($user[$this->fields['username']]) && !empty($user[$this->fields['username']]) && !empty($user[$this->fields['password']])) {
if (trim($user[$this->fields['username']]) == '=' || trim($user[$this->fields['password']]) == '=') {
return false;
}
$find = array(
$model->alias.'.'.$this->fields['username'] => $user[$this->fields['username']],
$model->alias.'.'.$this->fields['password'] => $user[$this->fields['password']]
);
} elseif (isset($user[$model->alias . '.' . $this->fields['username']]) && !empty($user[$model->alias . '.' . $this->fields['username']])) {
if (trim($user[$model->alias . '.' . $this->fields['username']]) == '=' || trim($user[$model->alias . '.' . $this->fields['password']]) == '=') {
return false;
}
// my code starts
$user['User.userEmail']=$user['User.userName'];
//find username using email
$find_by_email= $model->find('first', array(
'fields' => array('User.userName','User.realpass'),
'conditions' => array($model->alias.'.'.$this->fields['email'] => $user[$model->alias . '.' . $this->fields['email']]),
'recursive' => 0
));
if(!empty($find_by_email))
{
$uname=strtolower($find_by_email['User']['userName']);
$pwd=$user[$model->alias . '.' . $this->fields['password']];
}
else
{
$uname=strtolower($user[$model->alias . '.' . $this->fields['username']]);
$pwd=$user[$model->alias . '.' . $this->fields['password']];
}
$thepassword = sha1($uname.$pwd); // encrypt password
// find user where username or email equals to the username passed
$find = array(
'OR' => array($model->alias.'.'.$this->fields['username'] => $user[$model->alias . '.' . $this->fields['username']], $model->alias.'.'.$this->fields['email'] => $user[$model->alias . '.' . $this->fields['username']]),
$model->alias.'.'.$this->fields['password'] => $thepassword
);
} else {
return false;
}
$cond=array_merge($find, $conditions);
$data = $model->find('first', array(
'conditions' => $cond,
'recursive' => 0
));
// my code ends here
if (empty($data) || empty($data[$model->alias])) {
return null;
}
} elseif (!empty($user) && is_string($user)) {
$data = $model->find('first', array(
'conditions' => array_merge(array($model->escapeField() => $user), $conditions),
));
if (empty($data) || empty($data[$model->alias])) {
return null;
}
}
if (!empty($data)) {
if (!empty($data[$model->alias][$this->fields['password']])) {
unset($data[$model->alias][$this->fields['password']]);
}
return $data[$model->alias];
}
return null;
}
Lastly, I commented the password encrypt code to return the simple password so that I can encrypt it the wat I needed in the above function.
function password($password) {
//return Security::hash($password, null, true);
return $password;
}