Advertisement
Guest User

Untitled

a guest
Apr 16th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. <p:commandLink id="btn_save_users_modal"
  2. action="#{messageBean.insert()}"
  3. styleClass="btn btn-success"
  4. update=":message_form"
  5. validateClient="true">
  6. <i class="fa fa-check fa-fw" /> #{bundle['system.ui.label.save']}
  7. </p:commandLink>
  8.  
  9. public void insert() {
  10. try {
  11. messageFacade.save(message);
  12. } catch (Exception e) {
  13. e.printStackTrace();
  14. }
  15. }
  16.  
  17. public String doLogin() {
  18.  
  19. // Força a JVM para pt-BR, assim a formatação numérica fica no formato
  20. // brasileiro
  21. Locale.setDefault(new Locale("pt", "BR"));
  22.  
  23. // Validações
  24.  
  25. if (this.username == null || this.username.equals("")) {
  26. MessageGrowl.warn(
  27. MessageProperties.getString("message.loginVazio"), false);
  28. } else if (this.password == null || this.password.equals("")) {
  29. MessageGrowl
  30. .warn(MessageProperties.getString("message.passwordVazio"),
  31. false);
  32. } else {
  33.  
  34. // String hashedPassword = SecurityUtils.getHashedString(password);
  35.  
  36. this.loggedUser = loginUserFacade.getValideUser(username,password);
  37.  
  38. if (this.loggedUser != null) {
  39. isAuthenticated = true;
  40. redirectIfAlreadyLogged();
  41.  
  42. }
  43.  
  44. else {
  45.  
  46. MessageGrowl.error(MessageProperties
  47. .getString("login.autenticacao"));
  48. clear();
  49. }
  50. }
  51.  
  52. return "";
  53. }
  54.  
  55. @ManagedProperty(value = "#{loginMB}")
  56. private LoginMB loginMB;
  57. public void setLoginMB(LoginMB loginMB) {this.loginMB = loginMB;}
  58.  
  59. public void insert() {
  60. //pegando o usuario: loginMB.getUsername();
  61. }
  62.  
  63. @Transactional
  64. public Usuario verificaLoginSenha(String email, String senha) {
  65. Usuario usuario = usuarioDao.verificaLoginSenha(email,senha);
  66. if(usuario!=null){
  67. if(usuario.getCadastroAtivo()){
  68. logAutenticacaoService.salvar(new LogAutenticacao(new Date(),usuario));
  69. }
  70. }
  71. return usuario;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement