-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,856 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -4,6 +4,5 @@ | |
'username' => 'eatme', | ||
'password' => 'weM2KxUZriR9', | ||
'dbname' => 'eat_me' | ||
|
||
); | ||
?> |
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 @@ | ||
TIMESTAMP=`date +%Y-%m-%d_%H-%M-%S` | ||
echo "SQL DUMP STARTED AT ${TIMESTAMP}" | ||
touch "../backups/Backup-${TIMESTAMP}.sql" | ||
/Applications/XAMPP/bin/mysqldump --user=eatme --password=weM2KxUZriR9 --host=localhost eat_me > ../backups/Backup-${TIMESTAMP}.sql | ||
echo "BACKUP FINISHED" |
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,105 @@ | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="icon" type="image/png" href="../../img/favicon.png" /> | ||
<!-- Global Styles --> | ||
<link rel="stylesheet" href="../../css/style.css" /> | ||
<link rel="stylesheet" href="../../plugins/ArtemisAlert/ArtemisAlert.css"> | ||
<title>Login - EatME</title> | ||
</head> | ||
|
||
<body> | ||
<div class="navbar"> | ||
<div class="columns group"> | ||
<div class="column is-2"> | ||
<img src="../../img/logo.png" height="56" width="224" /> | ||
</div> | ||
<div class="column is-10"></div> | ||
</div> | ||
</div> | ||
|
||
<div class="container has-text-centered"> | ||
<h1 class="title mb-1 mt-0">Login</h1> | ||
<img id="banner-image" class="mt-0 mb-0" src="../../img/login.jpg" height="150" /> | ||
<center> | ||
<div id="error-block"></div> | ||
|
||
|
||
<div id="loginInfoDiv" style="display: block"> | ||
<label class="field artemis-input-field"> | ||
<label for="phone_number_input">Phone</label> | ||
<input class="artemis-input" type="text" placeholder="Your Phone Number here" id="phone_number_input" required> | ||
<span class="label-wrap"> | ||
<span class="label-text">Phone Number</span> | ||
</span> | ||
</label> | ||
<button class="button is-primary" name="is-send" onclick="sendOTP();">Send OTP</button> | ||
</div> | ||
|
||
<form action="/online/login" id="otpDiv" style="display: none" method="POST"> | ||
<label class="field artemis-input-field"> | ||
<input class="artemis-input" type="text" placeholder="Your OTP here" name="otp" autocomplete="one-time-code" required> | ||
<span class="label-wrap"> | ||
<span class="label-text">OTP</span> | ||
</span> | ||
</label> | ||
<input id="ref_token" style="display: none" name="token"> | ||
<button class="button is-primary" name="submit">Login</button> | ||
</form> | ||
|
||
|
||
</form> | ||
</center> | ||
</div> | ||
<script src="../../plugins/ArtemisAlert/ArtemisAlert.js"></script> | ||
<script> | ||
async function sendOTP() { | ||
|
||
let phone_no = document.getElementById('phone_number_input').value; | ||
if (!/^(?:0|94|\+94|0094)?(?:(11|21|23|24|25|26|27|31|32|33|34|35|36|37|38|41|45|47|51|52|54|55|57|63|65|66|67|81|91)(0|2|3|4|5|7|9)|7(0|1|2|5|6|7|8)\d)\d{6}$/.test(phone_no)) { | ||
artemisAlert.alert('error', 'Enter a valid phone number!') | ||
return; | ||
} else { | ||
|
||
//Call the Loader | ||
document.getElementById('banner-image').src = '../../img/loading.gif'; | ||
|
||
let data = { | ||
"phone": phone_no, | ||
} | ||
|
||
try { | ||
const response = await fetch('/api/v1/verify', { | ||
method: 'POST', | ||
body: JSON.stringify(data) | ||
}); | ||
|
||
let dataJson = JSON.parse(await response.text()); | ||
console.log(dataJson); | ||
if (!dataJson.token) { | ||
document.getElementById('error-block').innerHTML = '<div class="row artemis-notification notification-danger bounceIn"><p>Error: ' + dataJson.message + '!</p></div>'; | ||
document.getElementById('banner-image').src = '../../img/login.jpg'; | ||
} else { | ||
document.getElementById('ref_token').value = dataJson.token; | ||
document.getElementById('banner-image').src = '../../img/login.jpg'; | ||
document.getElementById('loginInfoDiv').style.display = "none"; | ||
document.getElementById('otpDiv').style.display = "block"; | ||
} | ||
|
||
} catch (err) { | ||
console.log(err.text); | ||
document.getElementById('banner-image').src = '../../img/login.jpg'; | ||
document.getElementById('error-block').innerHTML = '<div class="row artemis-notification notification-danger bounceIn"><p>Error: Unknown Error Occured! Please try again later!</p></div>'; | ||
} | ||
|
||
} | ||
|
||
} | ||
</script> | ||
</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 |
---|---|---|
@@ -1 +1,2 @@ | ||
tests/acceptance/FirstCest.php:secondpageWorks | ||
tests/acceptance/LoginCest.php:tryToTest | ||
tests/unit/UnitFirstTest.php:testLogin |
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,18 @@ | ||
<?php | ||
|
||
class LoginCest | ||
{ | ||
public function _before(AcceptanceTester $I) | ||
{ | ||
|
||
} | ||
|
||
// tests | ||
public function tryToTestLogin(AcceptanceTester $I) | ||
{ | ||
$I->amOnPage('online/login'); | ||
$I->fillField('#phone_number_input', "0771655198"); | ||
$I->click('is-sent'); | ||
$I->see('Your OTP here'); | ||
} | ||
} |
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,30 @@ | ||
<?php | ||
|
||
class UnitFirstTest extends \Codeception\Test\Unit | ||
{ | ||
/** | ||
* @var \UnitTester | ||
*/ | ||
protected $tester; | ||
|
||
protected function _before() | ||
{ | ||
} | ||
|
||
protected function _after() | ||
{ | ||
} | ||
|
||
// tests | ||
public function testLogin() | ||
{ | ||
$login = new OnlineOrderLoginController(); | ||
|
||
$login->submitLogin(null, null); | ||
$this->assertFalse("False Data Rejected"); | ||
|
||
$login->submitLogin('2dcDe2E', '234196'); | ||
$this->assertTrue('True Data Accpted'); | ||
|
||
} | ||
} |
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