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); } }
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); } }
//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); } } }
public ContentPageController(NavigationDrawer navigationDrawer) { NavDrawer = navigationDrawer; LogIn = new LogInLayout(this); LogInManager = new LogInManager(); // dispite all the work, this never gets seen in release due to real loading times vs emulator loading ties var LoadingScreen = new StackLayout { BackgroundColor = Color.FromHex("1393c3"), Children = { new Image { Source = "unsafespaceslogo.png" }, new Label { Text = "#nooneissafe", FontSize = 20, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, HeightRequest = 25 }, new Image { Source = "shocked_smile.png" }, new ActivityIndicator { Color = Color.Silver, IsRunning = true } } }; //Main view inside NavDrawer, wraps the rest of the views inside a scrollview View = new ScrollView { //BackgroundColor = Color.White, VerticalOptions = LayoutOptions.FillAndExpand, Content = LoadingScreen }; Content = View; // Accomodate iPhone status bar. LogIn.LILayout.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); LogIn.button.Clicked += async (sender, args) => { var tempButton = sender as Button; Invoke(() => tempButton.IsEnabled = false); if ((LogIn.username != null) && (LogIn.password != null)) { LogIn.button.Text = "Logging In!"; //Starts a new Log In await LogInManager.NewLogIn(LogIn, LogIn.Lusername.Text, LogIn.Lpassword.Text, true, this); } else { Invoke(() => DisplayAlert("Username or Password Blank", "Please fill out username and password before submitting", "OK").ConfigureAwait(false)); } Invoke(() => tempButton.IsEnabled = true); LogIn.button.Text = "Click To Log In"; }; LogIn.FacebookLogin.Clicked += (object sender, EventArgs e) => { Navigation.PushModalAsync(new LoginPage()); }; GameManager.ViewController = this; // Sends control to LogInManager to handle initial screen LogInManager.HandleLogIn(LogIn, this).ConfigureAwait(false); }