Beispiel #1
0
		public static JsonValue EncodeLoginRequest (LoginRequest loginRequest)
		{
			return new JsonObject {
				{ EMAIL, loginRequest.Email },
				{ PASSWORD, loginRequest.Password }
			};
		}
Beispiel #2
0
		public async static Task<LoginResponse> SendLoginRequest (LoginRequest loginRequest)
		{
			JsonValue json = Codec.EncodeLoginRequest (loginRequest);

			json = await Post (BASE, LOGIN, json);

			return Codec.DecodeLoginResponse (json);
		}
Beispiel #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 ();
				}
			}
		}