protected override void OnInitialized() { InitializeComponent(); Device.SetFlags(new[] { "SwipeView_Experimental", "AppTheme_Experimental" }); App.Current.UserAppTheme = (OSAppTheme)AppInfo.RequestedTheme; AppNavigationService = NavigationService; LanguageService.Init(); Sharpnado.Shades.Initializer.Initialize(true, true, filter: "ShadowsRenderer"); if (SettingsService.IsLoggedIn) { SessionService.AutoLogin(); } else { NavigationService.NavigateAsync($"/{nameof(NavigationPage)}/{nameof(LoginPage)}").Wait(); } }
private async void OAuth2Authenticator_Completed(object sender, AuthenticatorCompletedEventArgs eventArgs) { if (eventArgs.IsAuthenticated) { string email = string.Empty; switch (OAuth2ProviderType) { case OAuth2ProviderType.FACEBOOK: SessionService.SaveFBAccount(eventArgs.Account); email = await ProviderService.GetFacebookEmailAsync(); Debug.WriteLine($"Logged In User : {email}"); SettingsService.LoggedInUserEmail = email; SessionService.AutoLogin(); break; } } else { oAuth2Authenticator.OnCancelled(); oAuth2Authenticator = default(OAuth2Authenticator); } }
/// <summary> /// Performs user login. /// </summary> private async void Login() { try { if (string.IsNullOrEmpty(Email) && string.IsNullOrEmpty(Password)) { await DisplayAlertAsync(AppResources.TITLE_ERROR, AppResources.MESSAGE_ERROR_EMAIL_PASSWORD_ERROR, AppResources.TEXT_OK); return; } if (!(Regex.IsMatch(Email, SessionService.EMAIL_REGEX, RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250)))) { await DisplayAlertAsync(AppResources.TITLE_ERROR, AppResources.MESSAGE_ERROR_INVALID_EMAIL, AppResources.TEXT_OK); return; } var isConnected = CheckConnectivity(); if (!isConnected) { await DisplayAlertAsync(AppResources.TITLE_ALERT, AppResources.MESSAGE_ERROR_NO_INTERNET, AppResources.TEXT_OK); return; } await ShowLoader(true); LoginModel LoginData = new LoginModel(); LoginData.Email = Email; LoginData.Password = Password; LoginData.DeviceOSType = "No Device"; LoginData.DeviceToken = ""; LoginData.DeviceUDID = ""; var result = await LoginService.Login(LoginData); if (result != null) { if (result.Errors.Count > 0) { await ClosePopup(); await DisplayAlertAsync(AppResources.TITLE_ERROR, AppResources.MESSAGE_ERROR_EMAIL_PASSWORD_ERROR, AppResources.TEXT_OK); } else { await ClosePopup(); SettingsService.LoggedInUserEmail = result.Email; Debug.WriteLine($"Logged In User : {result.Email}"); SessionService.AutoLogin(); } } else { await ClosePopup(); await DisplayAlertAsync(AppResources.TITLE_ERROR, AppResources.MESSAGE_ERROR_EMAIL_PASSWORD_ERROR, AppResources.TEXT_OK); } } catch (Exception ex) { TelemetryService.Instance.Record(ex); } }