Exemple #1
0
		public void CacheUser (UserInfo user)
		{
			ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this); 
			ISharedPreferencesEditor editor = prefs.Edit();
			editor.PutString (UserInfo.NAME, user.Name);
			editor.PutString (UserInfo.SESSIONID, user.SessionId);
			// TODO add the rest
			editor.Apply();
		}
Exemple #2
0
		public async static void SendLogoutRequest (UserInfo user)
		{
			Dictionary<string, string> dict = new Dictionary<string, string> ();
			dict.Add (sessionIdHeaderKey, user.SessionId);

			await Delete (BASE, LOGOUT, dict);

		}
Exemple #3
0
		async void HandleLoginClicked (object sender, EventArgs e)
		{
			emailInput.ClearFocus ();
			passwordInput.ClearFocus ();

			HideKeyboard ();

			if (!isLoginInProgess) {
				if (string.IsNullOrWhiteSpace (emailInput.Text)
				   || string.IsNullOrWhiteSpace (passwordInput.Text)) {
					// bad input
				} else {
					isLoginInProgess = true;

					LoginRequest loginRequest = new LoginRequest {
						Email = emailInput.Text,
						Password = passwordInput.Text
					};
					loaderView.ShowAnimation ();

					LoginResponse response = await Networking.SendLoginRequest (loginRequest);

					if (string.IsNullOrEmpty (response.SessionId)) {
						DialogUtils.CreateDialog (activity, "Oops!", "Failed to log in with these credentials.");
					} else {
						UserInfo user = new UserInfo {
							Name = response.Name,
							Email = response.email,
							SessionId = response.SessionId
						};
						LoginState.ActiveUser = user;
						activity.CacheUser (user);
						List<ParkingLotInfo> parkingLotInfoList = await Networking.SendParkingLotsRequest ();
						if (parkingLotInfoList != null) {
							LoginState.ActiveUser.AccessInfo.AddRange (parkingLotInfoList);
						} else {
							// TODO handle failing in life
						}
						activity.Finish ();
					}
					isLoginInProgess = false;

					loaderView.StopAnimating ();
				}
			}
		}