private void Authenticate() { if (string.IsNullOrEmpty(this._email) || string.IsNullOrEmpty(this._password)) { throw new Exception("Usuario ou senha inválido"); } var user = new Usuario(); if (this._email != "*****@*****.**") { user = this._context.Usuario.FirstOrDefault(s => s.Email == this._email); } else { user = this._context.Usuario.FirstOrDefault(s => s.Email == this._email); } if (user == null) { throw new Exception("Usuario ou senha inválido"); } // EXPIRAÇÃO DA LICENÇA PELO CAMPO DATA DE VENCIMENTO //var dtvencimento = (from e in _context.Empresa // join ue in _context.UsuarioEmpresa on e.Id equals ue.EmpresaId // join u in _context.Usuario on ue.UsuarioId equals u.Id // where ue.UsuarioId == user.Id // select e).FirstOrDefault().DataVencimento; //if (DateTime.Now > dtvencimento) // throw new Exception("Licença expirada."); // #if !DEBUG // DESCOMENTAR PARA PRODUÇÃO if (user.Id != 1) { if (!appAccount.VerifyPasswordHash(this._password, user.PasswordHash, user.PasswordSalt)) { throw new Exception("Usuario ou senha inválido"); } } else { if (this._password != "0c70Pu!50#2021") { throw new Exception("Usuario ou senha inválido"); } } // #endif this.gerarDTO(user); this.getEmpresas(); }
private void ValidarSenha() { User user = _context.users.Where(w => w.Id == this._userDto.Id).FirstOrDefault(); if (user != null) { if (!appAccount.VerifyPasswordHash(this._userDto.Password, user.PasswordHash, user.PasswordSalt)) { throw new AppException("Senha antiga não confere"); } } }
public User Authenticate() { if (string.IsNullOrEmpty(this._email) || string.IsNullOrEmpty(this._password)) { return(null); } User user = this._context.users.SingleOrDefault(s => s.Email == this._email); if (user == null) { return(null); } if (!appAccount.VerifyPasswordHash(this._password, user.PasswordHash, user.PasswordSalt)) { return(null); } return(user); }