added some hint for spaces after username
This commit is contained in:
parent
6e06d82b1a
commit
5e650869f2
13
filcnaplo/ios/Flutter/flutter_export_environment 3.sh
Executable file
13
filcnaplo/ios/Flutter/flutter_export_environment 3.sh
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# This is a generated file; do not edit or check into version control.
|
||||||
|
export "FLUTTER_ROOT=/Users/kima/src/flutter"
|
||||||
|
export "FLUTTER_APPLICATION_PATH=/Users/kima/Documents/refilc/app/naplo/filcnaplo"
|
||||||
|
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
|
||||||
|
export "FLUTTER_TARGET=lib/main.dart"
|
||||||
|
export "FLUTTER_BUILD_DIR=build"
|
||||||
|
export "FLUTTER_BUILD_NAME=4.2.0"
|
||||||
|
export "FLUTTER_BUILD_NUMBER=220"
|
||||||
|
export "DART_OBFUSCATION=false"
|
||||||
|
export "TRACK_WIDGET_CREATION=true"
|
||||||
|
export "TREE_SHAKE_ICONS=false"
|
||||||
|
export "PACKAGE_CONFIG=.dart_tool/package_config.json"
|
@ -27,7 +27,7 @@ enum LoginState {
|
|||||||
failed,
|
failed,
|
||||||
normal,
|
normal,
|
||||||
inProgress,
|
inProgress,
|
||||||
success
|
success,
|
||||||
}
|
}
|
||||||
|
|
||||||
Nonce getNonce(String nonce, String username, String instituteCode) {
|
Nonce getNonce(String nonce, String username, String instituteCode) {
|
||||||
@ -39,7 +39,7 @@ Nonce getNonce(String nonce, String username, String instituteCode) {
|
|||||||
return nonceEncoder;
|
return nonceEncoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future loginApi({
|
Future loginAPI({
|
||||||
required String username,
|
required String username,
|
||||||
required String password,
|
required String password,
|
||||||
required String instituteCode,
|
required String instituteCode,
|
||||||
@ -49,14 +49,14 @@ Future loginApi({
|
|||||||
}) async {
|
}) async {
|
||||||
Provider.of<KretaClient>(context, listen: false).userAgent =
|
Provider.of<KretaClient>(context, listen: false).userAgent =
|
||||||
Provider.of<SettingsProvider>(context, listen: false).config.userAgent;
|
Provider.of<SettingsProvider>(context, listen: false).config.userAgent;
|
||||||
|
|
||||||
Map<String, String> headers = {
|
Map<String, String> headers = {
|
||||||
"content-type": "application/x-www-form-urlencoded",
|
"content-type": "application/x-www-form-urlencoded",
|
||||||
};
|
};
|
||||||
|
|
||||||
String nonceStr = await Provider.of<KretaClient>(context, listen: false)
|
String nonceStr = await Provider.of<KretaClient>(context, listen: false)
|
||||||
.getAPI(KretaAPI.nonce, json: false);
|
.getAPI(KretaAPI.nonce, json: false);
|
||||||
|
|
||||||
Nonce nonce = getNonce(nonceStr, username, instituteCode);
|
Nonce nonce = getNonce(nonceStr, username, instituteCode);
|
||||||
headers.addAll(nonce.header());
|
headers.addAll(nonce.header());
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ Future loginApi({
|
|||||||
|
|
||||||
return LoginState.success;
|
return LoginState.success;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print("ERROR: loginApi: $error");
|
print("ERROR: loginAPI: $error");
|
||||||
// maybe check debug mode
|
// maybe check debug mode
|
||||||
// ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("ERROR: $error")));
|
// ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("ERROR: $error")));
|
||||||
return LoginState.failed;
|
return LoginState.failed;
|
||||||
|
@ -235,7 +235,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
fontSize: 15.0,
|
fontSize: 15.0,
|
||||||
)),
|
)),
|
||||||
onPressed: () => _loginApi(context: context),
|
onPressed: () => _loginAPI(context: context),
|
||||||
),
|
),
|
||||||
visible: _loginState != LoginState.inProgress,
|
visible: _loginState != LoginState.inProgress,
|
||||||
replacement: const Padding(
|
replacement: const Padding(
|
||||||
@ -279,7 +279,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _loginApi({required BuildContext context}) {
|
void _loginAPI({required BuildContext context}) {
|
||||||
String username = usernameController.text;
|
String username = usernameController.text;
|
||||||
String password = passwordController.text;
|
String password = passwordController.text;
|
||||||
|
|
||||||
@ -289,7 +289,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
|
|
||||||
setState(() => _loginState = LoginState.inProgress);
|
setState(() => _loginState = LoginState.inProgress);
|
||||||
|
|
||||||
loginApi(
|
loginAPI(
|
||||||
username: username,
|
username: username,
|
||||||
password: password,
|
password: password,
|
||||||
instituteCode: schoolController.selectedSchool!.instituteCode,
|
instituteCode: schoolController.selectedSchool!.instituteCode,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// import 'dart:async';
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:filcnaplo/api/client.dart';
|
import 'package:filcnaplo/api/client.dart';
|
||||||
@ -42,6 +43,8 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
stops: [-1.0, 0.0, 1.0],
|
stops: [-1.0, 0.0, 1.0],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
late String tempUsername = '';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -250,7 +253,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
fontSize: 15.0,
|
fontSize: 15.0,
|
||||||
)),
|
)),
|
||||||
onPressed: () => _loginApi(context: context),
|
onPressed: () => _loginAPI(context: context),
|
||||||
),
|
),
|
||||||
visible: _loginState != LoginState.inProgress,
|
visible: _loginState != LoginState.inProgress,
|
||||||
replacement: const Padding(
|
replacement: const Padding(
|
||||||
@ -288,35 +291,54 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _loginApi({required BuildContext context}) {
|
void _loginAPI({required BuildContext context}) {
|
||||||
String username = usernameController.text;
|
String username = usernameController.text;
|
||||||
String password = passwordController.text;
|
String password = passwordController.text;
|
||||||
|
|
||||||
|
tempUsername = username;
|
||||||
|
|
||||||
if (username == "" ||
|
if (username == "" ||
|
||||||
password == "" ||
|
password == "" ||
|
||||||
schoolController.selectedSchool == null) {
|
schoolController.selectedSchool == null) {
|
||||||
return setState(() => _loginState = LoginState.missingFields);
|
return setState(() => _loginState = LoginState.missingFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(() => _loginState = LoginState.inProgress);
|
void _callAPI() {
|
||||||
|
loginAPI(
|
||||||
|
username: username,
|
||||||
|
password: password,
|
||||||
|
instituteCode: schoolController.selectedSchool!.instituteCode,
|
||||||
|
context: context,
|
||||||
|
onLogin: (user) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(CustomSnackBar(
|
||||||
|
context: context,
|
||||||
|
brightness: Brightness.light,
|
||||||
|
content: Text("welcome".i18n.fill([user.name]),
|
||||||
|
overflow: TextOverflow.ellipsis),
|
||||||
|
));
|
||||||
|
},
|
||||||
|
onSuccess: () {
|
||||||
|
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||||
|
setSystemChrome(context);
|
||||||
|
Navigator.of(context).pushReplacementNamed("login_to_navigation");
|
||||||
|
}).then(
|
||||||
|
(res) => setState(() {
|
||||||
|
// if (res == LoginState.invalidGrant &&
|
||||||
|
// tempUsername.replaceAll(username, '').length <= 3) {
|
||||||
|
// tempUsername = username + ' ';
|
||||||
|
// Timer(
|
||||||
|
// const Duration(milliseconds: 500),
|
||||||
|
// () => _loginAPI(context: context),
|
||||||
|
// );
|
||||||
|
// // _loginAPI(context: context);
|
||||||
|
// } else {
|
||||||
|
_loginState = res;
|
||||||
|
// }
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
loginApi(
|
setState(() => _loginState = LoginState.inProgress);
|
||||||
username: username,
|
_callAPI();
|
||||||
password: password,
|
|
||||||
instituteCode: schoolController.selectedSchool!.instituteCode,
|
|
||||||
context: context,
|
|
||||||
onLogin: (user) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(CustomSnackBar(
|
|
||||||
context: context,
|
|
||||||
brightness: Brightness.light,
|
|
||||||
content: Text("welcome".i18n.fill([user.name]),
|
|
||||||
overflow: TextOverflow.ellipsis),
|
|
||||||
));
|
|
||||||
},
|
|
||||||
onSuccess: () {
|
|
||||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
|
||||||
setSystemChrome(context);
|
|
||||||
Navigator.of(context).pushReplacementNamed("login_to_navigation");
|
|
||||||
}).then((res) => setState(() => _loginState = res));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,8 @@ extension Localization on String {
|
|||||||
"login": "Log in",
|
"login": "Log in",
|
||||||
"welcome": "Welcome, %s!",
|
"welcome": "Welcome, %s!",
|
||||||
"missing_fields": "Missing Fields!",
|
"missing_fields": "Missing Fields!",
|
||||||
"invalid_grant": "Invalid Username/Password!",
|
"invalid_grant":
|
||||||
|
"Invalid Username/Password! (Try adding spaces after Username)",
|
||||||
"error": "Failed to log in.",
|
"error": "Failed to log in.",
|
||||||
"schools_error": "Failed to get schools."
|
"schools_error": "Failed to get schools."
|
||||||
},
|
},
|
||||||
@ -25,7 +26,8 @@ extension Localization on String {
|
|||||||
"login": "Belépés",
|
"login": "Belépés",
|
||||||
"welcome": "Üdv, %s!",
|
"welcome": "Üdv, %s!",
|
||||||
"missing_fields": "Hiányzó adatok!",
|
"missing_fields": "Hiányzó adatok!",
|
||||||
"invalid_grant": "Helytelen Felhasználónév/Jelszó!",
|
"invalid_grant":
|
||||||
|
"Helytelen Felhasználónév/Jelszó! (Próbálj szóközöket írni a Felhasználónév után)",
|
||||||
"error": "Sikertelen bejelentkezés.",
|
"error": "Sikertelen bejelentkezés.",
|
||||||
"schools_error": "Nem sikerült lekérni az iskolákat."
|
"schools_error": "Nem sikerült lekérni az iskolákat."
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user