Skip to content

Commit

Permalink
Fix meal authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
hhhello0507 committed Oct 7, 2024
1 parent 9ff3aed commit d66a2b2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class WebSecurityConfig(
"/auth/sign-in",

"/school/**",

"/meals/**"
).permitAll()
.anyRequest().authenticated()
}
Expand Down
5 changes: 4 additions & 1 deletion Graduating-iOS/Data/Network/MealService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ extension MealEndpoint {
}

public var authorization: Authorization {
.none
switch self {
case .fetchMeals:
.refresh
}
}
}

Expand Down
8 changes: 1 addition & 7 deletions Graduating-iOS/Graduating/Feature/Main/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ extension MainView: View {
}
}
.onAppear {
print("MEAL")
fetchMeals()
mealViewModel.fetchMeals()
}
// .onAppear {
// handleGraduating(appState.graduating)
Expand All @@ -86,11 +85,6 @@ extension MainView {
// }
// }

func fetchMeals() {
guard let school = appState.currentUser.data?.school else { return }
mealViewModel.fetchMeals(schoolId: school.id)
}

func fetchGraduating() {
// guard let grade = appState.grade,
// let graduating = appState.graduating else {
Expand Down
5 changes: 1 addition & 4 deletions Graduating-iOS/Graduating/Feature/Main/Meal/MealView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ extension MealView: View {
}
.padding(insets)
.refreshable {
guard let school = appState.currentUser.data?.school else {
return
}
viewModel.fetchMeals(schoolId: school.id)
viewModel.fetchMeals()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public final class MealViewModel: ObservableObject {
}

extension MealViewModel {
func fetchMeals(schoolId: Int) {
func fetchMeals() {
MealService.shared.fetchMeals()
.resource(\.meals, on: self)
.ignoreError()
Expand Down

0 comments on commit d66a2b2

Please sign in to comment.