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

Implement OAuth2 for third-party apps in iOS.

parent 74572636
No related branches found
No related tags found
1 merge request!1Mobile app initial implementation.
......@@ -28,9 +28,18 @@
<key>CFBundleURLSchemes</key>
<array>
<string>app://com.vereign.app/oauth2</string>
<string>vereign://app.vereign.com</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>com.vereign.app/auhtorize</string>
<key>CFBundleURLSchemes</key>
<array>
<string>app</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
......
......@@ -54,7 +54,7 @@ class _AppState extends State<App> {
updateAppMode(Uri uri) {
log("Uri $uri");
if (uri?.path == "/oauth2") {
if (uri?.path == "/auhtorize") {
setState(() {
_appMode = "oauth";
_invokerURL = uri.queryParameters["invokerUrl"];
......@@ -66,6 +66,12 @@ class _AppState extends State<App> {
}
}
setMode(String mode) {
setState(() {
_appMode = mode;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
......@@ -80,7 +86,8 @@ class _AppState extends State<App> {
appBar: new AppBar(),
body: Home(
mode: _appMode,
invokerURL: _invokerURL
invokerURL: _invokerURL,
setMode: setMode
)
),
);
......
......@@ -6,9 +6,10 @@ import 'dart:developer';
import 'dart:convert';
class Home extends StatefulWidget {
Home({@required this.mode, @required this.invokerURL});
Home({@required this.mode, @required this.invokerURL, @required this.setMode});
final String mode;
final String invokerURL;
final void Function(String) setMode;
@override
_HomeState createState() => _HomeState();
......@@ -46,13 +47,8 @@ class _HomeState extends State<Home> {
child: Text('Go back'),
onPressed: () async {
Navigator.of(context).pop();
log('Try launch ${widget.invokerURL}');
if (await canLaunch(widget.invokerURL)) {
await launch("${widget.invokerURL}?token=$token");
} else {
log('Could not launch ${widget.invokerURL}');
}
widget.setMode("");
await launch("${widget.invokerURL}?token=$token");
},
),
],
......
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