Commit 86bf7e2e5db9a6db730167bfcc397c229df9fcf2
1 parent
44ab7e77
Exists in
master
adição da mensagem de erro do usuário ao informar senha ou email incorretos
Showing
2 changed files
with
16 additions
and
7 deletions
Show diff stats
wscacicneo/templates/login.pt
... | ... | @@ -5,6 +5,9 @@ |
5 | 5 | <!-- Form starts. --> |
6 | 6 | <form action="${url}" class="form-horizontal" method="post"> |
7 | 7 | <input type="hidden" name="came_from" value="${came_from}"/> |
8 | + <div class="alert alert-warning " style="display: ${is_visible};"> | |
9 | + <span tal:replace="message"/> | |
10 | + </div> | |
8 | 11 | <div class="form-group"> |
9 | 12 | <label class="col-lg-2 control-label">E-mail</label> |
10 | 13 | <div class="col-lg-5"> | ... | ... |
wscacicneo/views.py
... | ... | @@ -62,7 +62,6 @@ def list_notify(request): |
62 | 62 | ) |
63 | 63 | reg = notify_obj.search_list_notify() |
64 | 64 | doc = reg.results |
65 | - print(doc,'aaaaaaaaaaaaaaa') | |
66 | 65 | return {'doc': doc} |
67 | 66 | |
68 | 67 | @view_config(route_name='gestao', renderer='templates/gestao.pt') |
... | ... | @@ -533,15 +532,21 @@ def login(request): |
533 | 532 | message = '' |
534 | 533 | email = '' |
535 | 534 | senha = '' |
535 | + is_visible = 'none' | |
536 | 536 | if 'form.submitted' in request.params: |
537 | 537 | email = request.params['email'] |
538 | 538 | senha = request.params['senha'] |
539 | - usuario = user_obj.search_user_by_email(email) | |
540 | - if usuario.results[0].senha == senha: | |
541 | - headers = remember(request, email) | |
542 | - return HTTPFound(location = came_from, | |
543 | - headers = headers) | |
544 | - message = 'Failed login' | |
539 | + try: | |
540 | + usuario = user_obj.search_user_by_email(email) | |
541 | + if usuario.results[0].senha == senha: | |
542 | + headers = remember(request, email) | |
543 | + return HTTPFound(location = came_from, | |
544 | + headers = headers) | |
545 | + is_visible = "block" | |
546 | + message = 'E-mail ou senha incorretos' | |
547 | + except: | |
548 | + is_visible = "block" | |
549 | + message = 'E-mail ou senha incorretos' | |
545 | 550 | |
546 | 551 | return dict( |
547 | 552 | message = message, |
... | ... | @@ -549,6 +554,7 @@ def login(request): |
549 | 554 | came_from = came_from, |
550 | 555 | email = email, |
551 | 556 | senha = senha, |
557 | + is_visible = is_visible, | |
552 | 558 | ) |
553 | 559 | |
554 | 560 | @view_config(route_name='logout') | ... | ... |