v1.1.1+32
All checks were successful
Flutter Schmutter / build (push) Successful in 6m13s

This commit is contained in:
2025-06-06 19:26:53 +02:00
parent f083fc8e8f
commit 8e9f0eb1b8
9 changed files with 141 additions and 1 deletions

View File

@ -1,8 +1,11 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:f0ckapp/models/MediaItem.dart';
final storage = FlutterSecureStorage();
Future<List<MediaItem>> fetchMedia({
int? older,
String? type,
@ -43,3 +46,21 @@ Future<MediaItem> fetchMediaDetail(int itemId) async {
);
}
}
Future<bool> login(String username, String password) async {
final response = await http.post(
Uri.parse('https://api.f0ck.me/login'),
body: {'username': username, 'password': password},
);
if (response.statusCode == 200) {
final data = jsonDecode(response.body);
final token = data['token'];
await storage.write(key: "token", value: token);
return true;
} else {
return false;
}
}