inserido acesso dos usuários
This commit is contained in:
@@ -24,7 +24,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
final inputLogin = TextEditingController(text: 'admin');
|
||||
final inputSenha = TextEditingController(text: 'las1594@@');
|
||||
final inputCodigo = TextEditingController(text: 'e003');
|
||||
bool loading = false;
|
||||
bool carregando = false;
|
||||
List listCodigo = [];
|
||||
|
||||
carregarLista(){
|
||||
@@ -39,9 +39,13 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
if(inputCodigo.text.isNotEmpty){
|
||||
if(listCodigo.contains(inputCodigo.text.toUpperCase())){
|
||||
setState(() {
|
||||
loading = true;
|
||||
carregando = true;
|
||||
});
|
||||
conectAPI();
|
||||
if(inputLogin.text.toUpperCase() == 'ADMIN'){
|
||||
conectAPI();
|
||||
}else{
|
||||
getAcessosMariaDB();
|
||||
}
|
||||
}else{
|
||||
showSnackBar(context, 'Código inválido', Colors.red);
|
||||
}
|
||||
@@ -56,6 +60,38 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
getAcessosMariaDB()async{
|
||||
String cidade = '';
|
||||
for(int i =0; Cidades().listCidades.length>i;i++){
|
||||
if(Cidades().listCidades[i].codigo == inputCodigo.text.toUpperCase()){
|
||||
cidade = Cidades().listCidades[i].cidadeQuery.toUpperCase();
|
||||
}
|
||||
}
|
||||
final url = 'http://192.168.18.2:8000/acesso_maria?LOGIN=${inputLogin.text.toUpperCase()}&CIDADE=$cidade';
|
||||
print(url);
|
||||
final response = await http.get(Uri.parse(url));
|
||||
var map = json.decode(response.body);
|
||||
print(map);
|
||||
List list = map;
|
||||
if(list.length != 0 ){
|
||||
for(int i=0;list.length>i;i++){
|
||||
if(list[i]['ID_USUARIO']==inputLogin.text.toUpperCase() &&list[i]['CONDICAO']=='1'){
|
||||
conectAPI();
|
||||
}else{
|
||||
setState(() {
|
||||
carregando = false;
|
||||
});
|
||||
showSnackBar(context, 'Login seu acesso não está liberado!', Colors.red);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
setState(() {
|
||||
carregando = false;
|
||||
});
|
||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta e/ou Código incorreto', Colors.red);
|
||||
}
|
||||
}
|
||||
|
||||
conectAPI()async{
|
||||
|
||||
String cidade = '';
|
||||
@@ -71,7 +107,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
var map = json.decode(response.body);
|
||||
// print(map);
|
||||
if(map==false){
|
||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta', Colors.red);
|
||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta e/ou Código incorreto', Colors.red);
|
||||
}else{
|
||||
if(map['NO_USERNAME']==map['SENHA']){
|
||||
if(map['NO_USERNAME']==inputLogin.text.toUpperCase() && map['SENHA']==inputSenha.text.toUpperCase()){
|
||||
@@ -79,7 +115,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
List dados = [cidade,inputLogin.text];
|
||||
Navigator.pushNamed(context, '/home',arguments: dados);
|
||||
}else{
|
||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta', Colors.red);
|
||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta e/ou Código incorreto', Colors.red);
|
||||
}
|
||||
}else{
|
||||
if(MainControllers().encrypt(inputSenha.text,map['SENHA']) == map['SENHA']){
|
||||
@@ -87,12 +123,12 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
List dados = [cidade,inputLogin.text];
|
||||
Navigator.pushNamed(context, '/home',arguments: dados);
|
||||
}else{
|
||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta', Colors.red);
|
||||
showSnackBar(context, 'Login não cadastrado e/ou senha incorreta e/ou Código incorreto', Colors.red);
|
||||
}
|
||||
}
|
||||
}
|
||||
setState(() {
|
||||
loading = false;
|
||||
carregando = false;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -116,7 +152,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
Container(
|
||||
child: Image.asset("assets/images/logoEduca.png",width:width * 0.15,height: height * 0.12)
|
||||
),
|
||||
loading?Container():Container(
|
||||
carregando?Container():Container(
|
||||
width: width>900? width * 0.18:width*0.5,
|
||||
child: InputText(
|
||||
inputFormatters: [],
|
||||
@@ -127,7 +163,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
),
|
||||
),
|
||||
SizedBox(height: height * 0.02),
|
||||
loading?Container():Container(
|
||||
carregando?Container():Container(
|
||||
width: width>900? width * 0.18:width*0.5,
|
||||
child: InputText(
|
||||
inputFormatters: [],
|
||||
@@ -139,7 +175,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
),
|
||||
),
|
||||
SizedBox(height: height * 0.02),
|
||||
loading?Container():Container(
|
||||
carregando?Container():Container(
|
||||
width: width>900? width * 0.18:width*0.5,
|
||||
child: InputText(
|
||||
inputFormatters: [],
|
||||
@@ -150,7 +186,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
),
|
||||
),
|
||||
SizedBox(height: height * 0.02),
|
||||
loading?Row(
|
||||
carregando?Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
CircularProgressIndicator(),
|
||||
|
||||
Reference in New Issue
Block a user