passwor reset, bild hochladen
parent
9d5ddbb0ab
commit
51ebeea554
Binary file not shown.
After Width: | Height: | Size: 9.5 KiB |
|
@ -1,48 +1,114 @@
|
||||||
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
|
|
||||||
class ForgetPasswort extends StatefulWidget {
|
import '../login_page/login_screen.dart';
|
||||||
@override
|
import '../services/global_variables.dart';
|
||||||
State<ForgetPasswort> createState() => _ForgetPasswortState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ForgetPasswortState extends State<ForgetPasswort> {
|
class ForgetPasswort extends StatelessWidget {
|
||||||
final TextEditingController _emailController = TextEditingController();
|
final TextEditingController _emailController = TextEditingController();
|
||||||
|
final FirebaseAuth _auth = FirebaseAuth.instance;
|
||||||
|
|
||||||
|
ForgetPasswort({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
void _forgetPassSubmitForm(BuildContext context) async {
|
||||||
|
try {
|
||||||
|
await _auth.sendPasswordResetEmail(
|
||||||
|
email: _emailController.text,
|
||||||
|
);
|
||||||
|
Navigator.pushReplacement(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (_) => Login()),
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
Fluttertoast.showToast(msg: error.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
Size size = MediaQuery.of(context).size;
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
body: SingleChildScrollView(
|
||||||
title: const Text('Passwort vergessen'),
|
child: Container(
|
||||||
),
|
height: size.height - 18, // Adjust for bottom overflow
|
||||||
body: Padding(
|
child: Stack(
|
||||||
padding: const EdgeInsets.all(16.0),
|
children: [
|
||||||
child: Column(
|
Image.network(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
signupUrlImage,
|
||||||
children: [
|
fit: BoxFit.cover,
|
||||||
const Text(
|
width: double.infinity,
|
||||||
'Geben Sie Ihre E-Mail-Adresse ein, um das Passwort zurückzusetzen:',
|
height: double.infinity,
|
||||||
style: TextStyle(fontSize: 16),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
TextFormField(
|
|
||||||
controller: _emailController,
|
|
||||||
keyboardType: TextInputType.emailAddress,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: 'E-Mail-Adresse',
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
),
|
),
|
||||||
),
|
Center(
|
||||||
const SizedBox(height: 16),
|
child: Padding(
|
||||||
ElevatedButton(
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 80),
|
||||||
onPressed: () {
|
child: Column(
|
||||||
final email = _emailController.text;
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
// Fügen Sie hier den Code für das Zurücksetzen des Passworts hinzu
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
},
|
children: [
|
||||||
child: const Text('Passwort zurücksetzen'),
|
Padding(
|
||||||
),
|
padding: const EdgeInsets.only(left: 80, right: 80),
|
||||||
],
|
child: Transform.scale(
|
||||||
|
scale: 0.8, // 20% smaller
|
||||||
|
child: Image.asset('assets/images/password.png'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
const Text(
|
||||||
|
'Geben Sie Ihre E-Mail-Adresse ein, um das Passwort zurückzusetzen:',
|
||||||
|
style: TextStyle(fontSize: 16),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
TextFormField(
|
||||||
|
controller: _emailController,
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'E-Mail',
|
||||||
|
filled: true,
|
||||||
|
fillColor: Colors.blueGrey.withOpacity(0.2),
|
||||||
|
errorBorder: const UnderlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.red),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
validator: (value) {
|
||||||
|
if (value!.isEmpty) {
|
||||||
|
return 'Bitte geben Sie Ihre E-Mail-Adresse ein';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
_forgetPassSubmitForm(context);
|
||||||
|
},
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
primary: Colors.cyan,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(13),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 14),
|
||||||
|
child: Text(
|
||||||
|
'Reset Passwort',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,11 @@
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:cpd_ss23/ForgetPasswort/forget_pass_screen.dart';
|
import 'package:cpd_ss23/forget_passwort/forget_pass_screen.dart';
|
||||||
import 'package:cpd_ss23/services/global_methods.dart';
|
import 'package:cpd_ss23/services/global_methods.dart';
|
||||||
import 'package:cpd_ss23/services/global_variables.dart';
|
import 'package:cpd_ss23/services/global_variables.dart';
|
||||||
import 'package:firebase_auth/firebase_auth.dart';
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../forget_passwort/forget_pass_screen.dart';
|
||||||
import '../signup_page/signup_screen.dart';
|
import '../signup_page/signup_screen.dart';
|
||||||
|
|
||||||
class Login extends StatefulWidget {
|
class Login extends StatefulWidget {
|
||||||
|
|
|
@ -109,7 +109,7 @@ class _SignUpState extends State<SignUp> {
|
||||||
'createdAt': Timestamp.now(),
|
'createdAt': Timestamp.now(),
|
||||||
|
|
||||||
});
|
});
|
||||||
Navigator.canPop(context) ? Navigator.of(context) : null;
|
Navigator.canPop(context) ? Navigator.pop(context) : null;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle any errors that occur during sign-up
|
// Handle any errors that occur during sign-up
|
||||||
setState(){
|
setState(){
|
||||||
|
@ -117,7 +117,6 @@ class _SignUpState extends State<SignUp> {
|
||||||
}
|
}
|
||||||
GlobalMethod.showErrorDialog(error: e.toString(), ctx: context);
|
GlobalMethod.showErrorDialog(error: e.toString(), ctx: context);
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue