Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #104

Merged
merged 354 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
354 commits
Select commit Hold shift + click to select a range
1f75221
days meals model added
skitsbi Jul 21, 2023
89f3457
updated meal relationships and added date to identify
skitsbi Jul 21, 2023
cca2f0f
added mock data
AmickeC Jul 21, 2023
eb0132a
Added final recipe api endpoints
gryffindor-coder Jul 21, 2023
5435009
Manually corrected error causing exception
gryffindor-coder Jul 21, 2023
779d310
Update MealManagementController.java
gryffindor-coder Jul 21, 2023
c1bcc97
Merge remote-tracking branch 'origin/development' into recipe-book-page
gryffindor-coder Jul 21, 2023
50fcd85
update for users
skitsbi Jul 21, 2023
f8122d3
Filter button
SkulderLock Jul 22, 2023
7b421cd
testing something
skitsbi Jul 23, 2023
14af007
🚧 Sort functionality started
SkulderLock Jul 23, 2023
e8db11d
🚧 sort functionality started
SkulderLock Jul 23, 2023
26e3d2a
✨ Pantry and Shopping Sort
SkulderLock Jul 23, 2023
4b08929
🗃️ Update user endpoint
SkulderLock Jul 23, 2023
1ae288d
Update user fixes
SkulderLock Jul 23, 2023
95046e9
✨ Account profile linked to database
SkulderLock Jul 23, 2023
009cbb4
✨ Preferences page shows user name
SkulderLock Jul 23, 2023
8e4ac39
Connected recipe book service with page
gryffindor-coder Jul 23, 2023
c5e646c
Removed hard coded recipes
gryffindor-coder Jul 23, 2023
a770bf1
✨ Animations for food list items
SkulderLock Jul 23, 2023
9c34960
💄 Tabs switch animation added
SkulderLock Jul 23, 2023
18f4a87
changed settingsupdate quary
Krygsmancode Jul 24, 2023
1155ee7
.
AmickeC Jul 24, 2023
71060a4
added path to env
AmickeC Jul 24, 2023
ebafeb8
updated async funtion
AmickeC Jul 24, 2023
aafc8be
checking return of mock data
AmickeC Jul 24, 2023
4ba2da3
display of card
AmickeC Jul 24, 2023
9d232d1
updated
AmickeC Jul 24, 2023
84a3246
added url to mock data
AmickeC Jul 24, 2023
b3feafc
WIP : search functionality
AmickeC Jul 24, 2023
4e609e6
imports added
AmickeC Jul 24, 2023
d172f88
added search function
AmickeC Jul 24, 2023
52a7ab5
initialize searchQuery
AmickeC Jul 24, 2023
e921ab0
WIP : search functionality
AmickeC Jul 24, 2023
7f94b7b
Corrected getall and remove
gryffindor-coder Jul 24, 2023
db0b223
✅ Backend Pantry/List tests
SkulderLock Jul 24, 2023
986bc86
Corrected addRecipe method
gryffindor-coder Jul 25, 2023
0e7ee8d
url updated
AmickeC Jul 25, 2023
f180aa7
added an array of mock data
AmickeC Jul 25, 2023
c138924
updated return to return an array
AmickeC Jul 25, 2023
91db034
✅ UserController tests
SkulderLock Jul 25, 2023
feff52e
✨ Backend exception handler
SkulderLock Jul 25, 2023
a309445
✅ UserController Tests
SkulderLock Jul 25, 2023
2315b92
testing array
AmickeC Jul 25, 2023
b677ade
✅ updated tests
SkulderLock Jul 25, 2023
8044420
✅ Update Tests
SkulderLock Jul 25, 2023
2abcc7b
Update package.json
SkulderLock Jul 25, 2023
6ff562a
Update buildAndTest.yml
SkulderLock Jul 25, 2023
0f63398
WIP : meal array population
AmickeC Jul 25, 2023
1712835
Workflow fix
SkulderLock Jul 25, 2023
e4e310d
updated array
AmickeC Jul 25, 2023
30cbf14
🚧 Workflow fix
SkulderLock Jul 25, 2023
baf2699
updated display of cards
AmickeC Jul 25, 2023
5b1ee72
🚧 Workflow fix
SkulderLock Jul 25, 2023
cba7965
🚧 Hopefully fixed workflow
SkulderLock Jul 25, 2023
67d21d8
🚧 Hopefully workflow fix
SkulderLock Jul 25, 2023
5c20b0d
Merge pull request #91 from COS301-SE-2023/PantryFunctionality
SkulderLock Jul 25, 2023
ba50f22
added meal interface
skitsbi Jul 26, 2023
5a8458a
Create DaysMealsRepository.java
skitsbi Jul 26, 2023
2bc3612
Update DaysMealsModel.java
skitsbi Jul 26, 2023
d77ae45
Create MealDatabseService.java
skitsbi Jul 26, 2023
74780a5
Update MealDatabseService.java
skitsbi Jul 26, 2023
91834b1
added function that returns json node instead of string for days meals
skitsbi Jul 26, 2023
0a0565a
updated
skitsbi Jul 26, 2023
7f06667
pulled ethans progress, a bit sloppy but works
skitsbi Jul 26, 2023
0d42ab6
added save functionality
skitsbi Jul 26, 2023
bbdf91e
Update MealDatabseService.java
skitsbi Jul 26, 2023
3c88b3f
added save and retriver for mainpage meals
skitsbi Jul 26, 2023
f981652
added regen options to service
skitsbi Jul 26, 2023
658e0b0
updated the array display
AmickeC Jul 26, 2023
7796603
updated SearchedMeals function
AmickeC Jul 26, 2023
8be23b1
cleaned up code
AmickeC Jul 26, 2023
f882347
updated searchedMeals function
AmickeC Jul 26, 2023
c0749fa
WIP : search functionality
AmickeC Jul 26, 2023
438923a
WIP : search functionality updated
AmickeC Jul 26, 2023
c5eb94a
WIP: search display
AmickeC Jul 26, 2023
62fc0d2
added noResultsFound flag
AmickeC Jul 26, 2023
b49e5eb
WIP : search meals display
AmickeC Jul 26, 2023
74c1c94
WIP : displaying of cards
AmickeC Jul 26, 2023
715d19a
Modified method calls for add and remove recipe
gryffindor-coder Jul 26, 2023
23ec619
addded some progress
skitsbi Jul 26, 2023
a41ea9e
Added user to arguments in service
gryffindor-coder Jul 26, 2023
f450834
Corrected more wrong arguments in controller
gryffindor-coder Jul 26, 2023
ede34c5
WIP : display of searched cards
AmickeC Jul 26, 2023
f3dccfd
cleaned up code
AmickeC Jul 26, 2023
67ed6a5
changed to containers
AmickeC Jul 26, 2023
ca274d2
Merge branch 'development' into recipe-book-page
gryffindor-coder Jul 27, 2023
4e23e7e
fix number of cards displaying
AmickeC Jul 27, 2023
84a3b55
fixed div
AmickeC Jul 27, 2023
4998207
Fixed browse page search functionality
AmickeC Jul 27, 2023
323b9b4
Search reset button functionality
AmickeC Jul 27, 2023
d1fa73f
refresher added
AmickeC Jul 27, 2023
14bd06e
spelling updated
AmickeC Jul 27, 2023
a7d18d2
update error message
AmickeC Jul 27, 2023
804e183
changes UserRepo to create relationships
Krygsmancode Jul 28, 2023
8e1487d
Merge branch 'franko-EndToEnd' of https://github.com/COS301-SE-2023/M…
Krygsmancode Jul 28, 2023
01b5c6d
💄 Login/Signup page facelift
SkulderLock Jul 28, 2023
748ce1c
updated search functionality
AmickeC Jul 28, 2023
594d8bd
✅ added integration test
SkulderLock Jul 28, 2023
6540a1b
databse working for meals semi
skitsbi Jul 28, 2023
f3cd68a
✅ add test
SkulderLock Jul 28, 2023
fb953f6
changed logo
gryffindor-coder Jul 28, 2023
359faa7
Added packages
SkulderLock Jul 28, 2023
36bf683
databse save and retirieve working correctly
skitsbi Jul 28, 2023
8ad30f1
✅ Add integration tests
SkulderLock Jul 28, 2023
878d032
update search functionality for word order
AmickeC Jul 28, 2023
c535d4f
Removed unused import
gryffindor-coder Jul 29, 2023
26cbbbf
Corrected recipe item in details component
gryffindor-coder Jul 29, 2023
317f44c
Merge branch 'development' into origin/BrowseFunctionality
SkulderLock Jul 29, 2023
3aef4b2
bug fix
SkulderLock Jul 29, 2023
fe064a5
Added message for no recipes
gryffindor-coder Jul 29, 2023
d07b9a4
Message color adjustment
gryffindor-coder Jul 29, 2023
0575b29
Remove testing info
gryffindor-coder Jul 29, 2023
6fbde43
✅ fix test
SkulderLock Jul 29, 2023
be810be
Merge pull request #95 from COS301-SE-2023/origin/BrowseFunctionality
SkulderLock Jul 29, 2023
54cbb2d
null errors fixed
AmickeC Jul 29, 2023
1402878
cards size updated
AmickeC Jul 29, 2023
406b62e
uncommented tests
AmickeC Jul 29, 2023
823623b
🐛 changed logo filename
SkulderLock Jul 30, 2023
2282874
fixed frontend api-settings
Krygsmancode Jul 30, 2023
b52ff32
included goalsettings in html
Krygsmancode Jul 30, 2023
0b5e1d6
getAllRecipes no longer takes UserModel
gryffindor-coder Jul 30, 2023
cda8953
css looks correct now
skitsbi Jul 30, 2023
f6e22e1
updated path
AmickeC Jul 30, 2023
10b46dc
Query correction and api now passes nothing
gryffindor-coder Jul 30, 2023
0d46242
✅ Login page integration tests
SkulderLock Jul 30, 2023
36579c3
Merge pull request #96 from COS301-SE-2023/origin/BrowseFunctionality
AmickeC Jul 30, 2023
3544ba9
recipecontroller now uses token
gryffindor-coder Jul 30, 2023
623b5a0
recipeservice now uses token
gryffindor-coder Jul 30, 2023
d4d4394
✅ Signup page integration tests
SkulderLock Jul 30, 2023
c1502df
Merge branch 'development' of https://github.com/COS301-SE-2023/Meal-…
SkulderLock Jul 30, 2023
816edeb
Corrected recipe book page to receive response
gryffindor-coder Jul 30, 2023
907551a
Added missing parameter to requestheader
gryffindor-coder Jul 30, 2023
bd9849d
🐛 404 Error added
SkulderLock Jul 30, 2023
03b031e
css updated
skitsbi Jul 30, 2023
5781db7
🗑️ Remove old console logs
SkulderLock Jul 30, 2023
e6a30c4
Added recipe removal confirmation
gryffindor-coder Jul 30, 2023
2bd4d46
Recipe book page deletion code correctly expanded
gryffindor-coder Jul 30, 2023
e839bb0
Added auth token to removerecipe
gryffindor-coder Jul 30, 2023
cc696ee
recipe service now uses auth token for remove
gryffindor-coder Jul 30, 2023
86d8a6e
recipe repo updated with correct arguments
gryffindor-coder Jul 30, 2023
10ddb88
Removed debugging sysout
gryffindor-coder Jul 30, 2023
2e06ca9
Added stoppropagation to meal card
gryffindor-coder Jul 30, 2023
cb1c224
Converted delete alert to action sheet
gryffindor-coder Jul 30, 2023
919e69b
Corrected query for removing recipe
gryffindor-coder Jul 30, 2023
f95227b
Removed debugging sysout
gryffindor-coder Jul 30, 2023
6324802
Updated no recipes saved text
gryffindor-coder Jul 30, 2023
b3fd82b
BrowseRepository created
AmickeC Jul 30, 2023
8781f3c
linked till controller
skitsbi Jul 30, 2023
8fdefb0
added getPopularMeals function
AmickeC Jul 30, 2023
345008d
search function created
AmickeC Jul 30, 2023
96157ba
update MealModel
AmickeC Jul 30, 2023
dc28372
updated functions in repository
AmickeC Jul 30, 2023
91fa47a
updated getRandomMeals
AmickeC Jul 30, 2023
3775085
search function updated
AmickeC Jul 30, 2023
088af95
BrowseService created and updated
AmickeC Jul 30, 2023
3cde8a2
BrowseController added and updated
AmickeC Jul 30, 2023
705c904
fixing get settings
Krygsmancode Jul 30, 2023
f756621
html name update
Krygsmancode Jul 30, 2023
b280d81
defaulting macro and cooking
Krygsmancode Jul 30, 2023
8899ce3
implement calculateBMi
Krygsmancode Jul 30, 2023
3bbf5e6
added default macro's
Krygsmancode Jul 30, 2023
e9cf156
fixed limit error
AmickeC Jul 30, 2023
7e30d0a
fixed all null exeptions in frontend
Krygsmancode Jul 31, 2023
badaf44
add 0 checks for devisor
Krygsmancode Jul 31, 2023
92dea3e
created default cookingtime value
Krygsmancode Jul 31, 2023
e177ece
load and regenerate working + cleanup
skitsbi Jul 31, 2023
d7181f3
Workflow file update
SkulderLock Jul 31, 2023
babdc7c
Workflow updated
SkulderLock Jul 31, 2023
07a66ba
Workflow update
SkulderLock Jul 31, 2023
330369a
Create SavedMealsModel.java
skitsbi Jul 31, 2023
10dfecd
added copy function
skitsbi Jul 31, 2023
e3a41d8
formatted better
skitsbi Jul 31, 2023
3827c9f
Update SavedMealsModel.java
skitsbi Jul 31, 2023
c2723c9
✅ Backend tests updated
SkulderLock Jul 31, 2023
06395fe
updated searchedMeals controller
AmickeC Jul 31, 2023
6103e2f
updated search query
AmickeC Jul 31, 2023
f73e6e0
Create PopularMealsModel.java
skitsbi Jul 31, 2023
2fb085b
Create PopularMealsRepository.java
skitsbi Jul 31, 2023
85a6ae8
Update MealManagementController.java
skitsbi Jul 31, 2023
c0cb227
search query updated
AmickeC Jul 31, 2023
06feeb5
Workflow fix
SkulderLock Jul 31, 2023
78fb4dc
workflow fix
SkulderLock Jul 31, 2023
10596c9
Workflow fix
SkulderLock Jul 31, 2023
122e411
Workflow
SkulderLock Jul 31, 2023
8b44434
Merge branch 'development' into main-page-full-stack
skitsbi Jul 31, 2023
18e4eb6
commented out some code cus its wack
skitsbi Jul 31, 2023
7fb7126
Update daysMeals.model.ts
skitsbi Jul 31, 2023
61229ca
Merge pull request #97 from COS301-SE-2023/main-page-full-stack
theodorleroux Jul 31, 2023
a79aa12
Added tests
SkulderLock Jul 31, 2023
d4bc235
Merge branch 'development' of https://github.com/COS301-SE-2023/Meal-…
SkulderLock Jul 31, 2023
dcbc463
test
skitsbi Jul 31, 2023
da6a14c
Update daily-meals.component.html
skitsbi Jul 31, 2023
4a732d9
test
skitsbi Jul 31, 2023
6857be8
Update daily-meals.component.html
skitsbi Jul 31, 2023
2a797a4
Update daily-meals.component.html
skitsbi Jul 31, 2023
981851e
Update daily-meals.component.html
skitsbi Jul 31, 2023
52f8776
Update daysMeals.model.ts
skitsbi Jul 31, 2023
9ec4a39
Merge pull request #98 from COS301-SE-2023/main-page-full-stack
theodorleroux Jul 31, 2023
0c36482
Merge branch 'origin/BrowseFunctionality' into development
AmickeC Jul 31, 2023
3f5205c
Merge pull request #99 from COS301-SE-2023/development
AmickeC Jul 31, 2023
4a70ae9
error removed
AmickeC Jul 31, 2023
d6cbbd9
Corrected addtorecipe
gryffindor-coder Jul 31, 2023
39b3821
Recipe api post updated
gryffindor-coder Jul 31, 2023
efaf810
Recipe controller now uses token for adding
gryffindor-coder Jul 31, 2023
69a75a6
Recipe service now uses token for adding
gryffindor-coder Jul 31, 2023
9b312c8
Removed unused import
gryffindor-coder Jul 31, 2023
677890b
Recipe repo now returns a RecipeModel object
gryffindor-coder Jul 31, 2023
e6cb898
html fixed and amickes error
skitsbi Jul 31, 2023
074e4be
Merge pull request #100 from COS301-SE-2023/development
AmickeC Jul 31, 2023
52dad41
Merge pull request #101 from COS301-SE-2023/origin/BrowseFunctionality
AmickeC Jul 31, 2023
52ff8ac
syntax fixed
skitsbi Jul 31, 2023
e8e3637
Merge branch 'development' of https://github.com/COS301-SE-2023/Meal-…
skitsbi Jul 31, 2023
e78f674
Update daily-meals.component.ts
skitsbi Jul 31, 2023
7a72487
changes cooktime type for test
Krygsmancode Jul 31, 2023
8a13a3c
added all updations from backend to frontend
Krygsmancode Jul 31, 2023
7253ab8
update variables dynamically
Krygsmancode Jul 31, 2023
5419c64
corrected cooking time type
Krygsmancode Jul 31, 2023
f2c3fe8
fixed creation of user relatiohnships
Krygsmancode Jul 31, 2023
7d58a97
added all backend quaries
Krygsmancode Jul 31, 2023
a11b8f8
fixed BMI calculation logic
Krygsmancode Jul 31, 2023
39f22c0
added BMI calculation service
Krygsmancode Jul 31, 2023
366e9f2
🐛 bug fix
SkulderLock Jul 31, 2023
7c16770
search functionality fixed
AmickeC Jul 31, 2023
4355501
Merge branch 'development' of https://github.com/COS301-SE-2023/Meal-…
AmickeC Jul 31, 2023
a1a3095
Update home.page.ts
skitsbi Jul 31, 2023
c320798
Merge branch 'development' of https://github.com/COS301-SE-2023/Meal-…
skitsbi Jul 31, 2023
767fee6
removed redundant imports
Krygsmancode Jul 31, 2023
4303375
added string making fuction for openAI
Krygsmancode Jul 31, 2023
593fc98
updated test for profile page
Krygsmancode Jul 31, 2023
93d9382
updated test for api-services
Krygsmancode Jul 31, 2023
6bcde3c
Update OpenaiPromptBuilder.java
skitsbi Jul 31, 2023
e44741d
Merge branch 'development' into franko-EndToEnd
SkulderLock Jul 31, 2023
67491c1
workflow fix
SkulderLock Jul 31, 2023
cf1ec8b
save to recipe book can now trigger addrecipe
gryffindor-coder Jul 31, 2023
c46cb13
Merge pull request #102 from COS301-SE-2023/franko-EndToEnd
SkulderLock Jul 31, 2023
15b4069
🐛 bug fix
SkulderLock Jul 31, 2023
15bedfe
bug fix
SkulderLock Jul 31, 2023
c1cd5db
🚑 divide by zero
SkulderLock Jul 31, 2023
2366415
shiii idk features
skitsbi Jul 31, 2023
1c8907f
Tons of modifications to correctly call addRecipe
gryffindor-coder Jul 31, 2023
cc28e06
Merge branch 'development' into recipe-book-page
gryffindor-coder Jul 31, 2023
3643f89
MealModel final design complete
gryffindor-coder Jul 31, 2023
4af0042
Removed recipe model everywhere
gryffindor-coder Jul 31, 2023
6fb7beb
Removed MealBrowseI
gryffindor-coder Jul 31, 2023
3fcee9e
Updated queries to use full meal model
gryffindor-coder Jul 31, 2023
d27816e
Updated title attributes to names
gryffindor-coder Jul 31, 2023
d16d0e2
Updated more url to match image
gryffindor-coder Aug 1, 2023
69a2ab9
🐛 bug fix
SkulderLock Aug 1, 2023
fb4ab32
Merge pull request #103 from COS301-SE-2023/recipe-book-page
SkulderLock Aug 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions .github/workflows/buildAndTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,28 @@ jobs:
cache-dependency-path: package-lock.json
- run: npm ci
- run: npm run build --if-present
- run: npm run test:dev
- run: npm run test:unit

- name: Test with Angular
run: npm run test:dev

- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'

- name: Grant execute permission for gradlew
run: chmod +x gradlew
working-directory: backend

- name: Test with Gradle
run: ./gradlew test
working-directory: backend
env:
JWT_SECRET: ${{ secrets.JWT_SECRET }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
DB_USERNAME: ${{ secrets.DB_USERNAME }}
DB_URI: ${{ secrets.DB_URI }}

- name: Download artifacts
uses: actions/download-artifact@v2
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,5 @@ out/
### VS Code ###
.vscode/
angular.json
package-lock.json
package.json
5 changes: 0 additions & 5 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
{
"recommendations": [
"ionic.ionic"
]
}
5 changes: 4 additions & 1 deletion backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ repositories {

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-neo4j'
// implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
implementation 'io.jsonwebtoken:jjwt-impl:0.11.5'
implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'io.github.cdimascio:java-dotenv:5.2.2'
Expand Down
2 changes: 1 addition & 1 deletion backend/gradlew
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,4 @@ eval "set -- $(
tr '\n' ' '
)" '"$@"'

exec "$JAVACMD" "$@"
exec "$JAVACMD" "$@"
Empty file modified backend/gradlew.bat
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package fellowship.mealmaestro.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

import fellowship.mealmaestro.services.UserService;

@Configuration
public class ApplicationConfig {

private final UserService userService;

public ApplicationConfig(UserService userService){
this.userService = userService;
}

@Bean
public UserDetailsService userDetailsService(){
return username -> userService.findByEmail(username)
.orElseThrow(() -> new UsernameNotFoundException("User '" + username + "' not found"));
}

@Bean
public AuthenticationProvider authenticationProvider(){
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setUserDetailsService(userDetailsService());
provider.setPasswordEncoder(passwordEncoder());
return provider;
}

@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
//TODO
}

@Bean
public AuthenticationManager authenticationManager(AuthenticationConfiguration config) throws Exception {
return config.getAuthenticationManager();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package fellowship.mealmaestro.config;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {


@ExceptionHandler(RuntimeException.class)
public ResponseEntity<String> handleUserNotFoundException(RuntimeException e){
return new ResponseEntity<>(e.getMessage(), HttpStatus.NOT_FOUND);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package fellowship.mealmaestro.config;

import java.io.IOException;

import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;

import fellowship.mealmaestro.models.UserModel;
import fellowship.mealmaestro.services.auth.JwtService;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

@Component
public class JwtAuthenticationFilter extends OncePerRequestFilter {

private final JwtService jwtService;

private final UserDetailsService userDetailsService;

public JwtAuthenticationFilter(JwtService jwtService, UserDetailsService userDetailsService){
this.jwtService = jwtService;
this.userDetailsService = userDetailsService;
}

@Override
protected void doFilterInternal(
HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {

final String authHeader = request.getHeader("Authorization");
final String jwtToken;
final String userEmail;

if (authHeader == null || !authHeader.startsWith("Bearer ")) {
filterChain.doFilter(request, response);
return;
}

jwtToken = authHeader.substring(7);
userEmail = jwtService.extractUserEmail(jwtToken);

if (userEmail != null && SecurityContextHolder.getContext().getAuthentication() == null) {
UserModel userDetails = (UserModel) this.userDetailsService.loadUserByUsername(userEmail);
if (jwtService.isTokenValid(jwtToken, userDetails)){
UsernamePasswordAuthenticationToken authToken = new UsernamePasswordAuthenticationToken(
userDetails,
null,
userDetails.getAuthorities()
);

authToken.setDetails(
new WebAuthenticationDetailsSource().buildDetails(request)
);

SecurityContextHolder.getContext().setAuthentication(authToken);
}
}

filterChain.doFilter(request, response);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,32 @@
public class Neo4jConfig {
@Bean
public Driver neo4jDriver() {
Dotenv dotenv = Dotenv.load();
String uri = dotenv.get("DB_URI");
String username = dotenv.get("DB_USERNAME");
String password = dotenv.get("DB_PASSWORD");
String uri;
String username;
String password;
Dotenv dotenv;

if (System.getenv("DB_URI") != null) {
uri = System.getenv("DB_URI");
username = System.getenv("DB_USERNAME");
password = System.getenv("DB_PASSWORD");

return GraphDatabase.driver(uri, AuthTokens.basic(username, password));
}

try {
dotenv = Dotenv.load();
uri = dotenv.get("DB_URI");
username = dotenv.get("DB_USERNAME");
password = dotenv.get("DB_PASSWORD");
} catch (Exception e){
dotenv = Dotenv.configure()
.ignoreIfMissing()
.load();
uri = "No DB URI Found";
username = "No DB Username Found";
password = "No DB Password Found";
}

return GraphDatabase.driver(uri, AuthTokens.basic(username, password));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package fellowship.mealmaestro.config;

import java.util.Arrays;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;

@Configuration
@EnableWebSecurity
public class SecurityConfig {

private final JwtAuthenticationFilter jwtAuthFilter;

private final AuthenticationProvider authenticationProvider;

public SecurityConfig(JwtAuthenticationFilter jwtAuthFilter, AuthenticationProvider authenticationProvider){
this.jwtAuthFilter = jwtAuthFilter;
this.authenticationProvider = authenticationProvider;
}

@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception{
http
.cors(cors -> cors.configurationSource(corsConfigurationSource()))
.csrf(csrf -> csrf.disable())
.authorizeHttpRequests(authReq -> authReq
.requestMatchers("/register", "/authenticate")
.permitAll()
.anyRequest()
.authenticated()
)
.sessionManagement(session -> session
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
)
.addFilterBefore(jwtAuthFilter, UsernamePasswordAuthenticationFilter.class);


http.authenticationProvider(authenticationProvider);
return http.build();
}

@Bean
CorsConfigurationSource corsConfigurationSource(){
CorsConfiguration corsConfig = new CorsConfiguration();
corsConfig.setAllowedOrigins(Arrays.asList("http://localhost:4200", "http://localhost:8100"));
corsConfig.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS"));
corsConfig.setAllowedHeaders(Arrays.asList("*"));
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", corsConfig);
return source;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package fellowship.mealmaestro.controllers;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import fellowship.mealmaestro.models.MealModel;
import fellowship.mealmaestro.services.BrowseService;
//import fellowship.mealmaestro.services.PantryService;
import jakarta.validation.Valid;

@RestController
public class BrowseController {

@Autowired
private BrowseService browseService;

@GetMapping("/getPopularMeals")
public ResponseEntity<List<MealModel>> getPopularMeals(@RequestHeader("Authorization") String token){
if (token == null || token.isEmpty()) {
return ResponseEntity.badRequest().build();
}
String authToken = token.substring(7);
return ResponseEntity.ok(browseService.getPopularMeals(authToken));
}

@GetMapping("/getSearchedMeals")
public ResponseEntity<List<MealModel>> getSearcedhMeals(@RequestParam("query") String mealName, @RequestHeader("Authorization") String token){
if (token == null || token.isEmpty()) {
return ResponseEntity.badRequest().build();
}
String authToken = token.substring(7);
return ResponseEntity.ok(browseService.getSearchedMeals(mealName,authToken));
}

}
Loading
Loading