Add confirm password check
This commit is contained in:
parent
5b38559e1c
commit
6a0696b9c1
@ -13,10 +13,15 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||||||
final usernameInput = TextEditingController();
|
final usernameInput = TextEditingController();
|
||||||
final emailInput = TextEditingController();
|
final emailInput = TextEditingController();
|
||||||
final passwordInput = TextEditingController();
|
final passwordInput = TextEditingController();
|
||||||
|
final confirmPasswordInput = TextEditingController();
|
||||||
|
|
||||||
Future<void> _register() async {
|
Future<void> _register() async {
|
||||||
final result =
|
if (passwordInput.text != confirmPasswordInput.text) {
|
||||||
await api.request(context, api.ApiService.auth, 'POST', '/api/Users', {
|
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Passwords do not match')));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final result = await api.request(context, api.ApiService.auth, 'POST', '/api/Users', {
|
||||||
'username': usernameInput.text,
|
'username': usernameInput.text,
|
||||||
'email': emailInput.text,
|
'email': emailInput.text,
|
||||||
'password': passwordInput.text,
|
'password': passwordInput.text,
|
||||||
@ -25,8 +30,7 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||||||
if (result == null) return;
|
if (result == null) return;
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Successfully registered, please login')));
|
||||||
content: Text('Successfully registered, please login')));
|
|
||||||
Navigator.pushReplacementNamed(context, '/login');
|
Navigator.pushReplacementNamed(context, '/login');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -48,11 +52,21 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
const Text('Password'),
|
const Text('Password'),
|
||||||
TextField(
|
TextField(
|
||||||
controller: passwordInput,
|
controller: passwordInput,
|
||||||
obscureText: true,
|
obscureText: true,
|
||||||
enableSuggestions: false,
|
enableSuggestions: false,
|
||||||
autocorrect: false),
|
autocorrect: false
|
||||||
|
),
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
|
const Text('Confirm Password'),
|
||||||
|
TextField(
|
||||||
|
controller: confirmPasswordInput,
|
||||||
|
obscureText: true,
|
||||||
|
enableSuggestions: false,
|
||||||
|
autocorrect: false,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 30),
|
||||||
|
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: _register, child: const Text('Register')),
|
onPressed: _register, child: const Text('Register')),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
@ -71,6 +85,7 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||||||
usernameInput.dispose();
|
usernameInput.dispose();
|
||||||
emailInput.dispose();
|
emailInput.dispose();
|
||||||
passwordInput.dispose();
|
passwordInput.dispose();
|
||||||
|
confirmPasswordInput.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user