Пример #1
0
        public async Task <TokenUserDTO> GetTokenLogin([FromBody] UsuarioLoginDTO user)
        {
            try
            {
                /* FAZ O LOGIN */
                var userExists = await _signInManager.PasswordSignInAsync(user.Email, user.Password, true, false);

                TokenUserDTO token = null;
                if (userExists.Succeeded)
                {
                    /* Ele existe... logo loga... */
                    Usuario usuario = await _rep.GetUserByEmail(user.Email);

                    var tokenGerado = GetAuth.GenerateToken(usuario);
                    token = new TokenUserDTO()
                    {
                        TokenUrsao = tokenGerado,
                    };
                    return(token);
                }
                else
                {
                    throw new UsuarioNaoEncontradoException("usuario nao encontrado :P");
                }
            }
            catch (Exception e)
            {
                return(new TokenUserDTO()
                {
                    TokenUrsao = "Puuuxa não foi dessa vez... Mas ligue novamente para 4002-8922 q vc será atendido pelo SBT! --- SACANAGEM... KKKKK na real a msg é essa mano: Ocorreu algum erro interno na aplicação, por favor tente novamente... Erro: " + e.Message,
                });
            }
        }
Пример #2
0
 public void ToXml(XmlWriter writer)
 {
     writer.WriteStartElement("Entity");
     writer.WriteAttributeString("type", this.GetType().ToString());
     writer.WriteStartElement("SaveAuthGroups");
     foreach (String item in SaveAuthGroups)
     {
         writer.WriteStartElement("SaveAuthGroup");
         writer.WriteString(item);
         writer.WriteEndElement();
     }
     writer.WriteEndElement();
     writer.WriteStartElement("SaveAuth");
     writer.WriteString(SaveAuth.ToString());
     writer.WriteEndElement();
     writer.WriteStartElement("SaveVisible");
     writer.WriteString(SaveVisible.ToString());
     writer.WriteEndElement();
     writer.WriteStartElement("GetAuthGroups");
     foreach (String item in GetAuthGroups)
     {
         writer.WriteStartElement("GetAuthGroup");
         writer.WriteString(item);
         writer.WriteEndElement();
     }
     writer.WriteEndElement();
     writer.WriteStartElement("GetAuth");
     writer.WriteString(GetAuth.ToString());
     writer.WriteEndElement();
     writer.WriteStartElement("GetVisible");
     writer.WriteString(GetVisible.ToString());
     writer.WriteEndElement();
     writer.WriteStartElement("Description");
     writer.WriteString(Description);
     writer.WriteEndElement();
     writer.WriteStartElement("Properties");
     foreach (Property item in Properties)
     {
         if (item != null)
         {
             item.ToXml(writer);
         }
     }
     writer.WriteEndElement();
     writer.WriteStartElement("Name");
     writer.WriteString(Name);
     writer.WriteEndElement();
     writer.WriteEndElement();
 }
        public async Task <TokenUserDTO> GetTokenLogin([FromBody] UsuarioLoginDTO user)
        {
            try
            {
                /* FAZ O LOGIN */
                var userExists = await _signInManager.PasswordSignInAsync(user.Email, user.Password, true, false);

                TokenUserDTO token = null;
                if (userExists.Succeeded)
                {
                    /* Ele existe... logo loga... */
                    Usuario usuario = await _rep.GetUsuarioPorEmail(new UsuarioPorEmailDTO()
                    {
                        Email = user.Email
                    });

                    var tokenGerado = GetAuth.GenerateToken(usuario);
                    token = new TokenUserDTO()
                    {
                        Token = tokenGerado,
                    };
                    return(token);
                }
                else
                {
                    throw new UsuarioNaoEncontradoException("usuario nao encontrado");
                }
            }
            catch (Exception e)
            {
                return(new TokenUserDTO()
                {
                    Token = "Ocorreu algum erro interno na aplicação, por favor tente novamente... Erro: " + e.Message,
                });
            }
        }