Merge branch 'elham' into 'master'

token Id finally in works

See merge request Cloud_Solution/doctor_app_flutter!17
merge-requests/18/merge
Elham 6 years ago
commit b2227bab49

@ -0,0 +1 @@
final TOKEN = 'token';

@ -1,42 +1,50 @@
import 'dart:convert';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/providers/auth_provider.dart';
import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';
import 'package:http_interceptor/http_interceptor.dart';
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
List<String> publicUrls = [LOGIN_URL,SELECT_DEVICE_IMEI,];
List<String> publicUrls = [
LOGIN_URL,
SELECT_DEVICE_IMEI,
MEMBER_CHECK_ACTIVATION_CODE_NEW,
SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE
];
class HttpInterceptor extends InterceptorContract {
Future<RequestData> interceptRequest({RequestData data}) async {
// print('RequestData ${data.body}');
try {
print({data.headers});
data.headers["Content-Type"] = "application/json";
data.headers["Accept"] = "application/json";
if (!publicUrls.contains(data.url)) {
var loggedUserInfo = await sharedPref.getObj('loggedUser');
print('loggedUserInfo$loggedUserInfo');
// the sevices handel the token in differat name so I ask to be change
// we must change the implementaion once the name are changed
if(data.body['LogInTokenID']){
data.body['LogInTokenID'] = loggedUserInfo['LogInTokenID'];
}
if(data.body['TokenID']){
data.body['TokenID'] = loggedUserInfo['LogInTokenID'];
}
print('data.body${data.body}');
}
else {
if(data.body['LogInTokenID']){
data.body['LogInTokenID'] = '';
}
if(data.body['TokenID']){
data.body['TokenID'] = '';
}
}
// if (publicUrls.contains(data.url)) {
// var loggedUserInfo = await sharedPref.getObj('loggedUser');
// var token = await sharedPref.getString(TOKEN);
// // print("token"+token);
// // print('loggedUserInfo${loggedUserInfo["LogInTokenID"]}');
// // // the sevices handel the token in differat name so I ask to be change
// // // we must change the imple
// var body = json.decode(data.body);
// body['LogInTokenID']=token;
// data.body = json.encode(body);
// // data.body['LogInTokenID'] = '';
// } else {
// if (data.body['LogInTokenID']) {
// data.body['LogInTokenID'] = '';
// }
// if (data.body['TokenID']) {
// data.body['TokenID'] = '';
// }
// }
} catch (e) {
print(e);
}
// print('data.body${data.body}');
return data;
}

@ -1,6 +1,4 @@
import 'package:doctor_app_flutter/screens/patients/patient_profile_screen.dart';
import './screens/QR_reader_screen.dart';
import './screens/auth/change_password_screen.dart';
import './screens/auth/login_screen.dart';
@ -11,11 +9,12 @@ import './screens/dashboard_screen.dart';
import './screens/doctor_reply_screen.dart';
import './screens/medicine/medicine_search_screen.dart';
import './screens/my_schedule_screen.dart';
import './screens/patients/patient_profile_screen.dart';
import './screens/patients/patient_search_screen.dart';
import './screens/patients/patients_screen.dart';
import './screens/settings/settings_screen.dart';
const String INIT_ROUTE = PATIENTS;
const String INIT_ROUTE = LOGIN;
const String HOME = '/';
const String LOGIN = 'login';
const String CHANGE_PASSWORD = 'change-password';

@ -6,6 +6,7 @@ import 'package:hexcolor/hexcolor.dart';
import 'package:imei_plugin/imei_plugin.dart';
import 'package:provider/provider.dart';
import '../../config/shared_pref_kay.dart';
import '../../config/size_config.dart';
import '../../models/user_model.dart';
import '../../providers/auth_provider.dart';
@ -67,22 +68,8 @@ class _LoginFormState extends State<LoginForm> {
buildSizedBox(),
TextFormField(
keyboardType: TextInputType.number,
// style: TextStyle(fontSize: 30),
decoration: InputDecoration(
prefixIcon: Image.asset('assets/images/user_id_icon.png'),
hintText: 'Enter ID',
hintStyle: TextStyle(fontSize: 2 * SizeConfig.textMultiplier),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(20)),
borderSide: BorderSide(color: Hexcolor('#CCCCCC')),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
borderSide:
BorderSide(color: Theme.of(context).primaryColor),
)
//BorderRadius.all(Radius.circular(20));
),
decoration: buildInputDecoration(
context, 'Enter ID', 'assets/images/user_id_icon.png'),
validator: (value) {
if (value.isEmpty) {
return 'Please enter your ID';
@ -96,22 +83,8 @@ class _LoginFormState extends State<LoginForm> {
buildSizedBox(),
TextFormField(
obscureText: true,
decoration: InputDecoration(
prefixIcon: Image.asset('assets/images/password_icon.png'),
hintText: 'Enter Password',
hintStyle:
TextStyle(fontSize: 2 * SizeConfig.textMultiplier),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(20)),
borderSide: BorderSide(color: Hexcolor('#CCCCCC')),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
borderSide:
BorderSide(color: Theme.of(context).primaryColor),
)
//BorderRadius.all(Radius.circular(20));
),
decoration: buildInputDecoration(context, 'Enter Password',
'assets/images/password_icon.png'),
validator: (value) {
if (value.isEmpty) {
return 'Please enter your Password';
@ -130,22 +103,8 @@ class _LoginFormState extends State<LoginForm> {
},
showCursor: false,
readOnly: true,
decoration: InputDecoration(
prefixIcon: Image.asset('assets/images/password_icon.png'),
hintText: 'Select your porject',
hintStyle:
TextStyle(fontSize: 2 * SizeConfig.textMultiplier),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(20)),
borderSide: BorderSide(color: Hexcolor('#CCCCCC')),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
borderSide:
BorderSide(color: Theme.of(context).primaryColor),
)
//BorderRadius.all(Radius.circular(20));
),
decoration: buildInputDecoration(context, 'Select your porject',
'assets/images/password_icon.png'),
validator: (value) {
if (value.isEmpty) {
return 'Please enter your porject';
@ -207,6 +166,28 @@ class _LoginFormState extends State<LoginForm> {
);
}
/*
*@author: Elham Rababah
*@Date:20/4/2020
*@param: context, hint, asset
*@return: InputDecoration
*@desc: decorate input feilds
*/
InputDecoration buildInputDecoration(BuildContext context, hint, asset) {
return InputDecoration(
prefixIcon: Image.asset(asset),
hintText: hint,
hintStyle: TextStyle(fontSize: 2 * SizeConfig.textMultiplier),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(20)),
borderSide: BorderSide(color: Hexcolor('#CCCCCC')),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
borderSide: BorderSide(color: Theme.of(context).primaryColor),
));
}
SizedBox buildSizedBox() {
return SizedBox(
height: 20,
@ -223,6 +204,9 @@ class _LoginFormState extends State<LoginForm> {
if (res['MessageStatus'] == 1) {
// insertDeviceImei(res, authProv);
saveObjToString('loggedUser', res);
sharedPref.setString(TOKEN, res['LogInTokenID']);
print("token" + res['LogInTokenID']);
Navigator.of(context).pushNamed(VERIFICATION_METHODS);
} else {
// handel error

@ -1,3 +1,4 @@
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart';
@ -90,7 +91,6 @@ class _VerifyAccountState extends State<VerifyAccount> {
child: TextFormField(
maxLength: 1,
textAlign: TextAlign.center,
style: buildTextStyle(),
keyboardType: TextInputType.number,
decoration:
@ -256,8 +256,8 @@ class _VerifyAccountState extends State<VerifyAccount> {
Map model = {
"activationCode": activationCode,
"DoctorID": _loggedUser['List_MemberInformation'][0]['MemberID'],
"LogInTokenID": _loggedUser['LogInTokenID'],
"DoctorID": _loggedUser['DoctorID'],
// "LogInTokenID": _loggedUser['LogInTokenID'],
"ProjectID": 15,
"LanguageID": 2,
"stamp": "2020-02-26T14:48:27.221Z",
@ -272,19 +272,20 @@ class _VerifyAccountState extends State<VerifyAccount> {
changeLoadingStata(true);
Navigator.of(context).pushNamed(HOME);
// authProv.memberCheckActivationCodeNew(model).then((res) {
// changeLoadingStata(false);
// if (res['MessageStatus'] == 1) {
// Navigator.of(context).pushNamed(HOME);
// } else {
// helpers.showErrorToast(res['ErrorEndUserMessage']);
// }
// }).catchError((err) {
// changeLoadingStata(false);
authProv.memberCheckActivationCodeNew(model).then((res) {
changeLoadingStata(false);
if (res['MessageStatus'] == 1) {
sharedPref.setString(TOKEN, res['AuthenticationTokenID']);
Navigator.of(context).pushNamed(HOME);
} else {
helpers.showErrorToast(res['ErrorEndUserMessage']);
}
}).catchError((err) {
changeLoadingStata(false);
// print('$err');
// helpers.showErrorToast();
// });
print('$err');
helpers.showErrorToast();
});
} else {
// changeLoadingStata(false);
}

@ -188,8 +188,8 @@ class _VerificationMethodsState extends State<VerificationMethods> {
"UserName": _loggedUser['List_MemberInformation'][0]['MemberID'],
"OTP_SendType": oTPSendType
};
print('$_loggedUser');
print(oTPSendType);
// print('$_loggedUser');
// print(oTPSendType);
authProv.sendActivationCodeByOtpNotificationType(model).then((res) {
// Navigator.of(context).pushNamed(VERIFY_ACCOUNT);
widget.changeLoadingStata(false);

Loading…
Cancel
Save