Пример #1
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                FirebaseObject <CustomerAccount> user = await getUserFromFirebase(model.Email);

                if (user != null)
                {
                    ViewBag.Error = "This e mail address is used";
                    return(View());
                }
                var          firebase     = CustomAuth.firebase;
                FirebaseAuth firebaseAuth = new FirebaseAuth();
                var          authProvider = new FirebaseAuthProvider(new FirebaseConfig("AIzaSyBffXQCMpQYkqD1P6WKymTUd2LkfccU2TU"));
                try
                {
                    var auth = await authProvider.CreateUserWithEmailAndPasswordAsync(model.Email, model.Password);

                    CustomerAccount userModel = new CustomerAccount
                    {
                        EMail       = model.Email,
                        Pwd         = model.Password,
                        PhoneNumber = model.PhoneNumber,
                        Name        = "",
                        Surname     = "",
                        UserName    = model.Email,
                        Role        = "",
                    };
                    await firebase.Child("UserAccount").PostAsync(userModel);

                    return(RedirectToAction("Login", "Account"));
                }
                catch (Exception)
                {
                    ViewBag.Error = "Can not use this e mail address";
                    return(View(model));
                }
            }
            ViewBag.Error = "Username or password is not valid";
            return(View(model));
        }
Пример #2
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.logInLayout);
            Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);

            mButtuonSignUp = FindViewById <Button>(Resource.Id.registerButton);
            buttonSignIn   = FindViewById <Button>(Resource.Id.Loginbutton);
            progressBar    = FindViewById <ProgressBar>(Resource.Id.progressBar1);
            activityLogin  = FindViewById <LinearLayout>(Resource.Layout.logInLayout);

            progressBar.Visibility = ViewStates.Invisible;

            InitFirebaseAuth();

            con.db.CreateTable <User>();
            con.db.CreateTable <carDetailsSQL>();
            con.db.CreateTable <orders>();

            if (IsOnline())
            {
                updateServices();
                FirebaseUser user = FirebaseAuth.GetInstance(app).CurrentUser;

                if (user != null)
                {
                    checkIfRememberMeIsChecked();
                }
                if (login_rememberMe && user != null && IsOnline())
                {
                    updateServices();
                    Intent intent = new Intent(this, typeof(MainActivity));
                    StartActivity(intent);
                    this.FinishAffinity();
                }
            }

            mButtuonSignUp.Click += MButtuonSignUp_Click;
            buttonSignIn.Click   += ButtonSignIn_Click;
        }
Пример #3
0
        private void BtnRegister_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(InputName.Text) && string.IsNullOrWhiteSpace(InputName.Text))
            {
                InputName.Error = "Please provide your name";
                return;
            }
            if (string.IsNullOrEmpty(InputSurname.Text) && string.IsNullOrWhiteSpace(InputSurname.Text))
            {
                InputSurname.Error = "Please provide your surname";
                return;
            }

            if (string.IsNullOrEmpty(InputEmail.Text) && string.IsNullOrWhiteSpace(InputEmail.Text))
            {
                InputEmail.Error = "Please provide your email";//, ToastLength.Long).Show();
                return;
            }
            if (string.IsNullOrEmpty(InputPhoneNumber.Text) && string.IsNullOrWhiteSpace(InputPhoneNumber.Text))
            {
                InputPhoneNumber.Error = "Please provide your phone number";//, ToastLength.Long).Show();
                return;
            }
            if (string.IsNullOrEmpty(InputPassword.Text) && string.IsNullOrWhiteSpace(InputPassword.Text))
            {
                InputPassword.Error = "Please provide your password";
                return;
            }

            BtnRegister.Enabled = false;
            loadingDialog       = new IonAlert(context, IonAlert.ProgressType);
            loadingDialog.SetSpinKit("WanderingCubes")
            .SetSpinColor("#008D91")
            .ShowCancelButton(false)
            .Show();
            auth = FirebaseAuth.Instance;
            auth.CreateUserWithEmailAndPassword(InputEmail.Text.Trim(), InputPassword.Text.Trim())
            .AddOnFailureListener(this)
            .AddOnSuccessListener(this)
            .AddOnCompleteListener(this);
        }
Пример #4
0
    public void firebaseSignup()
    {
        int classes = Convert.ToInt32(std);

        classes             = classes - 1;
        databaseRefForClass = databaseRefForClass.Child(classes.ToString());
        databaseRefForClass = databaseRefForClass.Child("Students");
        FirebaseAuth auth = FirebaseAuth.DefaultInstance;

        auth.CreateUserWithEmailAndPasswordAsync(email, password).ContinueWith(task =>
        {
            if (task.IsCompleted)
            {
                databaseReference.Child(task.Result.UserId).Child("email").SetValueAsync(email);
                databaseReference.Child(task.Result.UserId).Child("name").SetValueAsync(userName);
                databaseReference.Child(task.Result.UserId).Child("class").SetValueAsync(std);
                databaseReference = databaseReference.Child(task.Result.UserId).Child("Characters");

                databaseReference.Child("1").Child("level").SetValueAsync(1);
                databaseReference.Child("1").Child("has").SetValueAsync(0);
                databaseReference.Child("1").Child("required").SetValueAsync(20);

                databaseReference.Child("2").Child("level").SetValueAsync(1);
                databaseReference.Child("2").Child("has").SetValueAsync(0);
                databaseReference.Child("2").Child("required").SetValueAsync(20);

                databaseReference.Child("3").Child("level").SetValueAsync(1);
                databaseReference.Child("3").Child("has").SetValueAsync(0);
                databaseReference.Child("3").Child("required").SetValueAsync(20);

                databaseReference.Child("4").Child("level").SetValueAsync(1);
                databaseReference.Child("4").Child("has").SetValueAsync(0);
                databaseReference.Child("4").Child("required").SetValueAsync(20);

                databaseRefForClass.Child(task.Result.UserId).Child("name").SetValueAsync(userName);
                databaseRefForClass.Child(task.Result.UserId).Child("email").SetValueAsync(email);

                SceneManager.LoadScene("MainScreen");
            }
        });
    }
Пример #5
0
        private void InitializeFirebase()
        {
            var app = FirebaseApp.InitializeApp(this);

            if (app == null)
            {
                var options = new FirebaseOptions.Builder()
                              .SetApplicationId("uber-clone-a1c9b")
                              .SetApiKey("AIzaSyA_iDmRc4MUWwvUuPxlus7NyywRSzah0IA")
                              .SetDatabaseUrl("https://uber-clone-a1c9b.firebaseio.com")
                              .SetStorageBucket("uber-clone-a1c9b.appspot.com")
                              .Build();

                app   = FirebaseApp.InitializeApp(this, options);
                mAuth = FirebaseAuth.Instance;
            }
            else
            {
                mAuth = FirebaseAuth.Instance;
            }
        }
Пример #6
0
        public async Task <bool> LoginWithFirebaseFB(string token)
        {
            firebaseAuth = FirebaseAuth.Instance;

            bool isLoggin    = false;
            var  credentials = FacebookAuthProvider.GetCredential(token);

            await firebaseAuth.SignInWithCredentialAsync(credentials).ContinueWith(task =>
            {
                if (task.IsCompletedSuccessfully)
                {
                    isLoggin = true;
                }
                else
                {
                    isLoggin = false;
                }
            });

            return(isLoggin);
        }
Пример #7
0
        public async Task UseAfterDelete()
        {
            var app = FirebaseApp.Create(new AppOptions()
            {
                Credential = MockCredential
            });
            FirebaseAuth auth = FirebaseAuth.DefaultInstance;

            app.Delete();
            await Assert.ThrowsAsync <InvalidOperationException>(
                async() => await auth.CreateCustomTokenAsync("user"));

            await Assert.ThrowsAsync <InvalidOperationException>(
                async() => await auth.VerifyIdTokenAsync("user"));

            await Assert.ThrowsAsync <InvalidOperationException>(
                async() => await auth.SetCustomUserClaimsAsync("user", null));

            await Assert.ThrowsAsync <InvalidOperationException>(
                async() => await auth.GetOidcProviderConfigAsync("oidc.provider"));
        }
        private void Initialize(IServiceAccountCredentials credentials)
        {
            var creds = credentials ?? throw new ArgumentNullException(nameof(credentials));

            Auth = new FirebaseAuth(creds, Configuration);

            if (FirebaseServiceAccess.Database == (Configuration.RequestedAccess & FirebaseServiceAccess.Database))
            {
                Database = new FirebaseDatabase(creds, Configuration);
            }

            if (FirebaseServiceAccess.Storage == (Configuration.RequestedAccess & FirebaseServiceAccess.Storage))
            {
                Storage = new FirebaseStorage(creds, Configuration);
            }

            if (FirebaseServiceAccess.CloudMessaging == (Configuration.RequestedAccess & FirebaseServiceAccess.CloudMessaging))
            {
                CloudMessaging = new FirebaseCloudMessaging(creds, Configuration);
            }
        }
        void InitialFirebase()
        {
            var app = FirebaseApp.InitializeApp(this);

            if (app == null)
            {
                var options = new FirebaseOptions.Builder()
                              .SetApplicationId("uberclone-6596f")
                              .SetApiKey("AIzaSyAXqLpF_JVINHqrS74X_r6uMG8wW5EZlzs")
                              .SetDatabaseUrl("https://uberclone-6596f.firebaseio.com")
                              .SetStorageBucket("uberclone-6596f.appspot.com")
                              .Build();

                app   = FirebaseApp.InitializeApp(this, options);
                mAuth = FirebaseAuth.Instance;
            }
            else
            {
                mAuth = FirebaseAuth.Instance;
            }
        }
Пример #10
0
        void InitializeFirebase()
        {
            var app = FirebaseApp.InitializeApp(this);

            if (app == null)
            {
                var options = new FirebaseOptions.Builder()
                              .SetApplicationId("fura-8ceb6")
                              .SetApiKey("AIzaSyDjfL4fliMr75o2NY_WYdh5iOuUuZRYBpU")
                              .SetDatabaseUrl("https://fura-8ceb6.firebaseio.com")
                              .SetStorageBucket("fura-8ceb6.appspot.com")
                              .Build();

                app   = FirebaseApp.InitializeApp(this, options);
                mAuth = FirebaseAuth.Instance;
            }
            else
            {
                mAuth = FirebaseAuth.Instance;
            }
        }
Пример #11
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Login);
            auth = FirebaseAuth.Instance;

            // InitFirebaseAuth();
            loginbutt   = FindViewById <Button>(Resource.Id.loginButt);
            loginmail   = FindViewById <EditText>(Resource.Id.LoginMatno);
            loginpass   = FindViewById <EditText>(Resource.Id.loginPass);
            forgotpass  = FindViewById <TextView>(Resource.Id.loginForgotpass);
            signup      = FindViewById <TextView>(Resource.Id.loginSignup);
            pgblogin    = FindViewById <ProgressBar>(Resource.Id.loginpgb);
            emaillay    = FindViewById <TextInputLayout>(Resource.Id.textInputLayout1);
            passlay     = FindViewById <TextInputLayout>(Resource.Id.textInputLayout2);
            loginHolder = FindViewById <LinearLayout>(Resource.Id.loginHolder);
            loginbutt.SetOnClickListener(this);
            forgotpass.SetOnClickListener(this);
            signup.SetOnClickListener(this);
            connectivityManager = (ConnectivityManager)GetSystemService(ConnectivityService);
        }
Пример #12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Settings);

            // initialize firebase auth instance
            auth = AuthHelper.GetInstance(this).GetAuth();

            // bind views to variables
            activity_root = FindViewById <LinearLayout>(Resource.Id.settings_root);
            input_pwd     = FindViewById <EditText>(Resource.Id.settings_newpassword);
            btnChangePass = FindViewById <Button>(Resource.Id.settings_btn_change_pass);
            btnClear      = FindViewById <Button>(Resource.Id.settings_clear);
            username_view = FindViewById <TextView>(Resource.Id.settings_username);

            username_view.SetText(auth.CurrentUser.Email, TextView.BufferType.Normal);

            // set on click listeners
            btnChangePass.SetOnClickListener(this);
            btnClear.SetOnClickListener(this);
        }
Пример #13
0
 private void CheckFirebaseDependencies()
 {
     FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
     {
         if (task.IsCompleted)
         {
             if (task.Result == DependencyStatus.Available)
             {
                 auth = FirebaseAuth.DefaultInstance;
             }
             else
             {
                 Debug.Log("Could not resolve all Firebase depen debcies : " + task.Result.ToString());
             }
         }
         else
         {
             Debug.Log("Dependency check was not completed. Error : " + task.Exception.Message);
         }
     });
 }
Пример #14
0
        Persistence()
        {
            // Set-Up Database
            FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://the-morals-game.firebaseio.com/");
            _root = FirebaseDatabase.DefaultInstance.RootReference;
            _auth = FirebaseAuth.DefaultInstance;

            var instanceCaller = new Thread(TrySignIn);

            instanceCaller.Start();

            // Initialize Data
            data = new AppData()
            {
                gameData     = new AppData.GameData(),
                postPollData = new AppData.QuestionarieData(),
                prePollData  = new AppData.QuestionarieData(),
                userData     = new AppData.UserData()
            };
            _lastSavedData = data;
        }
Пример #15
0
    // Start is called before the first frame update
    void Start()
    {
        FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
        {
            FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);
        });

        /*#if PLATFORM_ANDROID
         *
         * if (!Permission.HasUserAuthorizedPermission(Permission.ExternalStorageRead) || !Permission.HasUserAuthorizedPermission(Permission.ExternalStorageWrite))
         * {
         *  Permission.RequestUserPermission(Permission.ExternalStorageWrite);
         *
         * }
         *
         #endif*/

        _auth = FirebaseAuth.DefaultInstance;

        FirebaseAuth.DefaultInstance.StateChanged += HandleAuthStateChanged;
    }
Пример #16
0
    public void IniciarFirebase()
    {
        FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
            var dependencyStatus = task.Result;

            if (dependencyStatus == DependencyStatus.Available)
            {
                Debug.Log("Verificação concluída, Firebase ativado");

                auth = FirebaseAuth.DefaultInstance;

                auth.StateChanged += AuthStateChanged;
                AuthStateChanged(this, null);
            }

            else
            {
                Debug.LogError(System.String.Format("Não foi possível resolver todas as dependências do Firebase: {0}", dependencyStatus));
            }
        });
    }
 public static async Task <bool> FirebaseAuthWithFacebook(FirebaseAuth firebaseAuth, AccessToken fbUserToken)
 {
     try
     {
         if (Connectivity.NetworkAccess == NetworkAccess.Internet)
         {
             using (AuthCredential credential = FacebookAuthProvider.GetCredential(fbUserToken.Token))
             {
                 using (IAuthResult result = await firebaseAuth.SignInWithCredentialAsync(credential))
                 {
                     return(result != null && result.User != null);
                 }
             }
         }
     }
     catch (Exception e)
     {
         Crashlytics.Crashlytics.LogException(Java.Lang.Throwable.FromException(e));
     }
     return(false);
 }
Пример #18
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            view = inflater.Inflate(Resource.Layout.personalInfo, container, false);

            userInput_ime     = view.FindViewById <EditText>(Resource.Id.PIinputIme);
            userInput_prezime = view.FindViewById <EditText>(Resource.Id.PIinputPrezime);
            userInput_email   = view.FindViewById <EditText>(Resource.Id.PIinputEmail);
            userInput_broj    = view.FindViewById <EditText>(Resource.Id.PIinputBrojTelefona);
            userInput_mjesto  = view.FindViewById <EditText>(Resource.Id.PIinputMjesto);
            userInpu_ulicaibr = view.FindViewById <EditText>(Resource.Id.PIinputUlicaIBroj);
            save = view.FindViewById <Button>(Resource.Id.savePersonalInfo);

            var auth = FirebaseAuth.GetInstance(loginActivity.app).CurrentUser;

            id = auth.Uid;

            getUserData();

            save.Click += Save_ClickAsync;
            return(view);
        }
Пример #19
0
 public void InitializeFirebase()
 {
     FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task =>
     {
         var dependencyStatus = task.Result;
         if (dependencyStatus == Firebase.DependencyStatus.Available)
         {
             app  = FirebaseApp.DefaultInstance;
             auth = FirebaseAuth.DefaultInstance;
             root = FirebaseDatabase.DefaultInstance;
             Debug.Log("firebase initialized");
             onFirebaseInitialized();
         }
         else
         {
             Debug.LogError(System.String.Format(
                                "Could not resolve all Firebase dependencies: {0}", dependencyStatus));
             // Firebase Unity SDK is not safe to use here.
         }
     });
 }
Пример #20
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.Registration);

            //Initialize Firebase
            auth = FirebaseAuth.GetInstance(MainActivity.app);
            database = FirebaseDatabase.GetInstance(MainActivity.app);

            //Initialize layout views
            btn_register = FindViewById<Button>(Resource.Id.btn_register);
            input_email = FindViewById<EditText>(Resource.Id.register_email);
            input_password = FindViewById<EditText>(Resource.Id.register_password);
            input_name = FindViewById<EditText>(Resource.Id.register_name);
            activity_register = FindViewById<RelativeLayout>(Resource.Id.activity_register);
            SpinnerInit();
            btn_register.SetOnClickListener(this);
            SetEditing(true);
        }
Пример #21
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.SignUp);

            // initializing firebase auth
            auth = AuthHelper.GetInstance(this).GetAuth();

            // binding the views
            btnSignup        = FindViewById <Button>(Resource.Id.signup_btn_register);
            btnLogin         = FindViewById <TextView>(Resource.Id.signup_btn_login);
            btnForgotPass    = FindViewById <TextView>(Resource.Id.signup_btn_forgot_password);
            input_email      = FindViewById <EditText>(Resource.Id.signup_email);
            input_password   = FindViewById <EditText>(Resource.Id.signup_password);
            activity_sign_up = FindViewById <RelativeLayout>(Resource.Id.activity_sign_up);

            // setting on click listeners
            btnLogin.SetOnClickListener(this);
            btnForgotPass.SetOnClickListener(this);
            btnSignup.SetOnClickListener(this);
        }
Пример #22
0
        //---------------------------------------------------------------------
        // Messages
        //---------------------------------------------------------------------

        private void Awake()
        {
            ConfigureGoogleSignIn();
            _auth = FirebaseAuth.DefaultInstance;

            if (!FB.IsInitialized)
            {
                FB.Init();
            }
            else
            {
                FB.ActivateApp();
            }

            if (_auth.CurrentUser != null && GetSocial.User.IsAnonymous)
            {
                GetSocialSignIn();
            }

            SetGetSocialNameAndAvatar();
        }
Пример #23
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Editprofile);
            var toolbareditprofile = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbarEditProfile);

            SetSupportActionBar(toolbareditprofile);
            MaterialMenuDrawable materialMenu = new MaterialMenuDrawable(this, Color.Purple, (int)stroke.EXTRA_THIN, MaterialMenuDrawable.DefaultScale, MaterialMenuDrawable.DefaultTransformDuration);

            materialMenu.SetIconState(MaterialMenuDrawable.IconState.Arrow);
            toolbareditprofile.NavigationIcon   = materialMenu;
            toolbareditprofile.NavigationClick += delegate {
                OnBackPressed();
                Finish();
            };

            editname       = FindViewById <EditText>(Resource.Id.editname);
            edittitle      = FindViewById <EditText>(Resource.Id.edittitle);
            editemail      = FindViewById <TextView>(Resource.Id.editEmail);
            editstaffid    = FindViewById <TextView>(Resource.Id.editStaffID);
            editcollege    = FindViewById <TextView>(Resource.Id.editCollege);
            editdepartment = FindViewById <TextView>(Resource.Id.editDepartment);
            editHolder     = FindViewById <CardView>(Resource.Id.editCard);
            editpgb        = FindViewById <ProgressBar>(Resource.Id.editprofilepgb);
            edittextEdit   = FindViewById <TextView>(Resource.Id.editprofileEdit);
            auth           = FirebaseAuth.Instance;
            curruser       = "******"" + auth.CurrentUser.Email.ToString() + "\"";

            new GetProfileSpecifictDataEdit(this).Execute(Common.getAddresApiProfilespecifictitle(curruser));

            edittextEdit.Click += delegate
            {
                new EditProfileData(profileList[0], editname.Text.ToString(), edittitle.Text.ToString(), this).Execute(Common.getAddressSingleProfile(profileList[0]));
                StartActivity(typeof(SettingsActivity));
                Finish();
            };


            // Create your application here
        }
Пример #24
0
    private void AuthCallback(ILoginResult result)
    {
        if (FB.IsLoggedIn)
        {
            FirebaseAuth auth =
                FirebaseAuth.DefaultInstance;

            // AccessToken class will have session details
            var aToken = AccessToken.CurrentAccessToken;
            // Print current access token's User


            Credential credential = FacebookAuthProvider.GetCredential(aToken.TokenString);
            auth.SignInWithCredentialAsync(credential).ContinueWith(task => {
                if (task.IsCanceled)
                {
                    Debug.LogError("SignInWithCredentialAsync was canceled.");
                    return;
                }
                if (task.IsFaulted)
                {
                    Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
                    return;
                }
                if (task.IsCompleted)
                {
                    user = task.Result;
                    writeNewUser(user.UserId, user.DisplayName, user.Email, aToken.UserId);
                }
            });
            FacebookLoginButton.interactable = false;
            GuestLoginButton.interactable    = false;
        }
        else
        {
            FacebookLoginButton.interactable = true;
            GuestLoginButton.interactable    = true;
            Debug.Log("User cancelled login");
        }
    }
Пример #25
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            // Authentication Activity is started (on app open).
            base.OnCreate(savedInstanceState);
            // The view is set to the Authentication_Layout.
            SetContentView(Resource.Layout.Authentication_Layout);

            // Get the current user.
            auth = FirebaseAuth.Instance;
            user = auth.CurrentUser;

            if (user != null)
            {
                // If user already exists, they are already signed in.
                // Start the MainActivity.
                StartActivity(new Android.Content.Intent(this, typeof(MainActivity)).SetFlags(Android.Content.ActivityFlags.NoAnimation));
                Finish();
                return;
            }

            // Otherwise, continue to obtain the ImageButton btnlogin from the resources.
            ImageButton btnLogin = FindViewById <ImageButton>(Resource.Id.btnLogin);

            btnLogin.Click += delegate
            {
                // On btnLogin click, open a WebView (with the Steam URL).
                SetContentView(Resource.Layout.WebView_Layout);
                webView = FindViewById <WebView>(Resource.Id.webView);
                string steam_url = "https://steamcommunity.com/openid/login?openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&openid.identity=http://specs.openid.net/auth/2.0/identifier_select&openid.mode=checkid_setup&openid.ns=http://specs.openid.net/auth/2.0&openid.realm=https://clanbutton&openid.return_to=https://clanbutton/signin/";
                webView.Visibility = ViewStates.Visible;
                ExtendedWebViewClient webClient = new ExtendedWebViewClient();
                webClient.steamAuthentication = this;
                webView.SetWebViewClient(webClient);
                webView.LoadUrl(steam_url);

                // Allow JavaScript to be used in the WebView.
                WebSettings webSettings = webView.Settings;
                webSettings.JavaScriptEnabled = true;
            };
        }
Пример #26
0
        public async Task <User> LoginGoogle()
        {
            gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn)
                  .RequestIdToken("216415232228-vsuoihg6h9i13p7vl0kdosaj6jl84k67.apps.googleusercontent.com")
                  .RequestEmail()
                  .Build();

            client = new GoogleApiClient.Builder(MainActivity.ActivityContext)
                     .AddApi(Auth.GOOGLE_SIGN_IN_API, gso)
                     .Build();

            client.Connect();

            firebaseAuth = FirebaseAuth.Instance;

            GoogleSignInResult result = await OpenGoogleLogin();

            if (result.IsSuccess)
            {
                GoogleSignInAccount account = result.SignInAccount;
                var resultado = await LoginWithFirebase(account);

                if (resultado)
                {
                    User user = new User();
                    user.FirstName = account.GivenName;
                    user.LastName  = account.FamilyName;
                    user.Email     = firebaseAuth.CurrentUser.Email;
                    return(user);
                }
                else
                {
                    return(new User());
                }
            }
            else
            {
                return(new User());
            }
        }
Пример #27
0
        //initializer
        private AppData(Context thisContext)
        {
            currentLists = new List <GroceryListClass>();

            var options = new Firebase.FirebaseOptions.Builder()
                          .SetApplicationId("1:269645497682:android:41aae10df759a3e12da68b")
                          .SetApiKey("AIzaSyDrsPpcJX-o6wnrhbfY5PbOW5frpoNE2MA")
                          .Build();

            if (fireApp == null)
            {
                fireApp = FirebaseApp.InitializeApp(thisContext, options);
            }

            auth = FirebaseAuth.GetInstance(fireApp);

            string         FirebaseURL = "https://groceries-project.firebaseio.com";
            FirebaseClient rootNode    = new FirebaseClient(FirebaseURL);

            dataNode  = rootNode.Child("data");
            usersNode = rootNode.Child("users");
        }
Пример #28
0
    public LoginService()
    {
        OnEvent += (o, e) =>
        {
            if (e is AuthLoginEvent)
            {
                OnLoginEvent(this, (AuthLoginEvent)e);
            }
            else if (e is AuthLogoutEvent)
            {
                OnLogoutEvent(this, (AuthLogoutEvent)e);
            }
        };
        OnLoginEvent  += (o, e) => Debug.Log("Signed in " + e.User.UserId);
        OnLogoutEvent += (o, e) => Debug.Log("Signed out " + e.User.UserId);
        // Retrieve default auth instance based on config file
        auth = FirebaseAuth.DefaultInstance;

        // attach state change listener for login and logout events
        auth.StateChanged += AuthStateChanged;
        User = auth.CurrentUser;
    }
Пример #29
0
    IEnumerator Login()
    {
        while (System.String.IsNullOrEmpty(((PlayGamesLocalUser)Social.localUser).GetIdToken()))
        {
            yield return(null);
        }

        string idToken = ((PlayGamesLocalUser)Social.localUser).GetIdToken();

        auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
        Credential credential = Firebase.Auth.GoogleAuthProvider.GetCredential(idToken, null);

        auth.SignInWithCredentialAsync(credential).ContinueWith(
            task =>
        {
            if (task.IsFaulted)
            {
                Debug.Log("구글 로그인에 실패하였습니다.");
            }
            else if (task.IsCanceled)
            {
                Debug.Log("구글 로그인이 취소되었습니다.");
            }
            else if (task.IsCompleted)
            {
                Debug.Log("Task NewUser OK");
                // User is now signed in.
                FirebaseUser newUser  = task.Result;
                GameObject controller = GameObject.Find("Controller");
                // Get the root reference location fo Database
                user_Name = newUser.DisplayName;
                user_ID   = newUser.UserId;
                Debug.Log("USER NAME : " + user_Name + ", USER EMAIL : " + newUser.Email + ", USER ID : " + newUser.UserId);
                user_Ref.Child("users").Child(newUser.UserId).Child("name").SetValueAsync(user_Name);
                controller.GetComponent <ARSurvive.ARController>().StartMenu();
            }
        });
        Debug.Log("Login END. Check User");
    }
    // Sign in to Firebase
    private void SignInFirebase(Credential credential)
    {
        auth = FirebaseAuth.DefaultInstance;
        // Sign in to Firebase Authentication using credentials from providers
        auth.SignInWithCredentialAsync(credential).ContinueWith(task =>
        {
            if (task.IsCanceled)
            {
                Debug.LogError("SignInWithCredentialAsync was canceled.");
                return;
            }

            if (task.IsFaulted)
            {
                Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
                return;
            }

            user = task.Result;
            Debug.LogFormat("User signed in successfully: {0} ({1})", user.DisplayName, user.UserId);

            // Check if user has registered before
            bool registered = FirebaseHandler.CheckIfUserIsRegistered().Result;

            // Registered user
            if (registered)
            {
                Debug.Log("User has registered, proceed to home screen");
                SceneManager.LoadSceneAsync("Persistent");
            }
            // New user
            else
            {
                Debug.Log("User has not registered, proceed to username and character selection");
                FirebaseHandler.CreateNewUser(user.UserId);
                SceneManager.LoadSceneAsync("InputUsernameScreen");
            }
        });
    }