feat: init development branch with permanent access token and menu handlers

This commit is contained in:
RIT Services
2026-08-29 07:22:13 +00:00
parent 7d6d019b85
commit a0fbe836c4
11 changed files with 1014 additions and 36 deletions

View File

@@ -15,15 +15,19 @@ public class LoginHandler {
private final ImsApiService imsApiService;
private final StudentMenuHandler studentMenuHandler;
private final FacultyMenuHandler facultyMenuHandler;
@Autowired
public LoginHandler(WhatsAppMessageService messageService,
SessionService sessionService,
ImsApiService imsApiService,
StudentMenuHandler studentMenuHandler) {
StudentMenuHandler studentMenuHandler,
FacultyMenuHandler facultyMenuHandler) {
this.messageService = messageService;
this.sessionService = sessionService;
this.imsApiService = imsApiService;
this.studentMenuHandler = studentMenuHandler;
this.facultyMenuHandler = facultyMenuHandler;
}
public void startLoginFlow(String phoneNumber) {
@@ -42,18 +46,22 @@ public class LoginHandler {
messageService.sendMessage(phoneNumber, "Authenticating with IMS... ⏳");
String imsSessionToken = imsApiService.authenticate(imsId, passcode);
ImsApiService.AuthResult result = imsApiService.authenticate(imsId, passcode);
if (imsSessionToken != null) {
if (result != null && result.token != null) {
// Authentication successful
sessionService.authenticateUser(phoneNumber, imsId, passcode, imsSessionToken);
sessionService.authenticateUser(phoneNumber, imsId, passcode, result);
sessionService.clearTempLoginId(phoneNumber);
sessionService.resetState(phoneNumber); // Reset the flow state
messageService.sendMessage(phoneNumber, "✅ Login Successful!");
// Show the main menu
studentMenuHandler.sendMainMenu(phoneNumber);
if (result.isFaculty) {
facultyMenuHandler.sendMainMenu(phoneNumber);
} else {
studentMenuHandler.sendMainMenu(phoneNumber);
}
} else {
// Authentication failed
sessionService.clearTempLoginId(phoneNumber);