public async Task LogIn(string username, string password)
        {
            try
            {
                TokenItem tokenResponse = await _apiHelper.AuthenticateAsync(username, password);

                if (!String.IsNullOrWhiteSpace(tokenResponse.Token))
                {
                    Token = tokenResponse;
                }
                else
                {
                    throw new Exception("Empty token received");
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.Equals("Unauthorized"))
                {
                    throw new Exception("Bad login or password");
                }
                else
                {
                    throw new Exception(ex.Message);
                }
            }
        }
Exemple #2
0
        public async Task Login()
        {
            try
            {
                ErrorMessage = string.Empty;

                AuthenticatedUser userSession = await _apiHelper.AuthenticateAsync(Username, Password);

                await _apiHelper.GetLoggedInUserAsync(userSession.AccessToken);

                _events.PublishOnUIThread(new LoggedInEvent());
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }
Exemple #3
0
        public async Task LoginAsync()
        {
            try
            {
                ErrorMessage = string.Empty;
                var result = await _apiHelper.AuthenticateAsync(UserName, Password);

                //capture user info
                await _apiHelper.GetLoggedInUserInfo(result.Access_Token);

                await _events.PublishOnUIThreadAsync(new LogOnEvent());
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }