auth edits

merge-requests/22/head
MaximusAshraf 3 years ago
parent c5b5a8011a
commit fab1bdf65d

@ -30,7 +30,8 @@ class ApiManager {
headers.addAll(_headers);
Uri _url = Uri.parse(url);
// print(_url);
// print(_url);
// print(headers);
http.Response response = await http.get(_url,headers: headers);
if(jsonDecode(response.body) is Map<String,dynamic>){
final message = jsonDecode(response.body)["message"];
@ -54,9 +55,9 @@ class ApiManager {
headers.addAll(_headers);
Uri _url = Uri.parse(url);
// print(_url);
// print(headers);
log(json.encode(body));
// print(_url);
// print(headers);
// log(json.encode(body));
var request = http.Request('POST', _url);
request.body = json.encode(body);
request.headers.addAll(headers);

@ -59,7 +59,7 @@ class UserProvider extends ChangeNotifier{
if(response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
_user = User.fromJson(jsonDecode(response.body));
ApiManager.instance.user = _user;
return response.statusCode;
}
notifyListeners();

@ -103,10 +103,10 @@ class User{
id: parsedJson["userID"],
userName: parsedJson["username"],
email: parsedJson["email"],
// hospital: Hospital(
// id: parsedJson["client_id"],
// name: parsedJson["client_name"]
// ),
hospital: Hospital(
id: parsedJson["client_id"],
name: parsedJson["client_name"]
),
department: Department(
id: parsedJson["department_id"],
name: parsedJson["department_name"],

@ -154,7 +154,7 @@ class _LandPageState extends State<LandPage> {
mainAxisSpacing: 5,
childAspectRatio: 1.15,
children: [
if (_userProvider.user.type == UsersTypes.normal_user)
if (_userProvider.user?.type == UsersTypes.normal_user)
LandPageItem(
text: _subtitle.newServiceRequest,
icon: FontAwesomeIcons.tools,

Loading…
Cancel
Save