Commit 07297576 authored by Ilham Maulana's avatar Ilham Maulana 💻

fix: handle error message on sign up form

parent 1e317d45
......@@ -146,12 +146,15 @@ class AuthProvider with ChangeNotifier {
String token = Token.fromJson(data)!.key;
storeAccessToken(token);
isAuthenticated = true;
message = null;
if (context.mounted) {
context.go("/");
}
debugPrint("Signup successful $token");
} else {
final data = jsonDecode(response.body);
message = data["message"];
debugPrint(
"Error: sign up failed, ${response.statusCode}: ${response.body}");
}
......
......@@ -40,6 +40,8 @@ class _SignUpForm extends State<SignUpForm> {
const String formText = "Sign In to get started";
return Consumer<AuthProvider>(builder: (context, authProvider, child) {
final message = authProvider.message;
return Column(
children: [
Padding(
......@@ -120,8 +122,10 @@ class _SignUpForm extends State<SignUpForm> {
},
keyboardType: TextInputType.visiblePassword,
),
const SizedBox(
height: 20.0,
Padding(
padding: const EdgeInsets.symmetric(vertical: 20.0),
child: Text(message ?? "",
style: const TextStyle(color: Colors.red)),
),
Column(
children: [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment