Skip to content

Commit

Permalink
login
Browse files Browse the repository at this point in the history
  • Loading branch information
totoprayogo1916 committed Nov 14, 2023
1 parent aced4be commit b64bce3
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 89 deletions.
10 changes: 5 additions & 5 deletions donjo-app/Config/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Session\Handlers\BaseHandler;
use CodeIgniter\Session\Handlers\FileHandler;
use CodeIgniter\Session\Handlers\DatabaseHandler;

class Session extends BaseConfig
{
Expand All @@ -21,7 +21,7 @@ class Session extends BaseConfig
*
* @phpstan-var class-string<BaseHandler>
*/
public string $driver = FileHandler::class;
public string $driver = DatabaseHandler::class;

/**
* --------------------------------------------------------------------------
Expand All @@ -30,7 +30,7 @@ class Session extends BaseConfig
*
* The session cookie name, must contain only [0-9a-z_-] characters
*/
public string $cookieName = 'ci_session';
public string $cookieName = 'sid_session';

/**
* --------------------------------------------------------------------------
Expand All @@ -57,7 +57,7 @@ class Session extends BaseConfig
*
* IMPORTANT: You are REQUIRED to set a valid save path!
*/
public string $savePath = WRITEPATH . 'session';
public string $savePath = 'sessions';

/**
* --------------------------------------------------------------------------
Expand All @@ -69,7 +69,7 @@ class Session extends BaseConfig
* WARNING: If you're using the database driver, don't forget to update
* your session table's PRIMARY KEY when changing this setting.
*/
public bool $matchIP = false;
public bool $matchIP = true;

/**
* --------------------------------------------------------------------------
Expand Down
10 changes: 4 additions & 6 deletions donjo-app/Controllers/Siteman/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,12 @@ public function index(): string
*/
public function submit()
{
if (! $this->request->is('post')) {
return $this->index();
}

$rules = [
'username' => ['label' => 'Username', 'rules' => 'required'],
'password' => ['label' => 'Password', 'rules' => 'required'],
];

if (! $this->validate($rules)) {
if (! $this->request->is('post') || ! $this->validate($rules)) {
return $this->index();
}

Expand Down Expand Up @@ -71,6 +67,8 @@ public function submit()
return redirect()->to('hom_desa')->with('success', 'Halo, selamat datang kembali');
}

return redirect('login.view')->withInput()->with('error', 'Silakan coba kembali.');
session()->setFlashdata('error', 'Silakan coba kembali.');

return $this->index();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateCiSessionsTable extends Migration
{
protected $DBGroup = 'default';

public function up()
{
$this->forge->addField([
'id' => ['type' => 'VARCHAR', 'constraint' => 128, 'null' => false],
'ip_address' => ['type' => 'VARCHAR', 'constraint' => 45, 'null' => false],
'timestamp timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL',
'data' => ['type' => 'BLOB', 'null' => false],
]);
$this->forge->addKey(['id', 'ip_address'], true);
$this->forge->addKey('timestamp');
$this->forge->createTable('sessions', true);
}

Check warning

Code scanning / PHPMD

Naming Rules: ShortMethodName Warning

Avoid using short method names like CreateCiSessionsTable::up(). The configured minimum method name length is 3.

public function down()
{
$this->forge->dropTable('sessions', true);
}
}
10 changes: 10 additions & 0 deletions donjo-app/Views/siteman/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@

<!-- Sign In Form -->
<?= form_open(route_to('login.submit'), ['class' => 'px-4']) ?>

<?php if (session()->has('error')) : ?>
<div class="alert alert-danger" role="alert">
<p class="mb-0">
<?= esc(session()->get('error')) ?>
</p>
</div>

<?php endif ?>

<div class="form-floating mb-4">
<input type="text" class="form-control" id="login-username" name="username" placeholder="Masukkan namapengguna" required>
<label class="form-label" for="login-username">Nama Pengguna</label>
Expand Down
4 changes: 2 additions & 2 deletions donjo-app/Views/siteman/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</head>
<body>
<!-- Page Container -->
<!--
<?php /*
Available classes for #page-container:
GENERIC
Expand Down Expand Up @@ -75,7 +75,7 @@
DARK MODE
'sidebar-dark page-header-dark dark-mode' Enable dark mode (light sidebar/header is not supported with dark mode)
-->
*/ ?>
<div id="page-container" class="main-content-boxed">

<!-- Main Container -->
Expand Down
120 changes: 60 additions & 60 deletions resources/assets/js/plugins/ckeditor/samples/old/assets/posteddata.php
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
<!DOCTYPE html>
<?php
/*
Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
?>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Sample &mdash; CKEditor</title>
<link rel="stylesheet" href="sample.css">
<meta name="description" content="Try the latest sample of CKEditor 4 and learn more about customizing your WYSIWYG editor with endless possibilities.">
</head>
<body>
<h1 class="samples">
CKEditor &mdash; Posted Data
</h1>
<table border="1" cellspacing="0" id="outputSample">
<colgroup><col width="120"></colgroup>
<thead>
<tr>
<th>Field&nbsp;Name</th>
<th>Value</th>
</tr>
</thead>
<?php

if (!empty($_POST))
{
foreach ( $_POST as $key => $value )
{
if ( ( !is_string($value) && !is_numeric($value) ) || !is_string($key) )
continue;

if ( get_magic_quotes_gpc() )
$value = htmlspecialchars( stripslashes((string)$value) );
else
$value = htmlspecialchars( (string)$value );
?>
<tr>
<th style="vertical-align: top"><?php echo htmlspecialchars( (string)$key ); ?></th>
<td><pre class="samples"><?php echo $value; ?></pre></td>
</tr>
<?php
}
}
?>
</table>
<div id="footer">
<hr>
<p>
CKEditor - The text editor for the Internet - <a class="samples" href="https://ckeditor.com/">https://ckeditor.com</a>
</p>
<p id="copy">
Copyright &copy; 2003-2021, <a class="samples" href="https://cksource.com/">CKSource</a> - Frederico Knabben. All rights reserved.
</p>
</div>
</body>
</html>
<!DOCTYPE html>
<?php
/*
Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
?>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Sample &mdash; CKEditor</title>
<link rel="stylesheet" href="sample.css">
<meta name="description" content="Try the latest sample of CKEditor 4 and learn more about customizing your WYSIWYG editor with endless possibilities.">
</head>
<body>
<h1 class="samples">
CKEditor &mdash; Posted Data
</h1>
<table border="1" cellspacing="0" id="outputSample">
<colgroup><col width="120"></colgroup>
<thead>
<tr>
<th>Field&nbsp;Name</th>
<th>Value</th>
</tr>
</thead>
<?php

if (! empty($_POST)) {
foreach ($_POST as $key => $value) {
if ((! is_string($value) && ! is_numeric($value)) || ! is_string($key)) {
continue;
}

if (get_magic_quotes_gpc()) {
$value = htmlspecialchars(stripslashes((string) $value));
} else {
$value = htmlspecialchars((string) $value);
}
?>
<tr>
<th style="vertical-align: top"><?= htmlspecialchars((string) $key); ?></th>
<td><pre class="samples"><?= $value; ?></pre></td>
</tr>
<?php
}
}
?>
</table>
<div id="footer">
<hr>
<p>
CKEditor - The text editor for the Internet - <a class="samples" href="https://ckeditor.com/">https://ckeditor.com</a>
</p>
<p id="copy">
Copyright &copy; 2003-2021, <a class="samples" href="https://cksource.com/">CKSource</a> - Frederico Knabben. All rights reserved.
</p>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<?php /* <body><pre>
-------------------------------------------------------------------------------------------
CKEditor - Posted Data
We are sorry, but your Web server does not support the PHP language used in this script.
Please note that CKEditor can be used with any other server-side language than just PHP.
To save the content created with CKEditor you need to read the POST data on the server
side and write it to a file or the database.
Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
-------------------------------------------------------------------------------------------
</pre><div style="display:none"></body> */ include "assets/posteddata.php"; ?>
<?php
/* <body><pre>
-------------------------------------------------------------------------------------------
CKEditor - Posted Data
We are sorry, but your Web server does not support the PHP language used in this script.
Please note that CKEditor can be used with any other server-side language than just PHP.
To save the content created with CKEditor you need to read the POST data on the server
side and write it to a file or the database.
Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
-------------------------------------------------------------------------------------------
</pre><div style="display:none"></body> */ include 'assets/posteddata.php';

0 comments on commit b64bce3

Please sign in to comment.