Support token login
This commit is contained in:
parent
eaa6ffe85d
commit
e3a349c811
|
|
@ -37,6 +37,11 @@ class OAuthLoginRequest implements StartLoading {
|
|||
final String oneTimePassword;
|
||||
}
|
||||
|
||||
class TokenLogin {
|
||||
TokenLogin(this.token);
|
||||
final String token;
|
||||
}
|
||||
|
||||
class UserLoadUrl {
|
||||
UserLoadUrl({this.url});
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import 'package:flutter/services.dart';
|
|||
import 'package:invoiceninja_flutter/constants.dart';
|
||||
import 'package:invoiceninja_flutter/redux/ui/pref_state.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/buttons/app_text_button.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/buttons/elevated_button.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/dialogs/alert_dialog.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/forms/app_toggle_buttons.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/forms/decorated_form_field.dart';
|
||||
|
|
@ -46,6 +47,7 @@ class _LoginState extends State<LoginView> {
|
|||
final _urlController = TextEditingController();
|
||||
final _secretController = TextEditingController();
|
||||
final _oneTimePasswordController = TextEditingController();
|
||||
final _tokenController = TextEditingController();
|
||||
|
||||
final _buttonController = RoundedLoadingButtonController();
|
||||
|
||||
|
|
@ -53,6 +55,7 @@ class _LoginState extends State<LoginView> {
|
|||
|
||||
String _loginError = '';
|
||||
|
||||
bool _tokenLogin = false;
|
||||
bool _emailLogin = false;
|
||||
bool _isSelfHosted = false;
|
||||
bool _createAccount = true;
|
||||
|
|
@ -110,6 +113,8 @@ class _LoginState extends State<LoginView> {
|
|||
_passwordController.dispose();
|
||||
_urlController.dispose();
|
||||
_secretController.dispose();
|
||||
_oneTimePasswordController.dispose();
|
||||
_tokenController.dispose();
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
|
@ -294,9 +299,34 @@ class _LoginState extends State<LoginView> {
|
|||
onTap: () {
|
||||
launch(kSiteUrl, forceSafariVC: false, forceWebView: false);
|
||||
},
|
||||
onLongPress: () {
|
||||
if (kReleaseMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() => _tokenLogin = !_tokenLogin);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_tokenLogin)
|
||||
FormCard(
|
||||
forceNarrow: calculateLayout(context) != AppLayout.mobile,
|
||||
children: [
|
||||
DecoratedFormField(
|
||||
label: localization.token,
|
||||
controller: _tokenController,
|
||||
),
|
||||
AppButton(
|
||||
label: localization.submit.toUpperCase(),
|
||||
onPressed: () {
|
||||
final Completer<Null> completer = Completer<Null>();
|
||||
viewModel.onTokenLoginPressed(context, completer,
|
||||
token: _tokenController.text);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
AnimatedOpacity(
|
||||
duration: Duration(milliseconds: 500),
|
||||
opacity: viewModel.authState.isAuthenticated ? 0 : 1,
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ class LoginVM {
|
|||
@required this.onSignUpPressed,
|
||||
@required this.onGoogleLoginPressed,
|
||||
@required this.onGoogleSignUpPressed,
|
||||
@required this.onTokenLoginPressed,
|
||||
});
|
||||
|
||||
AppState state;
|
||||
|
|
@ -79,6 +80,12 @@ class LoginVM {
|
|||
@required String password,
|
||||
}) onSignUpPressed;
|
||||
|
||||
final Function(
|
||||
BuildContext,
|
||||
Completer<Null> completer, {
|
||||
@required String token,
|
||||
}) onTokenLoginPressed;
|
||||
|
||||
final Function(BuildContext, Completer<Null> completer,
|
||||
{String url, String secret, String oneTimePassword}) onGoogleLoginPressed;
|
||||
final Function(BuildContext, Completer<Null> completer) onGoogleSignUpPressed;
|
||||
|
|
@ -174,8 +181,8 @@ class LoginVM {
|
|||
idToken: idToken,
|
||||
accessToken: accessToken,
|
||||
));
|
||||
completer.future.then(
|
||||
(_) => _handleLogin(context: context, isSignUp: true));
|
||||
completer.future
|
||||
.then((_) => _handleLogin(context: context, isSignUp: true));
|
||||
}
|
||||
});
|
||||
if (!signedIn) {
|
||||
|
|
@ -246,6 +253,11 @@ class LoginVM {
|
|||
oneTimePassword: oneTimePassword.trim(),
|
||||
));
|
||||
completer.future.then((_) => _handleLogin(context: context));
|
||||
});
|
||||
},
|
||||
onTokenLoginPressed: (BuildContext context, Completer<Null> completer,
|
||||
{@required String token}) {
|
||||
//
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue