Пример #1
0
        public bool Login(string username, string password)
        {
            //custom authentication
            AccountServiceClient client = null;


            try
            {
                client = new AccountServiceClient();
                bool authenticated = client.LoginUser(username, password);

                if (authenticated)
                {
                    Account accountCriteria = new Account();
                    accountCriteria.AccountUsername = username;
                    accountCriteria.AccountPassword = password;

                    _view.Accounts        = client.AccountRetrieveByCriteria(accountCriteria).ToList();
                    _view.TitleForDisplay = "Login Successful";
                }
                else
                {
                    _view.Accounts        = null;
                    _view.TitleForDisplay = "Sorry, username and/or password are not correct";
                    return(false);
                }
            }
            catch (TimeoutException te)
            {
                _log.Fatal(te);
            }
            catch (FaultException fe)
            {
                _log.Fatal(fe);
            }
            catch (CommunicationException ce)
            {
                _log.Fatal(ce);
            }

            catch (Exception ex)
            {
                _log.Fatal(ex);
            }

            finally
            {
                if (client != null)
                {
                    client.CloseProxy();
                }
            }

            return(true);
        }
Пример #2
0
        public string ResetPasswordRequest(string username, string email)
        {
            //here we would make our wcf service call or do a webhttp request
            //for the purposes of this demo return the password code and fill the password code box, indicate that
            //on the page to the consumer that they would have gotten an email otherwise
            AccountServiceClient client = null;
            bool   result            = false;
            string passwordResetCode = null;

            try
            {
                client            = new AccountServiceClient();
                passwordResetCode = client.ResetPasswordRequest(username, email);

                result = true;
            }
            catch (TimeoutException te)
            {
                _log.Fatal(te);
            }
            catch (FaultException fe)
            {
                _log.Fatal(fe);
            }
            catch (CommunicationException ce)
            {
                _log.Fatal(ce);
            }

            catch (Exception ex)
            {
                _log.Fatal(ex);
            }

            finally
            {
                if (client != null)
                {
                    client.CloseProxy();
                }
            }

            if (result)
            {
                return(passwordResetCode);
            }
            return("There was an error and password reset code was not generated successfully");
        }
Пример #3
0
        public bool ResetPassword(string username, string email, string passwordResetCode, string newPassword)
        {
            //here we would make our wcf service call or do a webhttp request
            //for the purposes of this demo return the password code and fill the password code box, indicate that
            //on the page to the consumer that they would have gotten an email otherwise
            AccountServiceClient client = null;
            bool result = false;

            try
            {
                client = new AccountServiceClient();
                result = client.ResetPassword(username, email, passwordResetCode, newPassword);
            }
            catch (TimeoutException te)
            {
                _log.Fatal(te);
            }
            catch (FaultException fe)
            {
                _log.Fatal(fe);
            }
            catch (CommunicationException ce)
            {
                _log.Fatal(ce);
            }

            catch (Exception ex)
            {
                _log.Fatal(ex);
            }

            finally
            {
                if (client != null)
                {
                    client.CloseProxy();
                }
            }
            return(result);
        }