Esempio n. 1
0
 public void SetCurrentUser(JMMUser user)
 {
     CurrentUser       = user;
     Username          = CurrentUser.Username;
     IsAdminUser       = CurrentUser.IsAdmin == 1;
     UserAuthenticated = true;
 }
Esempio n. 2
0
        public bool AuthenticateUser(string username, string password)
        {
            JMMUser retUser = Instance.ShokoServices.AuthenticateUser(username, password);

            if (retUser != null)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 3
0
        public bool PromptUserLogin()
        {
            GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return(true);
            }

            //keep showing the dialog until the user closes it
            int selectedLabel;

            dlg.Reset();
            dlg.SetHeading(Translation.SelectUser);

            if (CurrentUser != null)
            {
                string msgCurUser = string.Format(Translation.CurrentUser, CurrentUser.Username);

                dlg.Add(msgCurUser);
                dlg.Add("--------");
                dlg.Add(">> " + Translation.LogOut);
            }

            List <JMMUser> allUsers = ShokoServerHelper.GetAllUsers();

            foreach (JMMUser user in allUsers)
            {
                dlg.Add(user.Username);
            }

            dlg.DoModal(GUIWindowManager.ActiveWindow);
            selectedLabel = dlg.SelectedLabel;

            if (selectedLabel < 0)
            {
                return(false);
            }
            if (CurrentUser != null)
            {
                selectedLabel = selectedLabel - 3;
            }

            if (dlg.SelectedLabelText == ">> " + Translation.LogOut)
            {
                LogOut(true);
                return(false);
            }
            JMMUser selUser = allUsers[selectedLabel];


            BaseConfig.MyAnimeLog.Write("Selected user label: " + selectedLabel);

            // try and auth user with a blank password

            bool   authed   = AuthenticateUser(selUser.Username, "");
            string password = "";

            while (!authed)
            {
                // prompt user for a password
                if (Utils.DialogText(ref password, true, GUIWindowManager.ActiveWindow))
                {
                    authed = AuthenticateUser(selUser.Username, password);
                    if (!authed)
                    {
                        Utils.DialogMsg(Translation.Error, Translation.IncorrectPasswordTryAgain);
                    }
                }
                else
                {
                    return(false);
                }
            }

            SetCurrentUser(selUser);

            return(true);
        }