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 @@ ...@@ -28,9 +28,18 @@
<key>CFBundleURLSchemes</key> <key>CFBundleURLSchemes</key>
<array> <array>
<string>app://com.vereign.app/oauth2</string> <string>app://com.vereign.app/oauth2</string>
<string>vereign://app.vereign.com</string>
</array> </array>
</dict> </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> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string> <string>$(FLUTTER_BUILD_NUMBER)</string>
......
...@@ -54,7 +54,7 @@ class _AppState extends State<App> { ...@@ -54,7 +54,7 @@ class _AppState extends State<App> {
updateAppMode(Uri uri) { updateAppMode(Uri uri) {
log("Uri $uri"); log("Uri $uri");
if (uri?.path == "/oauth2") { if (uri?.path == "/auhtorize") {
setState(() { setState(() {
_appMode = "oauth"; _appMode = "oauth";
_invokerURL = uri.queryParameters["invokerUrl"]; _invokerURL = uri.queryParameters["invokerUrl"];
...@@ -66,6 +66,12 @@ class _AppState extends State<App> { ...@@ -66,6 +66,12 @@ class _AppState extends State<App> {
} }
} }
setMode(String mode) {
setState(() {
_appMode = mode;
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
...@@ -80,7 +86,8 @@ class _AppState extends State<App> { ...@@ -80,7 +86,8 @@ class _AppState extends State<App> {
appBar: new AppBar(), appBar: new AppBar(),
body: Home( body: Home(
mode: _appMode, mode: _appMode,
invokerURL: _invokerURL invokerURL: _invokerURL,
setMode: setMode
) )
), ),
); );
......
...@@ -6,9 +6,10 @@ import 'dart:developer'; ...@@ -6,9 +6,10 @@ import 'dart:developer';
import 'dart:convert'; import 'dart:convert';
class Home extends StatefulWidget { 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 mode;
final String invokerURL; final String invokerURL;
final void Function(String) setMode;
@override @override
_HomeState createState() => _HomeState(); _HomeState createState() => _HomeState();
...@@ -46,13 +47,8 @@ class _HomeState extends State<Home> { ...@@ -46,13 +47,8 @@ class _HomeState extends State<Home> {
child: Text('Go back'), child: Text('Go back'),
onPressed: () async { onPressed: () async {
Navigator.of(context).pop(); Navigator.of(context).pop();
widget.setMode("");
log('Try launch ${widget.invokerURL}'); await launch("${widget.invokerURL}?token=$token");
if (await canLaunch(widget.invokerURL)) {
await launch("${widget.invokerURL}?token=$token");
} else {
log('Could not launch ${widget.invokerURL}');
}
}, },
), ),
], ],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment