Skip to content

Commit

Permalink
Adicionado retorno do User Type ao realizar login
Browse files Browse the repository at this point in the history
  • Loading branch information
duzzsys committed May 27, 2020
1 parent d5fed79 commit 66ed839
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 7 additions & 0 deletions database_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ def return_user_id(self, username):

return user_id


def return_user_type(self, user_id):
query = f'select type from usuarios where id={user_id}'
user_type = self.commit_with_return(query)[0][0]

return user_type


def return_salt(self, username):
query = f'select salt from usuarios where username = "{username}"'
Expand Down
5 changes: 2 additions & 3 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ def gera_token(self, data):
self.database.commit_without_return(query, database = 2)

self.r = {
'Message' : token,
'Status' : 200
'Message' : token
}
except Exception as e:

Expand Down Expand Up @@ -413,10 +412,10 @@ def solicitar_limpeza(self, data):
def autenticar_usuario(self, data):
try:
username = data['Username']
user_type = data['UserType']
password = data['Password']

user_id = self.database.return_user_id(username)
user_type = self.database.return_user_type(user_id)

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

0 comments on commit 66ed839

Please sign in to comment.