Skip to content

Commit

Permalink
Merge branch 'master' into duzzsys-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonasdart authored May 22, 2020
2 parents 11ec9e1 + 81da89e commit 04962b0
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 175 deletions.
2 changes: 2 additions & 0 deletions database_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def authenticate(self, database):
else:
config_bank = 'config_bank_api'

print(config_bank)

address_bank = config.get(config_bank, 'address_bank')
name_bank = config.get(config_bank, 'name_bank')
user_bank = config.get(config_bank, 'user_bank')
Expand Down
23 changes: 11 additions & 12 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,20 @@ def confirm_token(self, data):
def active_token(self, token, user_id):
try:
query = f'select id from tokens where token = {token} and user = {user_id}'
token_id = self.database.commit_with_return(query, database = 2)[0][0]
if len(id) > 0:
token_id = self.database.commit_with_return(query, database = 2)[0]

if len(token_id) > 0:
query = self.gera_query.alterar_dados_da_tabela('connections', ['active'], [1], where=True,
valor_where=token_id, coluna_verificacao='id')
valor_where=token_id[0], coluna_verificacao='id')
self.database.commit_without_return(query, database = 2)
else:
query = self.gera_query.inserir_na_tabela('connections', ['token'], [token_id])
query = self.gera_query.inserir_na_tabela('connections', ['token'], [token_id[0]])
self.database.commit_without_return(query, database = 2)

self.r = {
'Message' : {
'token' : token,
'token_id' : token_id
'token_id' : token_id[0]
},
'Status' : 200
}
Expand All @@ -124,14 +124,14 @@ def active_token(self, token, user_id):
def deactive_token(self, token):
try:
query = f'select id from tokens where token = {token}'
token_id = self.database.commit_with_return(query, database = 2)[0][0]
token_id = self.database.commit_with_return(query, database = 2)[0]

if len(id) > 0:
if len(token_id) > 0:
query = self.gera_query.alterar_dados_da_tabela('connections', ['active'], [0], where=True,
valor_where=token_id, coluna_verificacao='id')
valor_where=token_id[0], coluna_verificacao='id')
self.database.commit_without_return(query, database = 2)
else:
query = self.gera_query.inserir_na_tabela('connections', ['token', 'active'], [token_id, 0])
query = self.gera_query.inserir_na_tabela('connections', ['token', 'active'], [token_id[0], 0])
self.database.commit_without_return(query, database = 2)

self.r = {
Expand Down Expand Up @@ -236,7 +236,6 @@ def novo_veiculo(self, data):
username = data['Username']
user_type = data['UserType']
license_plate = data['LicensePlate']
username = data['Username']

user_id = self.database.return_user_id(username)
columns = self.database.return_columns('carros')
Expand Down Expand Up @@ -419,7 +418,7 @@ def autenticar_usuario(self, data):

user_id = self.database.return_user_id(username)

if len(user_id) == 0:
if not user_id:
raise Exception('Usuário não encontrado no banco de dados')

token = self.search_token(user_id)
Expand Down
Loading

0 comments on commit 04962b0

Please sign in to comment.