Save username/password instead of tokens
The tokens never worked. I don't know what i'm doing wrong but fluffychat basically just logs in and never tries to save anything. Im not sure how im meant to do this.
This commit is contained in:
parent
1cd8ba41ae
commit
f229c0371b
|
@ -44,10 +44,9 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
final homeserver = prefs.getString("homeserver");
|
final homeserver = prefs.getString("homeserver");
|
||||||
final username = prefs.getString("username");
|
final username = prefs.getString("username");
|
||||||
final accessToken = prefs.getString("accessToken");
|
final password = prefs.getString("password");
|
||||||
final refreshToken = prefs.getString("refreshToken");
|
|
||||||
|
|
||||||
if (homeserver == null || username == null || accessToken == null) return;
|
if (homeserver == null || username == null || password == null) return;
|
||||||
|
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
final provider = Provider.of<ZenithClientProvider>(context, listen: false);
|
final provider = Provider.of<ZenithClientProvider>(context, listen: false);
|
||||||
|
@ -55,7 +54,9 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await client.checkHomeserver(Uri.parse(homeserver));
|
await client.checkHomeserver(Uri.parse(homeserver));
|
||||||
await client.login(LoginType.mLoginToken, token: accessToken);
|
await client.login(LoginType.mLoginPassword,
|
||||||
|
password: password,
|
||||||
|
identifier: AuthenticationUserIdentifier(user: username));
|
||||||
provider.setClient(client);
|
provider.setClient(client);
|
||||||
setState(() {
|
setState(() {
|
||||||
showRooms = true;
|
showRooms = true;
|
||||||
|
@ -76,6 +77,19 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
if (errorMessage.isNotEmpty)
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
ErrorWidget(errorMessage),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
errorMessage = "";
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: const Text("Clear"))
|
||||||
|
],
|
||||||
|
);
|
||||||
if (showRooms)
|
if (showRooms)
|
||||||
return const RoomsPage();
|
return const RoomsPage();
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue
Block a user