Exemple #1
0
        public ModelStatus Registration(ModelLogin packet)
        {
            if (Player != null)
            {
                return(null);
            }
            //Thread.Sleep(5000);
            var player = Repository.GetData.PlayersAll
                         .FirstOrDefault(p => p.Public.Login == packet.Login);

            if (player != null)
            {
                return(new ModelStatus()
                {
                    Status = 1,
                    Message = "This login already exists"
                });
            }
            player = new PlayerServer(packet.Login)
            {
                Pass    = packet.Pass,
                IsAdmin = Repository.GetData.PlayersAll.Count == 1
            };
            Repository.GetData.PlayersAll.Add(player);
            Repository.Get.ChangeData = true;
            Player = player;
            return(new ModelStatus()
            {
                Status = 0,
                Message = null
            });
        }
Exemple #2
0
 /// <summary>
 /// constructor, definition commands and model
 /// </summary>
 public VMMain()
 {
     Register   = new commands.cmdRegister(this);
     Login      = new commands.cmdLogin(this);
     GoBack     = new commands.CmdGoBack(this);
     modelLogin = new ModelLogin();
 }
Exemple #3
0
 public ModelLogin VerificarLogin(ModelLogin modelLogin)
 {
     try
     {
         string     instrucao = string.Format(@"SELECT Nivel, Status FROM tbLogin WHERE ID = @ID AND Senha = @Senha");
         SqlCommand command   = new SqlCommand(instrucao, controllerConfiguracaoSQL.Conectar());
         command.Parameters.AddWithValue("@ID", modelLogin.ID);
         command.Parameters.AddWithValue("Senha", modelLogin.Senha);
         SqlDataReader sqlDataReader = command.ExecuteReader();
         if (sqlDataReader.HasRows)
         {
             sqlDataReader.Read();
             modelLogin.Nivel  = sqlDataReader["Nivel"].ToString();
             modelLogin.Status = sqlDataReader["Status"].ToString();
             return(modelLogin);
         }
         return(null);
     }
     catch
     {
         throw;
     }
     finally
     {
         controllerConfiguracaoSQL.Fechar();
     }
 }
 public ActionResult Login(ModelLogin model)
 {
     if (ModelState.IsValid)
     {
         var dao    = new Users();
         var result = dao.LoginKH(model.TaiKhoan, model.MatKhau);
         if (result == 1)
         {
             var user      = dao.GetByIdKH(model.TaiKhoan);
             var khSession = new KHLogin();
             khSession.TaiKhoan = user.TAIKHOAN;
             khSession.MaKH     = user.MAKH;
             Session.Add(CommonConstants.KH_SESSION, khSession);
             return(RedirectToAction("Index", "Home"));
         }
         else if (result == 0)
         {
             ModelState.AddModelError("", "Tài khoản không tồn tại");
         }
         else if (result == -2)
         {
             ModelState.AddModelError("", "Mật khẩu không đúng");
         }
     }
     else
     {
         ModelState.AddModelError("", "Đăng nhập không đúng");
     }
     return(View(model));
 }
Exemple #5
0
 private void btnRetirar_Click(object sender, EventArgs e)
 {
     try
     {
         if (!string.IsNullOrWhiteSpace(txtValor.Text))
         {
             ModelLogin modelLogin = new ModelLogin();
             modelLogin.Nivel = "?";
             FrmLogin frmLogin = new FrmLogin(modelLogin);
             frmLogin.ShowDialog();
             if (frmLogin.Retorno == "Supervisor")
             {
                 modelSaida.Vendedor  = txtVendedor.Text;
                 modelSaida.DataSaida = txtDataSaida.Text;
                 modelSaida.Valor     = txtValor.Text;
                 decimal valorRetirada = Convert.ToDecimal(txtValor.Text);
                 if (valorCaixa >= valorRetirada && controllerSaida.InserirSaida(modelSaida))
                 {
                     MessageBox.Show("Valor: " + valorRetirada.ToString("C") + " foi retirado com sucesso!", "Alerta!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     this.Close();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #6
0
 public Boolean validingLogin(ModelLogin ml)
 {
     try
     {
         if (validingUser(ml.userName))
         {
             if (validingPass(ml.passWord))
             {
                 Register r = new Register();
                 r.Visible = true;
                 return(true);
             }
             else
             {
                 MessageBox.Show("User or Pass Incorrect");
                 return(false);
             }
         }
         else
         {
             MessageBox.Show("User or Pass Incorrect");
             return(false);
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(" " + e);
     }
     return(false);
 }
        public IActionResult Login(string returnUrl = "/")
        {
            var model = new ModelLogin();

            model.ReturnUrl = returnUrl;

            return(View(model));
        }
Exemple #8
0
 public FrmLogin(ModelLogin modelLogin)
 {
     InitializeComponent();
     if (!string.IsNullOrWhiteSpace(modelLogin.Nivel))
     {
         btnLogar.Text = "OK";
     }
 }
Exemple #9
0
 public FrmLoginLog(ModelLogin modelLogin)
 {
     InitializeComponent();
     cbxFiltro.SelectedIndex = 0;
     idTec                 = modelLogin.IDTecSistemas;
     id                    = modelLogin.ID;
     dgvLog.DataSource     = controllerLogin.CarregarLogs(modelLogin, id);
     lblExibidosTotal.Text = "Exibidos total: " + dgvLog.Rows.Count;
 }
Exemple #10
0
        public FrmCadastroLogin(ModelLogin modelLogin)
        {
            InitializeComponent();
            if (controllerTema.CarregarEnderecoImagem() != null)
            {
                pictureBox1.BackgroundImage = Image.FromFile(controllerTema.CarregarEnderecoImagem());
            }

            if (!string.IsNullOrWhiteSpace(modelLogin.Codigo))
            {
                btnCadastrar.Text = "Editar";
                Text = "Editar Login";
                lblCadastrar.Text = "Editar";
                pnlLogin.Enabled  = false;
                Codigo            = modelLogin.Codigo;
                txtID.Text        = modelLogin.ID;
                txtSenha.Text     = modelLogin.Senha;
                txtID.Enabled     = false;
                if (modelLogin.Nivel == "Administrador")
                {
                    rbAdministrador.Checked = true;
                }
                if (modelLogin.Nivel == "Secretaria")
                {
                    rbSecretaria.Checked = true;
                }
                if (modelLogin.Nivel == "Clínico")
                {
                    rbClinico.Checked = true;
                }
            }
            if (modelLogin.Consultar == true)
            {
                Text = "Consultar Login";
                lblCadastrar.Text         = "Consultar";
                btnCadastrar.Visible      = false;
                btnCancelar.Text          = "Fechar";
                txtConfirmarSenha.Visible = false;
                lblConfirmarSenha.Visible = false;
                pnlLogin.Enabled          = false;
                txtID.Text    = modelLogin.ID;
                txtSenha.Text = modelLogin.Senha;
                if (modelLogin.Nivel == "Administrador")
                {
                    rbAdministrador.Checked = true;
                }
                if (modelLogin.Nivel == "Secretaria")
                {
                    rbSecretaria.Checked = true;
                }
                if (modelLogin.Nivel == "Clínico")
                {
                    rbClinico.Checked = true;
                }
            }
        }
Exemple #11
0
        public string GetLogin(string id_login, string connectionString)
        {
            myModelLogin = new ModelLogin();
            DS_Mensagem  = myModelLogin.GetLogin(id_login, connectionString);

            DS_Usuario = myModelLogin.DS_Usuario;
            DS_Senha   = myModelLogin.DS_Senha;

            return(DS_Mensagem);
        }
Exemple #12
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            ModelLogin ml = new ModelLogin();

            ml.userName = txtUserName.Text;
            ml.passWord = txtPassWord.Text;
            CrudLogin cl = new CrudLogin();

            cl.validingLogin(ml);
        }
Exemple #13
0
        private ModelStatus registration(ModelLogin packet, ServiceContext context)
        {
            packet.Email = Repository.CheckIsIntruder(context, packet.Email, packet.Login);

            if (packet.Login.Trim().Length < 2 ||
                packet.Pass.Length < 5)
            {
                return(new ModelStatus()
                {
                    Status = 1,
                    Message = "Incorrect login or password"
                });
            }

            packet.Login   = packet.Login.Trim();
            context.Player = Repository.GetData.PlayersAll
                             .FirstOrDefault(p => Repository.NormalizeLogin(p.Public.Login) == Repository.NormalizeLogin(packet.Login));
            if (context.Player != null)
            {
                return(new ModelStatus()
                {
                    Status = 1,
                    Message = "This login already exists"
                });
            }

            var isAdmin = Repository.GetData.PlayersAll.Count == 2;// 1 : system, 2 : discord и если  в этот момент добавляетесь Вы, voilà получаете админские права

            context.Player = new PlayerServer(packet.Login)
            {
                Pass    = packet.Pass,
                IsAdmin = isAdmin,
            };
            context.Player.Public.EMail = packet.Email;

            context.Player.Public.Grants = Grants.UsualUser;
            if (isAdmin)
            {
                context.Player.Public.Grants = context.Player.Public.Grants | Grants.Moderator | Grants.SuperAdmin;
            }

            context.Logined();

            ChatManager.Instance.PublicChat.LastChanged = System.DateTime.UtcNow;
            Repository.GetData.PlayersAll.Add(context.Player);
            Repository.Get.ChangeData = true;

            return(new ModelStatus()
            {
                Status = 0,
                Message = null
            });
        }
Exemple #14
0
        public string Acessar(string ds_usuario, string connectionString)
        {
            myModelLogin = new ModelLogin();
            DS_Mensagem  = myModelLogin.Acessar(ds_usuario, connectionString);

            ID_Login            = myModelLogin.ID_Login;
            ID_Funcionario      = myModelLogin.ID_Funcionario;
            DS_NivelAcesso      = myModelLogin.DS_NivelAcesso;
            NM_FuncionarioLogin = myModelLogin.NM_FuncionarioLogin;
            DS_Senha            = myModelLogin.DS_Senha;

            return(DS_Mensagem);
        }
Exemple #15
0
        private int Get_User_Detail(string UserName, string DomainName)
        {
            ModelLogin objMdlLogin = new ModelLogin();
            string     LawsonNew   = objMdlLogin.GetLawsonIDfromGlobalNew(UserName, DomainName);
            string     GosCode     = objMdlLogin.GetGosPositionCode(LawsonNew);
            DataTable  DtRoles     = new DataTable();

            DtRoles = objMdlLogin.GetRoles(GosCode);
            int accesstoGC = Convert.ToInt32(DtRoles.Rows[0]["accessToGC"].ToString());

            return(accesstoGC);
            //return objMdlLogin.GetUserDetails(UserName, DomainName);
        }
        public async Task <IActionResult> Login(ModelLogin model)
        {
            if (HttpContext.User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (string.IsNullOrEmpty(model.User))
            {
                ModelState.AddModelError("User", "Utilizador não é valido");
            }
            if (string.IsNullOrEmpty(model.Pass))
            {
                ModelState.AddModelError("Pass", "Password não é valida");
            }

            ModelState.AddModelError("Auth", "Auth not implemented");
            // ***********************************************
            //[Database logic and password verification HERE ]
            // ***********************************************

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            const string issuer = "http://mysite.domain";
            List <Claim> claims = new List <Claim>();

            //Set User, roles and other claims
            claims.Add(new Claim("User", model.User, ClaimValueTypes.String, issuer));

            //Creating and sign in auth cookie
            var userIdentity = new ClaimsIdentity("SecureLogin");

            userIdentity.AddClaims(claims);
            var userPrincipal = new ClaimsPrincipal(userIdentity);

            await HttpContext.Authentication.SignInAsync("Cookie", userPrincipal,
                                                         new AuthenticationProperties
            {
                ExpiresUtc   = DateTime.UtcNow.AddHours(12),
                IsPersistent = false,
                AllowRefresh = false,
            });

            return(RedirectToLocal(model.ReturnUrl));
        }
Exemple #17
0
        public IActionResult Index(ModelLogin model)
        {
            model.iserror = false;
            int?id = _kullanicilar.LoginID(model.email, model.password);

            if (id != null && _kullanicilar.GetById(id).aktif == 1)
            {
                StaticValues.LoginId = id;
                return(RedirectToAction("Index", "Start", new { area = "MENU" }));
            }
            else
            {
                model.iserror = true;
                return(View(model));
            }
        }
Exemple #18
0
        static void Main()
        {
            ControllerConfiguracaoSQLCentral controllerConfiguracaoSQLCentral = new ControllerConfiguracaoSQLCentral();
            ModelConfiguracaoSQLCentral      modelConfiguracaoSQLCentral      = controllerConfiguracaoSQLCentral.Carregar();
            ControllerConfiguracaoSQL        controllerConfiguracaoSQL        = new ControllerConfiguracaoSQL();
            ModelConfiguracaoSQL             modelConfiguracaoSQL             = new ModelConfiguracaoSQL();
            string     instrucao = string.Format(@"SELECT * FROM tbCadastro WHERE idTecSistemas = '" + modelConfiguracaoSQLCentral.IDTecSistemas + "' AND senhaTecSistemas = '" + modelConfiguracaoSQLCentral.SenhaTecSistemas + "' AND status = '1' AND dataVencimento > CURRENT_TIMESTAMP");
            SqlCommand command;

            try
            {
                command = new SqlCommand(instrucao, controllerConfiguracaoSQLCentral.Conectar());
            }
            catch (Exception ex)
            {
                var result = MessageBox.Show(ex.Message + "\n\nVerificar conexão?", "Erro!", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                if (result == DialogResult.Yes)
                {
                    FrmConfiguracaoSQL frmConfiguracaoSQL = new FrmConfiguracaoSQL();
                    frmConfiguracaoSQL.ShowDialog();
                }
                return;
            }
            SqlDataReader sqlDataReader = command.ExecuteReader();

            if (sqlDataReader.HasRows)
            {
                string        conexaoBanco   = string.Format(@"SELECT servidorBD, nomeBD, idBD, senhaBD FROM tbCadastro WHERE idTecSistemas = '" + modelConfiguracaoSQLCentral.IDTecSistemas + "'");
                SqlCommand    command1       = new SqlCommand(conexaoBanco, controllerConfiguracaoSQLCentral.Conectar());
                SqlDataReader sqlDataReader1 = command1.ExecuteReader();
                sqlDataReader1.Read();
                modelConfiguracaoSQL.ServidorBD = sqlDataReader1["servidorBD"].ToString();
                modelConfiguracaoSQL.NomeBD     = sqlDataReader1["nomeBD"].ToString();
                modelConfiguracaoSQL.IDBD       = sqlDataReader1["idBD"].ToString();
                modelConfiguracaoSQL.SenhaBD    = sqlDataReader1["senhaBD"].ToString();

                controllerConfiguracaoSQL.SalvarConexao(modelConfiguracaoSQL);
                ModelLogin modelLogin = new ModelLogin();
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new FrmLogin(modelLogin));
            }
            else
            {
                MessageBox.Show("O sistema está desativado ou vencido, entre em contato com o desenvolvedor.", "Alerta!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #19
0
 public FrmPrincipal(ModelLogin modelLogin)
 {
     InitializeComponent();
     CarregarTema();
     if (modelLogin != null && modelLogin.Nivel == "Vendedor")
     {
         caixaToolStripMenuItem.Visible         = true;
         clientesToolStripMenuItem.Visible      = false;
         produtosToolStripMenuItem.Visible      = false;
         financeiroToolStripMenuItem.Visible    = false;
         sobreToolStripMenuItem.Visible         = true;
         conexãoSQLToolStripMenuItem.Visible    = false;
         administradorToolStripMenuItem.Visible = false;
     }
     else if (modelLogin != null && modelLogin.Nivel == "Administrador")
     {
         caixaToolStripMenuItem.Visible         = true;
         clientesToolStripMenuItem.Visible      = true;
         produtosToolStripMenuItem.Visible      = true;
         financeiroToolStripMenuItem.Visible    = true;
         sobreToolStripMenuItem.Visible         = true;
         conexãoSQLToolStripMenuItem.Visible    = true;
         administradorToolStripMenuItem.Visible = true;
     }
     else if (modelLogin != null && modelLogin.Nivel == "Supervisor")
     {
         caixaToolStripMenuItem.Visible         = false;
         clientesToolStripMenuItem.Visible      = true;
         produtosToolStripMenuItem.Visible      = false;
         financeiroToolStripMenuItem.Visible    = true;
         sobreToolStripMenuItem.Visible         = true;
         conexãoSQLToolStripMenuItem.Visible    = false;
         administradorToolStripMenuItem.Visible = false;
     }
     else if (modelLogin != null && modelLogin.Nivel == "Estoquista")
     {
         caixaToolStripMenuItem.Visible         = false;
         clientesToolStripMenuItem.Visible      = false;
         produtosToolStripMenuItem.Visible      = true;
         financeiroToolStripMenuItem.Visible    = false;
         sobreToolStripMenuItem.Visible         = true;
         conexãoSQLToolStripMenuItem.Visible    = false;
         administradorToolStripMenuItem.Visible = false;
     }
     lblStatusLogin.Text = modelLogin.Nivel + ": " + modelLogin.ID;
 }
Exemple #20
0
 public IActionResult Login(ModelLogin login)
 {
     if (ModelState.IsValid)
     {
         Boolean loginOk = login.ValidarLogin();
         if (loginOk)
         {
             HttpContext.Session.SetString("IdUsuario", login.Id);
             HttpContext.Session.SetString("NomeUsuaio", login.Nome);
             return(RedirectToAction("index", "Home"));
         }
         else
         {
             TempData["ErrorMessage"] = "Email e/ou Senha Incorreto(s) !";
         }
     }
     return(View());
 }
Exemple #21
0
 public FrmPrincipal(ModelLogin modelLogin)
 {
     InitializeComponent();
     CarregarTema();
     if (modelLogin.Nivel == "Secretária")
     {
         administradorToolStripMenuItem.Visible = false;
         clientesToolStripMenuItem.Visible      = false;
         serviçosToolStripMenuItem.Visible      = false;
         ticketToolStripMenuItem.Visible        = false;
     }
     else if (modelLogin.Nivel == "Clínico")
     {
         administradorToolStripMenuItem.Visible = false;
         financeiroToolStripMenuItem.Visible    = false;
     }
     lblStatusLogin.Text = modelLogin.Nivel + ": " + modelLogin.ID;
 }
Exemple #22
0
        public ControllerLogin(string id_login, string id_funcionario, string ds_nivelAcesso, string ds_usuario, string ds_senha, string connectionString)
        {
            // validar a entrada de dados para inclusão
            string mDs_Msg = ValidateFields(id_login, id_funcionario, ds_usuario, ds_senha, ds_nivelAcesso, connectionString);

            if (mDs_Msg == "")
            {
                // tudo certinho
                // instanciar um objeto da classe login, carregar tela e alterar
                myModelLogin = new ModelLogin(Convert.ToInt32(id_login), Convert.ToInt32(id_funcionario), ds_nivelAcesso, ds_usuario, BCrypt.Net.BCrypt.HashPassword(ds_senha), connectionString);
                DS_Mensagem  = myModelLogin.DS_Mensagem;
            }
            else
            {
                // exibir erro!
                DS_Mensagem = mDs_Msg;
            }
        }
Exemple #23
0
 public bool Deletar(ModelLogin modelLogin)
 {
     try
     {
         string     instrucao = string.Format("DELETE FROM tbLogin WHERE Codigo = @Codigo");
         SqlCommand command   = new SqlCommand(instrucao, controllerConfiguracaoSQL.Conectar());
         command.Parameters.AddWithValue("@Codigo", modelLogin.Codigo);
         return(Convert.ToBoolean(command.ExecuteNonQuery()));
     }
     catch
     {
         throw;
     }
     finally
     {
         controllerConfiguracaoSQL.Fechar();
     }
 }
Exemple #24
0
        public async Task Deslogar()
        {
            _tokensource = new CancellationTokenSource();

            Boolean answer;

            answer = await
                     this._messageService.ShowAlertChooseAsync(
                AppResources.ConfirmaSair
                , AppResources.cancelar
                , AppResources.Ok
                , null);

            if (answer == true)
            {
                await Task.Run(async() =>
                {
                    TokenDataStore store = new TokenDataStore();
                    store.Clean();

                    try
                    {
                        Bll_PushNotification classPushNotification = new Bll_PushNotification();
                        classPushNotification.DeletePushKey(_tokensource.Token);
                    }
                    catch (Exception ex)
                    {
                        Crashes.TrackError(ex);
                    }

                    try
                    {
                        ModelLogin modelUsuario = new ModelLogin();
                        modelUsuario.Deslogar(_tokensource.Token);
                    }
                    catch (Exception ex)
                    {
                        Crashes.TrackError(ex);
                    }
                });

                this._navigationService.NavigateToLogin();
            }
        }
        public async Task <ActionResult> ContinueRequest(ModelLogin modelLogin)
        {
            if (!ModelState.IsValid)
            {
                return(View(modelLogin));
            }
            var user = await _userAppService.FindAsync(modelLogin.Identification, modelLogin.DocumentType, modelLogin.Identification + ConfigurationManager.AppSettings["Salt"]);

            if (user != null)
            {
                var identity =
                    await _userAppService.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);

                identity.Label = user.FullName;
                GetAuthenticationManager().SignIn(identity);
                var principal = new ClaimsPrincipal(identity);
                Thread.CurrentPrincipal = principal;
                HttpContext.User        = principal;
                //set arguments
                long.Parse(User.Identity.GetUserId(), CultureInfo.InvariantCulture);

                ProcessFlowArgument.User = user;

                var response = _userAppService.GetRequestBySimpleId(modelLogin.SimpleId);
                Session["Product"] = (ProductType)response.ProductId;
                BaseProductType    = (int)Session["Product"];

                ProcessFlowArgument.Execution = new Execution
                {
                    Id        = response.Id,
                    ProductId = response.ProductId
                };

                var pages = _userAppService.GetAllPagesWithSections();
                ViewBag.Pages    = pages;
                ViewBag.FullName = identity.Label;

                var stepresult = await ExecuteFlowAsync(identity, pages);

                return(ValidateStepResult(stepresult));
            }
            ModelState.AddModelError("", Resources.RequestController_ContinueRequest_No_Active_Request);
            return(View(modelLogin));
        }
Exemple #26
0
        public LoginViewModel Login(ModelLogin vmLog)
        {
            LoginViewModel vmRsta = new LoginViewModel(true, "Incorrect Email or Password");

            try
            {
                var objModel = context.Usuario.Where(x => x.Correo == vmLog.Correo && x.Clave == vmLog.Clave).FirstOrDefault();
                if (objModel != null)
                {
                    vmRsta = new LoginViewModel(false, "Welcome");
                    UsuarioViewModel vmUsuario = new UsuarioViewModel();
                    vmUsuario.ID      = objModel.ID;
                    vmUsuario.Nombres = objModel.Nombres + " " + objModel.Apellidos;
                    vmUsuario.Correo  = objModel.Correo;
                    vmUsuario.DNI     = objModel.DNI;
                    vmUsuario.Estado  = objModel.Estado.Nombre;
                    vmUsuario.Sexo    = objModel.ID_Sexo;
                    ReservaBL rbl   = new ReservaBL();
                    var       tutor = context.Tutor.Where(x => x.ID_Usuario == objModel.ID).FirstOrDefault();
                    if (tutor != null)
                    {
                        vmRsta.tutor          = true;
                        vmUsuario.IdTutor     = tutor.ID;
                        vmUsuario.Experiencia = tutor.Experiencia;
                        vmUsuario.Costo       = tutor.Costo;
                        vmUsuario.Direccion   = tutor.Direccion;
                        vmUsuario.Telefono    = tutor.Telefono;
                        vmRsta.vmLista        = rbl.TutorReserva(tutor.ID);
                    }
                    else
                    {
                        UsuarioBL abl = new UsuarioBL();
                        vmRsta.vmLista = rbl.AlumnoReserva(objModel.ID);
                    }
                    vmRsta.vmUsuario = vmUsuario;
                }
            }
            catch
            {
                vmRsta = new LoginViewModel(true, "Fail Conexion");
            }
            return(vmRsta);
        }
        private void btnEntrar_Click(object sender, EventArgs e)
        {
            var pELogin = new ModelLogin
            {
                Usuario  = txtUsuario.Text.Trim(),
                Password = txtContraseña.Text.Trim()
            };

            if (ModelLogin.LogIn(pELogin) > 0)
            {
                MessageBox.Show(@"Bienvenido", @"Sesión Iniciada", MessageBoxButtons.OK, MessageBoxIcon.Information);
                NuevoForm(ModelLogin.LogIn(pELogin));
            }
            else
            {
                MessageBox.Show(@"Contraseña o Usuario Incorrectos", @"Error!!!", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
        }
Exemple #28
0
 public bool AlterarStatus(ModelLogin modelLogin)
 {
     try
     {
         string     instrucao = string.Format(@"UPDATE tbLogin SET Status = @Status WHERE ID = @ID");
         SqlCommand command   = new SqlCommand(instrucao, controllerConfiguracaoSQL.Conectar());
         command.Parameters.AddWithValue("@ID", modelLogin.ID);
         command.Parameters.AddWithValue("@Status", modelLogin.Status);
         return(Convert.ToBoolean(command.ExecuteNonQuery()));
     }
     catch
     {
         throw;
     }
     finally
     {
         controllerConfiguracaoSQL.Fechar();
     }
 }
Exemple #29
0
        private void InsertLoginLog(string domain, string ntid)
        {
            ModelLogin       objMdlLogin = new ModelLogin();
            string           EmployeeID = string.Empty, userName = string.Empty, EmailAddress = string.Empty, telephone = string.Empty, firstname = string.Empty, lastName = string.Empty, GosCode = string.Empty;
            PrincipalContext pc;

            if (domain == "ACTICALL")
            {
                pc = new PrincipalContext(ContextType.Domain, "ACTICALL", "DC=acticall,DC=com");
            }
            else
            {
                pc = new PrincipalContext(ContextType.Domain, Convert.ToString(domain));
            }
            UserPrincipal user = new UserPrincipal(pc);

            user = UserPrincipal.FindByIdentity(pc, Convert.ToString(ntid));
            if (user != null)
            {
                userName     = user.GivenName + " " + user.Surname;
                EmailAddress = user.EmailAddress;
                telephone    = user.VoiceTelephoneNumber;
                firstname    = user.GivenName;
                lastName     = user.Surname;
                EmployeeID   = user.EmployeeId;
                GosCode      = user.Description;
            }
            else
            {
                userName = Convert.ToString(ntid);
            }

            Session["PP_FullName"]   = userName;
            Session["EmailAddress"]  = EmailAddress;
            Session["PP_EmployeeID"] = Session["PP_LawsonID"];
            if (domain == "ACTICALL")
            {
                HttpContext.Current.Session["PP_RoleName"] = GosCode;
                Session["PP_EmployeeID"] = EmployeeID;
            }

            objMdlLogin.InsertLoginLog(Convert.ToString(userName), Convert.ToString(ntid), Convert.ToString(domain), "PP");
        }
Exemple #30
0
        public ModelStatus Registration(ModelLogin packet)
        {
            if (Player != null)
            {
                return(null);
            }
            if (packet.Login.Trim().Length < 2 ||
                packet.Pass.Length < 5)
            {
                return(new ModelStatus()
                {
                    Status = 1,
                    Message = "Incorrect login or password"
                });
            }
            //Thread.Sleep(5000);
            packet.Login = packet.Login.Trim();
            var player = Repository.GetData.PlayersAll
                         .FirstOrDefault(p => Repository.NormalizeLogin(p.Public.Login) == Repository.NormalizeLogin(packet.Login));

            if (player != null)
            {
                return(new ModelStatus()
                {
                    Status = 1,
                    Message = "This login already exists"
                });
            }
            player = new PlayerServer(packet.Login)
            {
                Pass    = packet.Pass,
                IsAdmin = Repository.GetData.PlayersAll.Count == 1
            };
            Repository.GetData.PlayersAll.Add(player);
            Repository.Get.ChangeData = true;
            Player = player;
            return(new ModelStatus()
            {
                Status = 0,
                Message = null
            });
        }