|
@ -1,6 +1,7 @@ |
|
|
import 'dart:convert'; |
|
|
import 'dart:convert'; |
|
|
import 'dart:typed_data'; |
|
|
import 'dart:typed_data'; |
|
|
|
|
|
|
|
|
|
|
|
import 'package:Envelope/utils/storage/session_cookie.dart'; |
|
|
import 'package:flutter/material.dart'; |
|
|
import 'package:flutter/material.dart'; |
|
|
import 'package:http/http.dart' as http; |
|
|
import 'package:http/http.dart' as http; |
|
|
|
|
|
|
|
@ -167,13 +168,14 @@ class _SignupWidgetState extends State<SignupWidget> { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar( |
|
|
|
|
|
const SnackBar(content: Text('Processing Data')), |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
signUp() |
|
|
signUp() |
|
|
.then((dynamic) { |
|
|
.then((dynamic) { |
|
|
Navigator.of(context).popUntil((route) => route.isFirst); |
|
|
|
|
|
|
|
|
Navigator. |
|
|
|
|
|
pushNamedAndRemoveUntil( |
|
|
|
|
|
context, |
|
|
|
|
|
'/home', |
|
|
|
|
|
ModalRoute.withName('/home'), |
|
|
|
|
|
); |
|
|
}).catchError((error) { |
|
|
}).catchError((error) { |
|
|
showMessage('Failed to signup to Envelope, please try again later', context); |
|
|
showMessage('Failed to signup to Envelope, please try again later', context); |
|
|
}); |
|
|
}); |
|
@ -266,7 +268,7 @@ class _SignupWidgetState extends State<SignupWidget> { |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Future<SignupResponse> signUp() async { |
|
|
|
|
|
|
|
|
Future<dynamic> signUp() async { |
|
|
await MyProfile.setServerUrl(_serverUrlController.text); |
|
|
await MyProfile.setServerUrl(_serverUrlController.text); |
|
|
|
|
|
|
|
|
var keyPair = CryptoUtils.generateRSAKeyPair(); |
|
|
var keyPair = CryptoUtils.generateRSAKeyPair(); |
|
@ -293,12 +295,19 @@ class _SignupWidgetState extends State<SignupWidget> { |
|
|
}), |
|
|
}), |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
SignupResponse response = SignupResponse.fromJson(jsonDecode(resp.body)); |
|
|
|
|
|
|
|
|
if (resp.statusCode != 200) { |
|
|
|
|
|
throw Exception('Unable to signup to envelope'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (resp.statusCode != 201) { |
|
|
|
|
|
throw Exception(response.message); |
|
|
|
|
|
|
|
|
String? rawCookie = resp.headers['set-cookie']; |
|
|
|
|
|
if (rawCookie != null) { |
|
|
|
|
|
int index = rawCookie.indexOf(';'); |
|
|
|
|
|
setSessionCookie((index == -1) ? rawCookie : rawCookie.substring(0, index)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return response; |
|
|
|
|
|
|
|
|
return await MyProfile.login( |
|
|
|
|
|
json.decode(resp.body), |
|
|
|
|
|
_passwordController.text, |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |