make() public static method

public static make ( $value, $rounds = 12 )
Esempio n. 1
0
 public function login($email = null, $password = null, $remember = false)
 {
     if (!$email && !$password && $this->exists()) {
         session::put($this->_session_name, $this->_data->id);
     } else {
         $user = $this->find($email);
         if ($user) {
             if ($this->_data->password === hash::make($password, $this->_data->salt)) {
                 session::put($this->_session_name, $this->_data->id);
                 if ($remember) {
                     $hash = hash::unique();
                     $hash_check = $this->_db->get('users_session', array('user_id', '=', $this->_data->id));
                     if (!$hash_check->count()) {
                         $this->_db->insert('users_session', array('user_id' => $this->_data->id, 'hash' => $hash));
                     } else {
                         $hash = $hash_check->firstResult()->hash;
                     }
                     cookie::put($this->_cookie_name, $hash, config::get('remember/cookie_expiry'));
                 }
                 return true;
             }
         }
     }
     return false;
 }
Esempio n. 2
0
 public function auth()
 {
     $username = input::get('username');
     $password = input::get('password');
     $sandi = hash::make('admin');
     $ceklogin = DB::table('users')->where('password', '=', $sandi)->get();
     return $sandi;
 }
Esempio n. 3
0
 public function adduser()
 {
     $username = '******';
     $password = hash::make('admin');
     $data = ['id' => "", 'username' => $username, 'password' => $password, 'fullname' => 'admin', 'jobdesc' => 'admin'];
     $save = DB::table('users')->insert($data);
     return $data;
 }
 public function postRegister(Request $Request)
 {
     $input = Input::all();
     $rules = ['name' => 'required', 'email' => 'required|email|unique:users,email', 'password' => 'required', 'password_confirmation' => 'required|same:password'];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return redirect('/register')->withErrors($validator);
     } else {
         $obj = new user();
         $obj->name = Input::get('name');
         $obj->email = Input::get('email');
         $obj->password = hash::make(Request::get('password'));
         $obj->status = 'unactive';
         $obj->active_token = md5(time());
         $obj->save();
         $obj->sendMail(Input::get('email'), Input::get('name'), $obj->active_token, $obj->id);
         return redirect('/auth/login')->withErrors(['error' => 'Please check Email active account ']);
     }
 }
Esempio n. 5
0
 public function store(UserRequest $request)
 {
     //validate data input
     $data = $request->all();
     if (isset($data['image'])) {
         $thumb = $data['image'];
         $new = 'ava' . uniqid() . '.' . $thumb->getClientOriginalExtension();
         $thumb->move('upload/users', $new);
     }
     $data['image'] = $new;
     $obj = new User();
     $obj->name = $data['name'];
     $obj->email = $data['email'];
     $obj->role_id = $data['role_id'];
     $obj->password = hash::make($data['role_id']);
     $obj->status = 'active';
     $obj->remember_token = $data['_token'];
     $obj->image = $new;
     $obj->save();
     return redirect('admin/users');
 }
 public function postCreate()
 {
     $values = Request::all();
     if ($values['emp_first_name'] == '' || $values['emp_first_name'] == null) {
         return Response::json(array('success' => false, 'data' => 'Campo Nombre requerido'));
     }
     if ($values['emp_last_name'] == '' || $values['emp_last_name'] == null) {
         return Response::json(array('success' => false, 'data' => 'Campo Apellido requerido'));
     }
     if ($values['emp_address'] == '' || $values['emp_address'] == null) {
         return Response::json(array('success' => false, 'data' => 'Campo Dirección requerido'));
     }
     if ($values['emp_phone_number'] == '' || $values['emp_phone_number'] == null) {
         return Response::json(array('success' => false, 'data' => 'Campo Número Fijo requerido'));
     }
     if ($values['emp_job'] == '' || $values['emp_job'] == null) {
         return Response::json(array('success' => false, 'data' => 'Campo Puesto requerido'));
     }
     if ($values['emp_fk_business_unit'] == '' || $values['emp_fk_business_unit'] == null || $values['emp_fk_business_unit'] == 'null') {
         return Response::json(array('success' => false, 'data' => 'Campo Unidad de Negocio requerido'));
     }
     if ($values['emp_email'] == '' || $values['emp_email'] == null) {
         return Response::json(array('success' => false, 'data' => 'Campo Correo/Usuario requerido'));
     }
     if ($values['emp_password'] == '' || $values['emp_password'] == null) {
         return Response::json(array('success' => false, 'data' => 'Campo Contraseña requerido'));
     }
     $values['emp_password'] = hash::make($values['emp_password']);
     $rows = fil_employee::where('emp_email', '=', $values['emp_email'])->count();
     if ($rows == 1) {
         return Response::json(array('success' => false, 'data' => 'Este correo ya está en uso, por favor utilice otro correo'));
     }
     fil_employee::create($values);
     $response = Response::json(array('success' => true, 'data' => 'Empleado guardado con exito'));
     return $response;
 }
Esempio n. 7
0
 public function login($UserID = null, $Password = null, $remember = false)
 {
     // $user=$this->find($UserID);
     if (!$UserID && !$Password && $this->exists()) {
         session::put($this->_sessionName, $this->data());
     } else {
         $user = $this->find($UserID);
         // print_r($user);
         // print_r($this->_data);
         if ($user) {
             if ($this->data()->Password === hash::make($Password)) {
                 echo 'ok!';
                 // need to check the node_id/UserID
                 session::put($this->_sessionName, $this->data()->node_id);
                 if ($remember) {
                     $hash = hash::unique();
                     $hashCheck = $this->_database->get('User_session', array('UserID', '=', $this->data()->node_id));
                     if (!$hashCheck->counts()) {
                         $this->_database->insert('User_session', array('userID' => $this->data()->SessionID, 'Hash' => $hash));
                     } else {
                         $hash = $hashCheck->first()->hash;
                     }
                     cookie::put($this->_cookieName, $hash, config::get('remember/cookie_expiry'));
                 }
                 return true;
             }
         }
     }
     return false;
 }
Esempio n. 8
0
 if (token::check(input::get('token'))) {
     $validate = new validate();
     $validation = $validate->check($_POST, array('Password' => array('required' => true, 'min' => 6), 'password_again' => array('required' => true, 'matches' => 'Password')));
     if ($validation->passed()) {
         //session::flash('success','You registered successfully!');
         //header('Location: index.php');
         $user = new user(null, $_log);
         $salt = hash::salt(32);
         if ($data = $_db->get('Users', array('Username', '=', $username))) {
             //var_dump($data);
             if ($data->counts() > 0) {
                 if ($data->first()->User_Verified == 0) {
                     if ($data->first()->Confirm_Hash == $confirmCode) {
                         $oldUser = $data->first()->Old_User;
                         try {
                             $user->updateUser(array('Password' => hash::make(input::get('Password'), $salt), 'Salt' => $salt, 'User_Verified' => 1, 'Confirm_Hash' => null, 'Old_User' => null), $_GET['Username']);
                             session::flash('home', 'Your password has been created');
                             $_log->info('Username verified: ' . $username);
                             // Will be logged
                             if ($oldUser !== null) {
                                 try {
                                     if ($user->delete($oldUser)) {
                                         $_log->info('Old user deleted: ' . (string) $oldUser);
                                     } else {
                                         $_log->warning('Old user NOT deleted: ' . (string) $oldUser);
                                     }
                                 } catch (Exception $e) {
                                     var_dump($e->getMessage());
                                     $_log->info($e->getMessage());
                                     die($e->getMessage());
                                 }
Esempio n. 9
0
 public function login($username = null, $password = null, $remember = false)
 {
     if (!$username && !$password && $this->exists()) {
         //if no username or password sent to function and there is a user in database, used when remeber function is active
         session::put($this->_sessionName, $this->data()->Id);
     } else {
         $user = $this->find($username);
         if ($user) {
             if ($this->data()->Password === hash::make($password, $this->data()->Salt)) {
                 session::put($this->_sessionName, $this->data()->Id);
                 if ($remember) {
                     //if remeber option selected
                     $hash = hash::unique();
                     $hashCheck = $this->_db->get('User_Sessions', array('User_Id', '=', $this->data()->Id));
                     //check whether user session saved on db
                     if (!$hashCheck->counts()) {
                         $this->_db->insert('User_Sessions', array('User_Id' => $this->data()->Id, 'Hash' => $hash));
                     } else {
                         $hash = $hashCheck->first()->Hash;
                         //if already in session db use that hash (should not happen)
                     }
                     cookie::put($this->_cookieName, $hash, config::get('remember/cookie_expiry'));
                     //create login cookie
                 }
                 return true;
             } else {
                 $this->_log->warning('Wrong  password used for user: '******'Wrong username used: ' . $username);
             // Will be logged
             echo "Sorry, username not found. ";
         }
     }
     //end of not remember
     return false;
 }
Esempio n. 10
0
/*
if(input::exists()){
	echo input::get('FName');
}*/
//var_dump(token::check(input::get('token')));
if (input::exists()) {
    if (token::check(input::get('token'))) {
        //	echo 'token is working!!';
        $validate = new validation();
        $validation = $validate->check($_POST, array('emailAddr' => array('required' => true, 'min' => 2, 'max' => 20), 'FirstName' => array('required' => true, 'min' => 2, 'max' => 20), 'LastName' => array('required' => true, 'min' => 2, 'max' => 20), 'DOB' => array('required' => true), 'UserID' => array('required' => true, 'min' => 2, 'max' => 20, 'unique' => 'UserID'), 'Password' => array('required' => true, 'min' => 8, 'max' => 20), 'Gender' => array('required' => true)));
        if ($validation->passed()) {
            $user = new user();
            //$gender = form_input($_POST["gender"]);
            //$salt=hash::salt(32);
            try {
                $user->create(array('EmailAddress' => input::get('emailAddr'), 'FirstName' => input::get('FirstName'), 'LastName' => input::get('LastName'), 'DOB' => input::get('DOB'), 'UserID' => input::get('UserID'), 'Password' => hash::make(trim(input::get('Password'))), 'Gender' => input::get('Gender'), 'Group' => 1));
                //header('Location: index.php');
                //redirect::to('login.php');
                //echo $user->data()->Gender;
            } catch (Exception $e) {
                echo $e->getMessage();
            }
            session::flash('home', 'You have been registered and can login');
            redirect::to('login.php');
            //echo 'passed!';
            //session::flash('Sucess!!', 'Your are registered!');
        } else {
            foreach ($validation->errors() as $error) {
                echo $error . '<br>';
            }
        }
Esempio n. 11
0
 public function postRegister(Request $request)
 {
     $user = ["remember_token" => Request::get('_token'), "name" => Request::get('name'), "password" => hash::make(Request::get('password')), "email" => Request::get('email'), "role_id" => 1];
     User::Create($user);
 }
 public function run()
 {
     \DB::table('users')->insert(array('name' => 'martin', 'email' => '*****@*****.**', 'password' => \hash::make('123456')));
 }
Esempio n. 13
0
 /**
  * Hash the given value.
  *
  * @param  string  $value
  * @param  array   $options
  * @return string
  */
 function hash($value, $options = array())
 {
     return hash::make($value, $options);
 }
Esempio n. 14
0
require_once '../Core/init.php';
$user = new user(null, $_log);
if (!$user->isLoggedIn()) {
    redirect::to('../index.php');
}
if (input::exists()) {
    if (token::check(input::get('token'))) {
        $validate = new validate();
        $validation = $validate->check($_POST, array('password_current' => array('required' => true, 'min' => 6), 'password_new' => array('required' => true, 'min' => 6), 'password_new_again' => array('required' => true, 'min' => 2, 'matches' => 'password_new')));
        if ($validation->passed()) {
            if (hash::make(input::get('password_current'), $user->data()->Salt) !== $user->data()->Password) {
                echo 'The current password you entered is not correct. ';
            } else {
                $salt = hash::salt(32);
                $user->update(array('Password' => hash::make(input::get('password_new'), $salt), 'Salt' => $salt));
                session::flash('home', 'Your password has been changed successfully. ');
                redirect::to('index.php');
            }
        } else {
            foreach ($validation->errors() as $error) {
                echo $error, '<br>';
            }
        }
    }
}
?>

<!DOCTYPE html>
<html lang="en">
	<head>
Esempio n. 15
0
<?php

define('path', '../../../');
$page = "Register";
require path . 'inc/init.php';
$user = new User();
if ($user->hasPermission("Admin")) {
    if (Input::exists()) {
        if (Token::check(Input::get('token'))) {
            $val = new Validation();
            $val->check($_POST, array('name' => array('required' => true), 'username' => array('required' => true, 'min' => 2, 'max' => 50, 'unique' => 'users'), 'password' => array('required' => true, 'min' => 8), 'password_conf' => array('required' => true, 'matches' => 'password')));
            if ($val->passed()) {
                $salt = hash::salt(32);
                $password = hash::make(escape(Input::get('password')), $salt);
                try {
                    $user->create(array('username' => escape(Input::get('username')), 'password' => Hash::make(escape(Input::get('password')), $salt), 'salt' => $salt, 'name' => escape(Input::get('name')), 'joined' => date('Y-m-d- H:i:s'), 'group' => 1));
                } catch (Exception $e) {
                    die($e->getMessage());
                }
            }
        }
    }
} else {
    session::flash("error", "You don't have admin permission! If you think this is an error contact your administrator or owner");
    Redirect::to(path . "index.php");
}
?>
<html>
	<head>
		<?php 
include path . 'assets/php/css.php';
Esempio n. 16
0
<?php

require_once '/opt/lampp/htdocs/MySpace/src/init.php';
$user = new user();
if (!$user->isLoggedIn()) {
    redirect::to('index.php');
}
if (input::exists()) {
    if (token::check(input::get('token'))) {
        $validate = new validation();
        $validation = $validate->check($_POST, array('Password' => array('required' => true, 'min' => 8), 'Npassword' => array('required' => true, 'min' => 8), 'Rpassword' => array('required' => true, 'min' => 8, 'matches' => 'Npassword')));
        if ($validation->passed()) {
            if (hash::make(input::get('Password')) !== $user->data()->Password) {
                echo 'your old password did not match';
            } else {
                if ($user->update(array('Password' => hash::make(input::get('Npassword'))))) {
                    session::flash('home', 'Your password have been updated!!');
                    redirect::to('index.php');
                }
            }
        }
    }
}
?>
<link href="<?php 
echo 'register.css';
?>
" rel='stylesheet' type='text/css'>
<form action="" method="post">
  <div class="field">
  <label id="icon" for="Password"><i class="icon-shield"></i></label>
Esempio n. 17
0
require_once '../Core/init.php';
$user = new user(null, $_log);
if (!$user->isLoggedIn() || !$user->hasPermission('Admin')) {
    redirect::to('../index.php');
}
if (input::exists()) {
    if (token::check(input::get('token'))) {
        $validate = new validate();
        $validation = $validate->check($_POST, array('Username' => array('required' => true, 'min' => 2, 'max' => 20, 'unique' => 'Users'), 'Password' => array('required' => true, 'min' => 6), 'password_again' => array('required' => true, 'matches' => 'Password'), 'Name' => array('required' => true, 'min' => 2, 'max' => 50)));
        if ($validation->passed()) {
            //session::flash('success','You registered successfully!');
            //header('Location: index.php');
            $user = new user(null, $_log);
            $salt = hash::salt(32);
            try {
                $user->create(array('Username' => input::get('Username'), 'User_Group' => 3, 'Password' => hash::make(input::get('Password'), $salt), 'Salt' => $salt));
                session::flash('home', 'You have been registered');
                redirect::to('index.php');
            } catch (Exception $e) {
                //echo $e->getMessage(), '<br>';
                die($e->getMessage());
            }
        } else {
            foreach ($validation->errors() as $error) {
                echo $error, '<br>';
            }
        }
    }
}
?>
Esempio n. 18
0
require_once '../core/init.php';
req::once('functions/rand_pass.php');
$user = new user();
if ($user->hasPermission('logged in')) {
    redirect::to('index.php');
}
if (input::exists()) {
    $validate = new validate();
    $validate->check($_POST, array('email' => array('required' => true, 'min' => 2, 'max' => 32, 'unique' => 'users', 'email' => true), 'password' => array('required' => true, 'min' => 6, 'max' => 32), 'confirmation' => array('required' => true, 'matches' => 'password')));
    if ($validate->passed()) {
        $user = new user();
        $salt = hash::salt(32);
        $activation_code = random_code(16);
        $activation_hash = hash::make($activation_code);
        try {
            $id = $user->create(array('email' => input::get('email'), 'type' => input::get('account_type'), 'status' => 'u', 'password' => hash::make(input::get('password'), $salt), 'salt' => $salt, 'activation_code' => $activation_hash));
            mail(input::get('email'), 'Thank you for registering with MyBasket', 'To activate your account, go here: ' . config::get('site_url') . '/activate.php?code=' . $activation_code . '&user='******'email'));
            $db = db::getInstance();
            if (input::get('account_type') === 'l') {
                $db->insert('lab_user_data', array('user_id' => $id));
            } else {
                if (input::get('account_type') === 'd') {
                    $db->insert('ds_user_data', array('user_id' => $id));
                }
            }
        } catch (Exception $e) {
            die($e->getMessage());
        }
    }
}
Esempio n. 19
0
 public function run()
 {
     DB::table('users')->insert(array('first_name' => "testclient", 'last_name' => "testpass", 'email' => "*****@*****.**", 'password' => Hash::make('admin'), 'photo_url' => '', 'status' => 1));
     DB::table('users')->insert(array('first_name' => "haqi", 'last_name' => "haqi", 'email' => "*****@*****.**", 'password' => hash::make('haqi'), 'photo_url' => '', 'status' => 1));
 }