Example #1
0
 private static void InvalidLogin(IRestClient sericeClient)
 {
     try
     {
         Console.WriteLine("Example Invalid Login");
         var request = new Login() {Username = "******", Password = "******"};
         var user = sericeClient.Post<SecurityUser>(request);
     }
     catch (WebServiceException webEx)
     {
         Console.WriteLine("Caught Exception:");
         Console.WriteLine(webEx.ToString());
     }
 }
        public object Post(Login request)
        {
            //V1 of service did not allow selection of password algorithm
            //now if we get an old version request, then we will just pick the correct default
            if (request.Version < 2)
            {
                request.SecurityAlgorithm = "reverse";
            }

            Func<string, string> passwordEncrypt = null;
            switch (request.SecurityAlgorithm)
            {
            case "reverse":
                passwordEncrypt = Reverse;
                break;
            case "upper":
                passwordEncrypt = s => s.ToUpper();
                break;
            default:
                throw new HttpError("Invalid password algorithm");
            }

            if (request.Password == passwordEncrypt(request.Username))
            {
                return new SecurityUser()
                       {
                           Username = request.Username,
                           EmailAddress = request.Username + "@example.local",
                           Timezone = -6
                       };
            }
            else
            {
                return new HttpError("Invalid username and password");
            }
        }
Example #3
0
 private static void SuccessfulLogin(IRestClient sericeClient)
 {
     Console.WriteLine("Example Successful Login:"******"chris", Password = "******"};
     var user = sericeClient.Post(request);
     user.PrintDump();
 }