Exemplo n.º 1
0
		/// <summary>
		/// Validates users credentials for login, retrieves a token to 
		/// be used throughout the session
		/// </summary>
		/// <param name="logonInfo">Logon info. Contains username, password, rememberMe</param>
		public TokenClient Logon (AccountLogonInfo logonInfo, bool useAsync = false)
		{

			return InvokeStrategy<TokenClient> (() => {
				_logonInfo = logonInfo;
				string authInfo = Convert.ToBase64String (System.Text.Encoding.Default.GetBytes (
					                  logonInfo.UserName + ":" + logonInfo.Password
				                  ));

				if (useAsync) {
					var wc = base.GetAsync (UrlPaths.Logon, this.LogonCompleted, (whc) => {
						whc.Add ("Authorization", "Basic " + authInfo);
					});
					if (wc.HasErrors)
						return;				
				 
				} else {
					var wc = base.Get (UrlPaths.Logon, (whc) => {
						whc.Add ("Authorization", "Basic " + authInfo);
					});
					if (wc.HasErrors)
						return;		

					LogonCompleted ();
				}

			});					
		}
		public static void Logon (AccountLogonInfo logonInfo, Action loggedOn)
		{
			ECLSUIUtil.TryAction<DefaultViewController> ("Login", () => {
				new ECLSAsyncApiStatus<TokenClient> () {
					CompletedStrategy = (tokenClient) => {
						new ECLSAsyncApiStatus<UserContext> () {

							CompletedStrategy = (uc) => {
								uc.UserLoaded ();
								SyncDefaultSettings ();
								loggedOn ();
							}
						}.InvokeAsyncAction ("Loading Profile...", uc => {
							uc.LoadAsync ();
						});
						ApplicationContext.Current.RememberedUser = logonInfo;
					}
					
				}.InvokeAsyncAction ("Logging on...", (tokenclient) => {
					tokenclient.Logon (logonInfo, true);
				});
			});
		}
Exemplo n.º 3
0
		private void UpdateCredentialCache (AccountLogonInfo accountLoginInfo)
		{

			UserContext.Current.User = UserContext.Current.User = new AccountUserInfo () {
				UserName = accountLoginInfo.UserName,
				IsGuest = accountLoginInfo.IsGuest
			};
			//  if (ApplicationContext.Current.WasUserCached)
			//  {
			//      accountLoginInfo.RememberMe = true;
              
			//  }
			ApplicationContext.Current.RememberedUser = accountLoginInfo;
		}