Sign in with Apple
This commit is contained in:
parent
7d2e4ef86d
commit
86d7af0e71
|
|
@ -10,6 +10,7 @@ import 'package:invoiceninja_flutter/ui/app/app_title_bar.dart';
|
|||
// Package imports:
|
||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||
import 'package:rounded_loading_button/rounded_loading_button.dart';
|
||||
import 'package:sign_in_with_apple/sign_in_with_apple.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
// Project imports:
|
||||
|
|
@ -576,7 +577,58 @@ class _LoginState extends State<LoginView> {
|
|||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20, bottom: 10, left: 16, right: 16),
|
||||
child: RoundedLoadingButton(
|
||||
child: _loginType == LOGIN_TYPE_APPLE
|
||||
? SignInWithAppleButton(
|
||||
onPressed: () async {
|
||||
final credential =
|
||||
await SignInWithApple.getAppleIDCredential(
|
||||
scopes: [
|
||||
AppleIDAuthorizationScopes.email,
|
||||
AppleIDAuthorizationScopes.fullName,
|
||||
],
|
||||
webAuthenticationOptions:
|
||||
WebAuthenticationOptions(
|
||||
clientId: 'com.invoiceninja.client',
|
||||
redirectUri: kIsWeb
|
||||
? Uri.parse(
|
||||
'https://staging.invoicing.co/')
|
||||
: Uri.parse(
|
||||
'https://invoicing.co/auth/apple'),
|
||||
),
|
||||
);
|
||||
|
||||
// ignore: avoid_print
|
||||
print('## credentials: $credential');
|
||||
|
||||
/*
|
||||
// This is the endpoint that will convert an authorization code obtained
|
||||
// via Sign in with Apple into a session in your system
|
||||
final signInWithAppleEndpoint = Uri(
|
||||
scheme: 'https',
|
||||
host:
|
||||
'flutter-sign-in-with-apple-example.glitch.me',
|
||||
path: '/sign_in_with_apple',
|
||||
queryParameters: <String, String>{
|
||||
'code': credential.authorizationCode,
|
||||
if (credential.givenName != null)
|
||||
'firstName': credential.givenName,
|
||||
if (credential.familyName != null)
|
||||
'lastName': credential.familyName,
|
||||
},
|
||||
);
|
||||
|
||||
final session = await http.Client().post(
|
||||
signInWithAppleEndpoint,
|
||||
);
|
||||
|
||||
// If we got this far, a session based on the Apple ID credential has been created in your system,
|
||||
// and you can now set this as the app's session
|
||||
// ignore: avoid_print
|
||||
print(session);
|
||||
*/
|
||||
},
|
||||
)
|
||||
: RoundedLoadingButton(
|
||||
height: 50,
|
||||
borderRadius: 4,
|
||||
width: 430,
|
||||
|
|
@ -589,7 +641,8 @@ class _LoginState extends State<LoginView> {
|
|||
if (_loginType == LOGIN_TYPE_EMAIL)
|
||||
Icon(Icons.mail, color: Colors.white)
|
||||
else if (_loginType == LOGIN_TYPE_MICROSOFT)
|
||||
Icon(MdiIcons.microsoft, color: Colors.white)
|
||||
Icon(MdiIcons.microsoft,
|
||||
color: Colors.white)
|
||||
else if (_loginType == LOGIN_TYPE_APPLE)
|
||||
Icon(MdiIcons.apple, color: Colors.white)
|
||||
else
|
||||
|
|
@ -606,16 +659,21 @@ class _LoginState extends State<LoginView> {
|
|||
: _createAccount
|
||||
? (_loginType == LOGIN_TYPE_EMAIL
|
||||
? localization.emailSignUp
|
||||
: _loginType == LOGIN_TYPE_MICROSOFT
|
||||
? localization.microsoftSignUp
|
||||
: _loginType ==
|
||||
LOGIN_TYPE_MICROSOFT
|
||||
? localization
|
||||
.microsoftSignUp
|
||||
: localization.googleSignUp)
|
||||
: (_loginType == LOGIN_TYPE_EMAIL
|
||||
? localization.emailSignIn
|
||||
: _loginType == LOGIN_TYPE_MICROSOFT
|
||||
? localization.microsoftSignIn
|
||||
: localization.googleSignIn),
|
||||
style:
|
||||
TextStyle(fontSize: 18, color: Colors.white),
|
||||
: _loginType ==
|
||||
LOGIN_TYPE_MICROSOFT
|
||||
? localization
|
||||
.microsoftSignIn
|
||||
: localization
|
||||
.googleSignIn),
|
||||
style: TextStyle(
|
||||
fontSize: 18, color: Colors.white),
|
||||
)
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
<meta charset="UTF-8">
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.4.456/pdf.min.js"></script>
|
||||
<script type="text/javascript" src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js"></script>
|
||||
<script type="text/javascript">
|
||||
pdfjsLib.GlobalWorkerOptions.workerSrc = "//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.4.456/pdf.worker.min.js";
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue