Skip to main content
Homepage
Explore
Search or go to…
/
Sign in
Explore
Primary navigation
Project
P
PHP app
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Collapse sidebar
Snippets
Groups
Projects
Show more breadcrumbs
IF3110-2023-02-18
PHP app
Commits
a51d4a5d
Commit
a51d4a5d
authored
Oct 4, 2023
by
Bitha17
Browse files
Options
Downloads
Patches
Plain Diff
add authentication
parent
422fe089
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/Controllers/EventController.php
+7
-1
7 additions, 1 deletion
app/Controllers/EventController.php
app/Controllers/TicketController.php
+7
-0
7 additions, 0 deletions
app/Controllers/TicketController.php
app/Controllers/UserController.php
+3
-1
3 additions, 1 deletion
app/Controllers/UserController.php
with
17 additions
and
2 deletions
app/Controllers/EventController.php
+
7
−
1
View file @
a51d4a5d
<?php
<?php
// app/Controllers/EventController.php
// app/Controllers/EventController.php
ob_start
();
require_once
(
__DIR__
.
'/../Models/Event.php'
);
require_once
(
__DIR__
.
'/../Models/Event.php'
);
if
(
!
isset
(
$_SESSION
[
"user_id"
]))
{
// User is not authenticated; redirect to login page
header
(
"Location: /app/Views/login/login.php"
);
ob_end_flush
();
}
class
EventController
{
class
EventController
{
private
$eventModel
;
private
$eventModel
;
...
...
...
...
This diff is collapsed.
Click to expand it.
app/Controllers/TicketController.php
+
7
−
0
View file @
a51d4a5d
<?php
<?php
// app/controllers/ticketController.php
// app/controllers/ticketController.php
ob_start
();
// require_once 'Ticket.php';
// require_once 'Ticket.php';
require_once
(
__DIR__
.
'/../Models/Ticket.php'
);
require_once
(
__DIR__
.
'/../Models/Ticket.php'
);
if
(
!
isset
(
$_SESSION
[
"user_id"
]))
{
// User is not authenticated; redirect to login page
header
(
"Location: /app/Views/login/login.php"
);
ob_end_flush
();
}
class
TicketController
{
class
TicketController
{
private
$ticketModel
;
private
$ticketModel
;
...
...
...
...
This diff is collapsed.
Click to expand it.
app/Controllers/UserController.php
+
3
−
1
View file @
a51d4a5d
...
@@ -38,6 +38,7 @@ class UserController {
...
@@ -38,6 +38,7 @@ class UserController {
public
function
loginByEmail
(
$email
,
$password
)
{
public
function
loginByEmail
(
$email
,
$password
)
{
$user
=
$this
->
userModel
->
getUserByEmail
(
$email
);
$user
=
$this
->
userModel
->
getUserByEmail
(
$email
);
if
(
$user
!==
false
&&
password_verify
(
$password
,
$user
[
'user_hashedPass'
]))
{
if
(
$user
!==
false
&&
password_verify
(
$password
,
$user
[
'user_hashedPass'
]))
{
session_start
();
$_SESSION
[
"user_id"
]
=
$user
[
'user_ID'
];
$_SESSION
[
"user_id"
]
=
$user
[
'user_ID'
];
return
"success"
;
return
"success"
;
}
else
{
}
else
{
...
@@ -48,6 +49,7 @@ class UserController {
...
@@ -48,6 +49,7 @@ class UserController {
public
function
loginByUsername
(
$username
,
$password
)
{
public
function
loginByUsername
(
$username
,
$password
)
{
$user
=
$this
->
userModel
->
getUserByUsername
(
$username
);
$user
=
$this
->
userModel
->
getUserByUsername
(
$username
);
if
(
$user
!==
false
&&
password_verify
(
$password
,
$user
[
'user_hashedPass'
]))
{
if
(
$user
!==
false
&&
password_verify
(
$password
,
$user
[
'user_hashedPass'
]))
{
session_start
();
$_SESSION
[
"user_id"
]
=
$user
[
'user_ID'
];
$_SESSION
[
"user_id"
]
=
$user
[
'user_ID'
];
return
"success"
;
return
"success"
;
}
else
{
}
else
{
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment