Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ASE_Y2S1_CP_G4
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Joshua Gill
ASE_Y2S1_CP_G4
Commits
3dd72dd1
Commit
3dd72dd1
authored
3 years ago
by
Joshua Gill
Browse files
Options
Downloads
Patches
Plain Diff
loginAPI logged
parent
98a29b0d
Branches
issueThirtyNine
Branches containing commit
No related tags found
2 merge requests
!114
LoggingService service class, new method to add a log to the "Logs" table when...
,
!107
Issue complete
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/com/example/clientproject/web/restControllers/loginAPI.java
+21
-1
21 additions, 1 deletion
...m/example/clientproject/web/restControllers/loginAPI.java
with
21 additions
and
1 deletion
src/main/java/com/example/clientproject/web/restControllers/loginAPI.java
+
21
−
1
View file @
3dd72dd1
package
com.example.clientproject.web.restControllers
;
import
com.example.clientproject.exceptions.ForbiddenErrorException
;
import
com.example.clientproject.service.LoggingService
;
import
com.example.clientproject.service.Utils.JWTUtils
;
import
com.example.clientproject.service.dtos.UsersDTO
;
import
com.example.clientproject.service.searches.UsersSearch
;
...
...
@@ -20,6 +21,7 @@ import java.util.Optional;
public
class
loginAPI
{
private
UsersSearch
usersSearch
;
private
JWTUtils
jwtUtils
;
LoggingService
loggingService
;
public
loginAPI
(
UsersSearch
aUsersSearch
,
JWTUtils
jwt
)
{
usersSearch
=
aUsersSearch
;
...
...
@@ -51,14 +53,32 @@ public class loginAPI {
jwtUtils
.
makeUserJWT
(
(
int
)
usersDTOOptional
.
get
().
getUserId
(),
session
);
// Otherwise, throw an exception with the correct error message
// Log the successful login
loggingService
.
logEvent
(
"Successful Login"
,
session
,
"Successful login for User with Id: "
+
usersDTOOptional
.
get
().
getUserId
()
);
}
else
{
// Log the Failed login
loggingService
.
logEvent
(
"Failed Login"
,
session
,
"Failed login for User with Id: "
+
usersDTOOptional
.
get
().
getUserId
()
);
//Changed this as it is a security risk exposing which field is incorrect
//throw new ForbiddenErrorException("Password Incorrect");
throw
new
ForbiddenErrorException
(
"Details Incorrect"
);
}
// Else - assumes that the email is incorrect
}
else
{
// Log the Failed login
loggingService
.
logEvent
(
"Failed Login"
,
session
,
"Failed login for User with Email: "
+
loginForm
.
getLoginEmail
()
);
//Changed this as it is a security risk exposing which field is incorrect
//throw new ForbiddenErrorException("Email Incorrect");
throw
new
ForbiddenErrorException
(
"Details Incorrect"
);
...
...
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
register
or
sign in
to comment