Example #1
0
        public async void OnAuthCompleted(object sender, AuthenticatorCompletedEventArgs e)
        {
            if (sender is OAuth2Authenticator authenticator)
            {
                authenticator.Completed -= OnAuthCompleted;
                authenticator.Error     -= OnAuthError;
            }

            if (e.IsAuthenticated)
            {
                User user = null;
                switch (loginFrom)
                {
                case Constants.FROM_GOOGLE:
                    user = await GetGoogleUserInfo(e.Account);

                    break;

                case Constants.FROM_FACEBOOK:
                    user = await GetFacebookUserInfo(e.Account);

                    break;
                }

                if (account != null)
                {
                    store.Delete(account, Constants.AppName);
                }

                await store.SaveAsync(account = e.Account, Constants.AppName);

                // salva dados do usuário na base de dados local
                App.usrCorrente = await UsuariosBD.InsereAtualizaUsuario(user, loginFrom);

                // mostra página inicial
                await App.MostrarPaginaInicial();
            }
        }