Commit 606ada52 authored by Marius Mauritz's avatar Marius Mauritz
Browse files

registrieren in db

parent d36e99f3
......@@ -45,18 +45,22 @@ class UserService {
return User.fromJson(_extractData(response) as Map<String, dynamic>);
Future login(username, password) async {
var response =
await, body: {'username': username, 'password': password}) as Response;
Map<String,dynamic> mappedResponse = json.decode(response.body) as Map<String,dynamic>;
window.localStorage.addAll({"token": mappedResponse["key"]as String});
Future check_authentification () async {
String _headers_key = "Authorization";
String _headers_value = "Token "+window.localStorage["token"];
var response = await _http.get("", headers: {_headers_key: _headers_value})as Response;
Map<String,dynamic> jsonMap = json.decode(response.body) as Map<String,dynamic>;
Future login(String username, String password) async {
// Must include http package in your pubspec.yaml
const clientID = "";
final body = "username=$username&password=$password&grant_type=password";
// Note the trailing colon (:) after the clientID.
// A client identifier secret would follow this, but there is no secret, so it is the empty string.
final clientCredentials = Base64Encoder().convert("$clientID:".codeUnits);
final response = await
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Basic $clientCredentials"
body: body);
window.localStorage.addAll({"access_token": response["access_token"]as String,"token_type":response["token_type"]as String,"expires_in": response["expires_in"] as String});
Supports Markdown
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