public static bool PermisosConfirmar( string title, string action, string permissionName) { if (!Roles.IsUserInRole(Properties.Settings.Default.UsuarioNombre, "admin")) { if (Main.CheckUserPermission(Properties.Settings.Default.WsirConnectionString, Properties.Settings.Default.UsuarioNombre, permissionName, false)) { return(true); } } bool IsAuthenticated = false; if (String.IsNullOrEmpty(action)) { action = "Need permission to do this!"; } Login2 dlg = new Login2(Properties.Settings.Default.TouchOriented, true, title, action); //, "Confirm your authenticity please"); dlg.Usuario = Properties.Settings.Default.LoginUsuarioNombre; dlg.Recuerdame = Properties.Settings.Default.LoginUsuarioRecuerdame; //dlg.IsAuthenticated = true; //IsAuthenticated; dlg.ShowDialog(); IsAuthenticated = dlg.IsAuthenticated; if (IsAuthenticated) { //is an admin? if (!Roles.IsUserInRole(dlg.Usuario, "admin")) { //has that permission in particular? //Dictionary<string, bool> permisos = null; // = new Dictionary<string, bool>(); if (! //Funciones.PermisosObtener_Leer(Properties.Settings.Default.WsirConnectionString, ref permisos, permissionName, dlg.Usuario, "", false)) Main.CheckUserPermission(Properties.Settings.Default.WsirConnectionString, dlg.Usuario, permissionName, false)) { IsAuthenticated = false; } } } if (!IsAuthenticated) { MessageBox.Show("Sorry! You don't have the permission to do this, cannot continue!"); return(false); } dlg.Dispose(); dlg = null; return(true); }
private bool OpenBottleDropLogin() { var bdLoginForm = new Login2(Properties.Settings.Default.TouchOriented, false, "", "Please verify your BottleDrop Login"); bdLoginForm.BottleDrop = true; bdLoginForm.Recuerdame = false; bool auth; bdLoginForm.ShowDialog(); auth = bdLoginForm.IsAuthenticated; bdLoginForm.Dispose(); return(auth); }
public static void LogOff(ref ToolStripStatusLabel labelUser) { //hacer logout si el usuario estaba conectado if (Main.IsAuthenticated) { DialogResult result = MessageBox.Show("Do you want to log out?", "", MessageBoxButtons.YesNo); if (result != System.Windows.Forms.DialogResult.Yes) { return; } //toolStripStatusLabelUserName.Text = String.Empty; labelUser.Text = String.Empty; Main.IsAuthenticated = false; Login2 dlg = new Login2(Properties.Settings.Default.TouchOriented, false, "Login", "Enter your credentials please"); dlg.Usuario = Properties.Settings.Default.LoginUsuarioNombre; dlg.Recuerdame = Properties.Settings.Default.LoginUsuarioRecuerdame; dlg.IsAuthenticated = Main.IsAuthenticated; dlg.ShowDialog(); Properties.Settings.Default.LoginUsuarioNombre = dlg.Usuario; Properties.Settings.Default.LoginUsuarioRecuerdame = dlg.Recuerdame; Main.IsAuthenticated = dlg.IsAuthenticated; Properties.Settings.Default.UsuarioNombre = dlg.Usuario; Properties.Settings.Default.Save(); //salimos si no hay usuario en sesion if (!Main.IsAuthenticated) { Application.Exit(); //Close(); } //toolStripStatusLabelUserName.Text = dlg.Usuario; // User.Trim();// +"."; labelUser.Text = dlg.Usuario; //change clerkname in customerScreen if any if (Main.CustomerScreenForm != null) { Main.CustomerScreenForm.toolStripStatusLabelUser.Text = dlg.Usuario; } dlg.Dispose(); dlg = null; } }