Skip to content
Snippets Groups Projects
Commit cc6814df authored by Markin Igor's avatar Markin Igor
Browse files

Pass host from third-party app.

parent 4882815c
No related branches found
No related tags found
1 merge request!1Mobile app initial implementation.
......@@ -20,6 +20,7 @@ class _AppState extends State<App> {
// Url of the app which invoked OAuth
String _invokerURL;
String _host;
@override
initState() {
......@@ -53,11 +54,11 @@ class _AppState extends State<App> {
}
updateAppMode(Uri uri) {
log("Uri $uri");
if (uri?.path == "/authorize") {
setState(() {
_appMode = "oauth";
_invokerURL = uri.queryParameters["invokerUrl"];
_host = uri.queryParameters["host"];
});
} else {
setState(() {
......@@ -87,7 +88,8 @@ class _AppState extends State<App> {
body: Home(
mode: _appMode,
invokerURL: _invokerURL,
setMode: setMode
setMode: setMode,
host: _host
)
),
);
......
......@@ -8,9 +8,10 @@ import 'dart:convert';
import '../../config.dart';
class Home extends StatefulWidget {
Home({@required this.mode, @required this.invokerURL, @required this.setMode});
Home({@required this.mode, @required this.invokerURL, @required this.setMode, @required this.host});
final String mode;
final String invokerURL;
final String host;
final void Function(String) setMode;
@override
......@@ -18,12 +19,12 @@ class Home extends StatefulWidget {
}
const hosts = [
'https://demo1.vereign.com',
'https://demo2.vereign.com',
'https://rosengeorgiev.dev.vereign.com',
'https://borisdimitrov.dev.vereign.com',
'https://integration.vereign.com',
'https://staging.vereign.com',
'https://demo1.vereign.com',
'https://demo2.vereign.com',
'https://damyanmitev.dev.vereign.com',
'https://gospodinbodurov.dev.vereign.com',
'https://alexeylunin.dev.vereign.com',
......@@ -83,14 +84,21 @@ class _HomeState extends State<Home> {
// this method IS called when parent widget passes new "props"
// unlike React, this method IS called _before_ the build
// unlike React, this method ISN'T called after setState()
if (widget.host != oldWidget.host && widget.host != null) {
setState(() {
_host = widget.host;
});
}
if (widget.mode != oldWidget.mode) {
showMode(widget.mode);
}
super.didUpdateWidget(oldWidget);
}
showMode(mode) {
log(mode);
if (mode == "app") {
openVereign();
} else if (mode == "oauth") {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment