From 9cb8091b70f5d7f3aba66ccc8944b89d46122ce9 Mon Sep 17 00:00:00 2001 From: connor-addison-h <70348761+connor-addison-h@users.noreply.github.com> Date: Thu, 23 May 2024 10:20:25 -0700 Subject: [PATCH] Create SettingsController.java --- .../ui/controllers/SettingsController.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 app/femr/ui/controllers/SettingsController.java diff --git a/app/femr/ui/controllers/SettingsController.java b/app/femr/ui/controllers/SettingsController.java new file mode 100644 index 000000000..5dd28cedd --- /dev/null +++ b/app/femr/ui/controllers/SettingsController.java @@ -0,0 +1,32 @@ +package femr.ui.controllers; + +import com.google.inject.Inject; +import controllers.AssetsFinder; +import femr.business.services.core.ISessionService; +import femr.common.dtos.CurrentUser; +import femr.ui.views.html.home.index; +import femr.ui.views.html.sessions.create; +import play.mvc.Controller; +import play.mvc.Result; + +public class SettingsController extends Controller { + private final AssetsFinder assetsFinder; + private ISessionService sessionService; + + @Inject + public SettingsController(AssetsFinder assetsFinder, ISessionService sessionService) { + + this.assetsFinder = assetsFinder; + this.sessionService = sessionService; + } + + public Result index() { + CurrentUser currentUser = sessionService.retrieveCurrentUserSession(); + + if (currentUser != null) { + return ok(index.render(currentUser, assetsFinder)); + } + + return ok(create.render(null, 0, assetsFinder)); + } +}