Exemple #1
0
        public async Task HandleLogIn(LogInLayout LIlayout, ContentPageController viewController)
        {
            //this is used only for debugging cause the emulator likes to save credentials
            //AuthCache.DeleteObject();

            ViewController = viewController;
            if (AuthCache.DoCredentialsExist())
            {
                // need to gather credentials and pass them on
                var Username = AuthCache.GetUserName();
                var CookieString = AuthCache.GetCookieString();
                //string Password = "******";

                // build the cookiecontainer from authstring
                var tempcookie = new Cookie {Name = ".AspNet.ApplicationCookie", Value = CookieString};
                var tempcollection = new CookieContainer();
                tempcollection.Add(new Uri(Constants.EndPoint), tempcookie);
                await VerifyAndPass(LIlayout, Username, tempcollection, false, viewController);
            }
            else
            {
                SeenHomeScreen = true;
                var HLayout = new HomeLayout(ViewController, false);
            }
        }
Exemple #2
0
 //Handles a new Log In and Stores Credientials
 public async Task NewLogIn(LogInLayout LIlayout, string userName, string password, bool saveCredentials,
     ContentPageController viewcontroller)
 {
     var cookieJar = await LogIn(userName, password);
     if (await VerifyLogin(cookieJar))
     {
         await VerifyAndPass(LIlayout, userName, cookieJar, saveCredentials, viewcontroller);
     }
     else
     {
         if (!SeenHomeScreen)
         {
             SeenHomeScreen = true;
             var HLayout = new HomeLayout(ViewController, false);
         }
         else
         {
             ViewController.Invoke(() => ViewController.View.Content = ViewController.LogIn.LILayout);
         }
     }
 }
Exemple #3
0
        public async Task VerifyAndPass(LogInLayout LIlayout, string userName, CookieContainer cookieJar,
            bool saveCredentials, ContentPageController viewController)
        {
            CookieJar = cookieJar;

            // store credientials if it is a new login
            if (saveCredentials)
            {
                //Gather Cookie String
                var gameUri = new Uri(Constants.EndPoint);
                var gamecookies = CookieJar.GetCookies(gameUri);
                string CookieString = null;
                foreach (Cookie c in gamecookies)
                {
                    if (c.Name == ".AspNet.ApplicationCookie") CookieString = c.Value;
                }
                //Store Cookie
                AuthCache.InsertObject(userName, CookieString);
            }

            //just preps the Game Manager
            GameManager.SetupGame(CookieJar, ViewController);

            if (!SeenHomeScreen)
            {
                SeenHomeScreen = true;
                var HLayout = new HomeLayout(ViewController, true);
            }
            else
            {
                var GSlayout = new GameSelectLayout(ViewController);
            }
        }