-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from wanderlust-group-project-1/nirmal
docker environment
- Loading branch information
Showing
13 changed files
with
197 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
echo "This is the index page"; | ||
|
||
|
||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
class Home { | ||
use Controller; | ||
|
||
public function index(string $a = '', string $b = '', string $c = ''):void { | ||
$this->view('admin/home'); | ||
} | ||
} | ||
|
||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
use Firebase\JWT\JWT; | ||
|
||
|
||
class Login { | ||
use Controller; | ||
|
||
private function setcookie(array $userData): void{ | ||
print_r($userData); | ||
$token = JWT::encode($userData, SECRET_KEY, 'HS256'); | ||
|
||
setcookie('jwt_auth_token', $token, time() + 36000, '/', '', false, true); | ||
|
||
// echo json_encode(['token' => $token]); | ||
|
||
} | ||
private function post(): mixed { | ||
$user = new UserModel; | ||
$email = $_POST['email']; | ||
$password = $_POST['password']; | ||
|
||
if ($user->authenticate($email, $password)) { | ||
$userData = $user->authenticate($email, $password); | ||
// $_SESSION['USER'] = $userData; | ||
// filter user data get id and email array | ||
$userData = array_filter((array) $userData, function ($key) { | ||
return in_array($key, ['id', 'email']); | ||
}, ARRAY_FILTER_USE_KEY); | ||
$this->setcookie($userData); | ||
redirect('home'); | ||
} else { | ||
$data['errors'] = ['email' => 'Wrong Email or Password']; | ||
return $data; | ||
|
||
} | ||
|
||
} | ||
|
||
|
||
public function index(): void { | ||
|
||
|
||
if ($_SERVER['REQUEST_METHOD'] == 'POST') { | ||
$data = $this->post(); | ||
}else { | ||
$data = []; | ||
} | ||
|
||
|
||
$this->view('admin/login', $data); | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<nav class="sidebar"> | ||
<div class="logo"> | ||
<img src="<?= ROOT_DIR ?>/assets/images/logo.png" alt="logo"> | ||
</div> | ||
<ul class="nav-menu"> | ||
<li class="nav-menu-item"><a href="#">Home</a></li> | ||
<li class="nav-menu-item"><a href="#">About</a></li> | ||
<li class="nav-menu-item"><a href="#">Guides</a></li> | ||
<li class="nav-menu-item"><a href="#">Rental Services</a></li> | ||
<li class="nav-menu-item"><a href="#">Blogs</a></li> | ||
<li class="nav-menu-item"><a href="#">Tips & Knowhows</a></li> | ||
<li class="nav-menu-item"><a href="#">Complaints</a></li> | ||
</ul> | ||
<div class="login-button"><a href="#">Login</a></div> | ||
</nav> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
<html> | ||
<head> | ||
<title>Wanderlust</title> | ||
<link rel="stylesheet" type="text/css" href="<?=ROOT_DIR ?>/assets/css/style.css"> | ||
</head> | ||
<body> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
require_once('../app/views/admin/layout/header.php'); | ||
// require_once('../app/views/components/navbar.php'); | ||
|
||
|
||
?> | ||
<div class="login-container"> | ||
<!-- <h1>Login</h1> --> | ||
<div class="login-form"> | ||
<form id="loginForm" action="<?=ROOT_DIR?>/login" method="post"> | ||
<h2>Login</h2> | ||
|
||
|
||
<?php if(isset($errors)): ?> | ||
<div> <?= implode('<br>', $errors)?> </div> | ||
<?php endif; ?> | ||
|
||
<label for="email">Email</label> | ||
<input type="text" name="email" id="email" placeholder="Email" required> | ||
<label for="password" >Password</label> | ||
<input type="password" name="password" id="password" placeholder="Password" required> | ||
<div class="message-text"> | ||
<a href="#">Forgot your password?</a> | ||
</div> | ||
<input type="submit" name="submit" value="login"> | ||
|
||
<p> | ||
Don't have an account? <a href="<?=ROOT_DIR?>/signup">Signup</a> | ||
<p> | ||
|
||
|
||
</form> | ||
<!-- <a href="<?=ROOT_DIR?>/signup" title="Signup">Signup</a> | ||
<a href="<?=ROOT_DIR?>" title="Home">Home</a> --> | ||
</div> | ||
</div> | ||
|
||
|
||
<script src="<?=ROOT_DIR?>/assets/js/login.js"></script> | ||
|
||
<?php | ||
require_once('../app/views/admin/layout/footer.php'); | ||
|
||
|
||
?> | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
DB_USER=root | ||
DB_PASSWORD=root | ||
DB_HOST=localhost | ||
DB_NAME=wanderlust | ||
DUMP_FILE_NAME=wanderlust |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
DB_USER=root | ||
DB_PASSWORD=root | ||
DB_HOST=wl-mysql | ||
DB_NAME=wanderlust | ||
DUMP_FILE_NAME=wanderlust |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters