Exemple #1
0
 public function APILogin()
 {
     $email = PostInput('email');
     $password = PostInput('password');
     $data = ['email' => $email, 'password' => $password];
     $validator = $this->validate($data, ['email' => 'required|email', 'password' => 'required|min:6|max:20']);
     if (!$validator->success) {
         setcookie('validate_errors', json_encode($validator->errors), time() + 86400, '/');
         redirectBack();
     } else {
         $user = new User();
         $user->email = $email;
         $salt = mt_rand(0, 10000000000);
         $user->persist_code = $salt;
         $user->password = hash("sha256", $password . $salt);
         if ($user->save()) {
             redirect();
         }
     }
 }
Exemple #2
0
        $data['usr_id'] = $id;
        isset($_POST['username']) ? $data['usr_name'] = $_POST['username'] : '';
        isset($_POST['password']) ? $data['usr_password'] = $_POST['password'] : '';
        isset($_POST['email']) ? $data['usr_email'] = $_POST['email'] : '';
        isset($_POST['roles']) ? $data['rol_id'] = $_POST['roles'] : '';
        $user = new User();
        $stmt = $user->postUpdateUser($data);
        if ($stmt) {
            //header('location:/user/default.html');
            header('location:index.php?module=user&action=default');
        } else {
            redirectBack();
        }
    }
}
if ($id) {
    $user = new User();
    $result = $user->findById($id);
    if ($result) {
        $smarty->assign('data', $result);
    } else {
        redirectBack();
    }
}
$role = new Role();
$rol_list = $role->listRoles();
foreach ($rol_list as $ro) {
    $roles[$ro['rol_id']] = $ro['rol_desc'];
}
$smarty->assign('roles', $roles);
$smarty->display(VIEW . 'edit.tpl');