-
Notifications
You must be signed in to change notification settings - Fork 195
Fix Login/Signup Service Redirection Issue #465 #478
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
base: master
Are you sure you want to change the base?
Changes from all commits
aa1a83b
a730f23
6f30679
54c0cd0
c906f78
1ed56f4
0575395
03e7d75
c1e3a2d
0f8b0d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React, { useState } from 'react'; | ||
|
||
const RoomInput = () => { | ||
const [title, setTitle] = useState(''); | ||
const [description, setDescription] = useState(''); | ||
const TITLE_LIMIT = 50; // Set desired limit | ||
const DESCRIPTION_LIMIT = 200; // Set desired limit | ||
|
||
const handleTitleChange = (e) => { | ||
if (e.target.value.length <= TITLE_LIMIT) { | ||
setTitle(e.target.value); | ||
} | ||
}; | ||
|
||
const handleDescriptionChange = (e) => { | ||
if (e.target.value.length <= DESCRIPTION_LIMIT) { | ||
setDescription(e.target.value); | ||
} | ||
}; | ||
|
||
return ( | ||
<div> | ||
<input | ||
type="text" | ||
value={title} | ||
onChange={handleTitleChange} | ||
placeholder="Room Title" | ||
/> | ||
<span>{`${title.length}/${TITLE_LIMIT}`}</span> | ||
<textarea | ||
value={description} | ||
onChange={handleDescriptionChange} | ||
placeholder="Room Description" | ||
/> | ||
<span>{`${description.length}/${DESCRIPTION_LIMIT}`}</span> | ||
</div> | ||
); | ||
}; | ||
|
||
export default RoomInput; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import 'package:get/get.dart'; | ||
|
||
class ConnectionController extends GetxController { | ||
var isConnected = false.obs; | ||
var connectionAttempts = 0.obs; | ||
|
||
void resetAttempts() { | ||
connectionAttempts.value = 0; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:flutter/material.dart'; | ||
import '../services/auth_service.dart'; | ||
|
||
class SettingsScreen extends StatelessWidget { | ||
final AuthService authService = AuthService(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar(title: Text("Settings")), | ||
body: Center( | ||
child: ElevatedButton( | ||
onPressed: () async { | ||
await authService.logout(); | ||
}, | ||
child: Text("Logout"), | ||
), | ||
), | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:get/get.dart'; | ||
|
||
class AuthService { | ||
// Other methods... | ||
|
||
Future<void> logout() async { | ||
// Clear user session data | ||
await clearSession(); | ||
// Redirect to login screen | ||
Get.offAllNamed('/login'); // Adjust the route as necessary | ||
} | ||
|
||
Future<void> clearSession() async { | ||
// Implement session clearing logic here | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'dart:async'; | ||
import 'package:get/get.dart'; | ||
import 'connection_controller.dart'; | ||
|
||
class LiveKitService { | ||
final ConnectionController connectionController = Get.find<ConnectionController>(); | ||
final int maxAttempts = 3; | ||
final Duration attemptDelay = Duration(seconds: 2); | ||
|
||
Future<void> handleConnectionLoss() async { | ||
connectionController.resetAttempts(); | ||
while (connectionController.connectionAttempts.value < maxAttempts) { | ||
await Future.delayed(attemptDelay); | ||
connectionController.connectionAttempts.value++; | ||
// Attempt to reconnect | ||
bool success = await reconnect(); | ||
if (success) { | ||
connectionController.isConnected.value = true; | ||
return; // Exit if successful | ||
} | ||
} | ||
// Notify user about failed reconnection | ||
notifyUser("Failed to reconnect after $maxAttempts attempts."); | ||
} | ||
|
||
Future<bool> reconnect() async { | ||
// Implement your reconnection logic here | ||
// Return true if successful, false otherwise | ||
} | ||
|
||
void notifyUser(String message) { | ||
// Implement user notification logic here | ||
} | ||
Comment on lines
+31
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,11 +26,7 @@ class _LoginScreenState extends State<LoginScreen> { | |
Widget build(BuildContext context) { | ||
return PopScope( | ||
onPopInvokedWithResult: (didPop, result) { | ||
controller.emailController.clear(); | ||
controller.passwordController.clear(); | ||
controller.confirmPasswordController.clear(); | ||
controller.isPasswordFieldVisible.value = false; | ||
controller.isConfirmPasswordFieldVisible.value = false; | ||
_clearFormFields(); | ||
}, | ||
child: Scaffold( | ||
resizeToAvoidBottomInset: false, | ||
|
@@ -118,7 +114,11 @@ class _LoginScreenState extends State<LoginScreen> { | |
if (!controller.isLoading.value) { | ||
if (controller.loginFormKey.currentState! | ||
.validate()) { | ||
await controller.login(); | ||
final success = await controller.login(); | ||
if (success) { | ||
// Navigate to home or dashboard after successful login | ||
Get.offAllNamed(AppRoutes.home); | ||
} | ||
Comment on lines
+117
to
+121
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be beneficial to handle the case where
|
||
} | ||
} | ||
}, | ||
|
@@ -142,7 +142,8 @@ class _LoginScreenState extends State<LoginScreen> { | |
), | ||
GestureDetector( | ||
onTap: () { | ||
Get.offNamed(AppRoutes.forgotPassword); | ||
_clearFormFields(); | ||
Get.toNamed(AppRoutes.forgotPassword); | ||
}, | ||
child: Text( | ||
"Forgot Password?", | ||
|
@@ -159,12 +160,8 @@ class _LoginScreenState extends State<LoginScreen> { | |
const Text("New to Resonate? "), | ||
GestureDetector( | ||
onTap: () { | ||
controller.emailController.clear(); | ||
controller.passwordController.clear(); | ||
controller.confirmPasswordController.clear(); | ||
controller.isPasswordFieldVisible.value = false; | ||
controller.isConfirmPasswordFieldVisible.value = false; | ||
Get.offNamed(AppRoutes.signup); | ||
_clearFormFields(); | ||
Get.toNamed(AppRoutes.signup); | ||
}, | ||
child: Text( | ||
"Register", | ||
|
@@ -183,4 +180,12 @@ class _LoginScreenState extends State<LoginScreen> { | |
), | ||
); | ||
} | ||
|
||
void _clearFormFields() { | ||
controller.emailController.clear(); | ||
controller.passwordController.clear(); | ||
controller.confirmPasswordController.clear(); | ||
controller.isPasswordFieldVisible.value = false; | ||
controller.isConfirmPasswordFieldVisible.value = false; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:get/get.dart'; | ||
import '../controllers/connection_controller.dart'; | ||
|
||
class ConnectionStatusWidget extends StatelessWidget { | ||
final ConnectionController connectionController = Get.find<ConnectionController>(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Obx(() { | ||
if (connectionController.isConnected.value) { | ||
return Text("Connected"); | ||
} else { | ||
return Text("Attempting to reconnect... (${connectionController.connectionAttempts.value})"); | ||
} | ||
}); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
reconnect()
method is currently empty. It should contain the actual reconnection logic. Without this, the reconnection attempts will always fail.