コード例 #1
0
        public static async Task Login(ChatsViewController thisView, string inputEmail, string inputPassword)
        {
            bool done = false;

            AppData.auth.SignInWithPassword(inputEmail, inputPassword, async(user, error) =>
            {
                if (error != null)
                {
                    AlertShow.Alert(thisView, "Error", "The following Error has occured: " + error.ToString());
                    return;
                }

                UserClass newUser = new UserClass
                {
                    Name  = user.User.DisplayName,
                    Uid   = user.User.Uid,
                    Email = user.User.Email
                };

                SetLocalUser.Set(newUser);


                await thisView.ReloadData();
                AlertShow.Alert(thisView, "Login Was Successful", "Welcome back " + newUser.Name);

                done = true;
            });
            while (!done)
            {
                await Task.Delay(50);
            }
        }
コード例 #2
0
ファイル: RegisterClass.cs プロジェクト: tiffvan/Coder
        public static async Task Register(ChatsViewController thisView, string inputName, string inputEmail, string inputPassword)
        {
            bool done = false;

            AppData.auth.CreateUser(inputEmail, inputPassword, (user, error) =>
            {
                if (error != null)
                {
                    AlertShow.Alert(thisView, "Error", "This went wrong: " + error.UserInfo.Description);
                    return;
                }

                UserProfileChangeRequest changeRequest = user.User.ProfileChangeRequest();
                changeRequest.DisplayName = inputName;

                changeRequest.CommitChanges(async(profileError) =>
                {
                    if (profileError != null)
                    {
                        AlertShow.Alert(thisView, "Error", "Profile Error: " + profileError);
                        return;
                    }

                    SetLocalUser.Set(new UserClass
                    {
                        Name  = user.User.DisplayName,
                        Email = user.User.Email,
                        Uid   = user.User.Uid
                    });

                    object[] userKeys = { "name", "email", "uid" };
                    object[] userVals = { user.User.DisplayName, user.User.Email, user.User.Uid };

                    var userDict = NSDictionary.FromObjectsAndKeys(userVals, userKeys);

                    AppData.UsersNode.GetChild(user.User.Uid).SetValue <NSDictionary>(userDict);

                    foreach (ChatListClass any in AppData.currentLST)
                    {
                        if (any.ChatOwner.Uid == AppData.curUser.Uid)
                        {
                            SaveListOnCloud.Save(any);
                        }
                    }

                    await thisView.ReloadData();

                    AlertShow.Alert(thisView, "Success", "You are now registered on Coder");

                    done = true;
                });
            });

            while (!done)
            {
                await Task.Delay(50);
            }
        }
コード例 #3
0
ファイル: LogoutClass.cs プロジェクト: tiffvan/Coder
        public static async void Logout(ChatsViewController thisView)
        {
            NSError error;

            bool signedOut = AppData.auth.SignOut(out error);

            if (signedOut)
            {
                AlertShow.Alert(thisView, "Loged Out", "You can still work offline");
                await thisView.ReloadData();
            }
            else
            {
                AlertShow.Alert(thisView, "Error", error.ToString());
            }
        }