Commit 02d4d566 authored by Dirk Steinkopf's avatar Dirk Steinkopf

prepare to send auth header (not active yet)

parent 86c7e76a
<component name="libraryTable">
<library name="Flutter Plugins">
<CLASSES />
<CLASSES>
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-2.0.0" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/package_info-0.3.2" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.4.3" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/location-1.4.1" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
......
import 'package:flutter/material.dart';
import 'dart:convert'; // for the utf8.encode, base64Encode methods
import 'package:http/http.dart' as http;
import 'user_registration.dart';
......@@ -6,9 +7,6 @@ import 'user_registration.dart';
class Backend {
static const REQUEST_TIMEOUT_SEK = 15;
String _configBaseUrl = "http://localhost:8080/tuerauf/frontend/";
String _configAppSecret = "secretApp";
var _lastCall = new Map<String, DateTime>();
static Backend _singleton;
......@@ -102,12 +100,16 @@ class Backend {
final urlString = userRegistration.configBaseUrl + urlParam;
var bodyDataToPost = bodyData == null ? new Map<String, String>() : new Map<String, String>.from(bodyData);
bodyDataToPost['appsecret'] = userRegistration.configAppSecret;
debugPrint("calling url $urlString with bodyDataToPost '$bodyDataToPost'");
Map <String,String> headersToPost = {};
// headersToPost.addAll(getAuthHeader(userRegistration));
debugPrint("calling url $urlString with bodyDataToPost '$bodyDataToPost' and headersToPost '$headersToPost'");
activityHandler(true);
http
.post(urlString, body: bodyDataToPost)
.post(urlString, headers: headersToPost, body: bodyDataToPost)
.timeout(new Duration(seconds: REQUEST_TIMEOUT_SEK))
.then((http.Response response) {
activityHandler(false);
......@@ -135,4 +137,11 @@ class Backend {
debugPrint("_isFastRepeatedCall: callType=$callType, timePassed=$timePassed");
return timePassed.inSeconds < 2;
}
Map<String,String> getAuthHeader(UserRegistration userRegistration) {
final username = "app";
final password = userRegistration.configAppSecret;
var auth = base64Encode(utf8.encode("$username:$password"));
return { 'authorization': "Basic $auth" };
}
}
......@@ -3,7 +3,6 @@ import 'package:location/location.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'dart:async';
import 'package:synchronized/synchronized.dart';
import 'package:mutex/mutex.dart';
import 'backend.dart';
......
Markdown is supported
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