agreacion contrasenna encuesta y arreglo cache

This commit is contained in:
Paola 2021-07-24 22:53:38 -06:00
parent 3e459cd133
commit 6663fb729d
15 changed files with 764 additions and 10 deletions

View File

@ -24,13 +24,13 @@ public class CacheConfiguration {
private final javax.cache.configuration.Configuration<Object, Object> jcacheConfiguration;
public CacheConfiguration(JHipsterProperties jHipsterProperties) {
JHipsterProperties.Cache.Ehcache ehcache = jHipsterProperties.getCache().getEhcache();
//JHipsterProperties.Cache.Ehcache ehcache = jHipsterProperties.getCache().getEhcache();
jcacheConfiguration =
Eh107Configuration.fromEhcacheCacheConfiguration(
CacheConfigurationBuilder
.newCacheConfigurationBuilder(Object.class, Object.class, ResourcePoolsBuilder.heap(ehcache.getMaxEntries()))
.withExpiry(ExpiryPolicyBuilder.timeToLiveExpiration(Duration.ofSeconds(ehcache.getTimeToLiveSeconds())))
.newCacheConfigurationBuilder(Object.class, Object.class, ResourcePoolsBuilder.heap(100L))
.withExpiry(ExpiryPolicyBuilder.timeToLiveExpiration(Duration.ofSeconds(1)))
.build()
);
}
@ -82,6 +82,7 @@ public class CacheConfiguration {
private void createCache(javax.cache.CacheManager cm, String cacheName) {
javax.cache.Cache<Object, Object> cache = cm.getCache(cacheName);
if (cache != null) {
cache.clear();
} else {

View File

@ -31,7 +31,7 @@ public interface UserRepository extends JpaRepository<User, Long> {
Optional<User> findOneByLogin(String login);
@EntityGraph(attributePaths = "authorities")
//@Cacheable(cacheNames = USERS_BY_LOGIN_CACHE)
@Cacheable(cacheNames = USERS_BY_LOGIN_CACHE)
Optional<User> findOneWithAuthoritiesByLogin(String login);
@EntityGraph(attributePaths = "authorities")

View File

@ -30,6 +30,8 @@ public class MailService {
private static final String USER = "user";
private static final String CONTRASENNA = "contrasenna";
private static final String BASE_URL = "baseUrl";
private final JHipsterProperties jHipsterProperties;
@ -93,6 +95,22 @@ public class MailService {
sendEmail(user.getEmail(), subject, content, false, true);
}
@Async
public void sendEmailFromTemplateEncuesta(User user, String templateName, String titleKey, String contrasenna) {
if (user.getEmail() == null) {
log.debug("Email doesn't exist for user '{}'", user.getLogin());
return;
}
Locale locale = Locale.forLanguageTag(user.getLangKey());
Context context = new Context(locale);
context.setVariable(CONTRASENNA, contrasenna);
context.setVariable(USER, user);
context.setVariable(BASE_URL, jHipsterProperties.getMail().getBaseUrl());
String content = templateEngine.process(templateName, context);
String subject = messageSource.getMessage(titleKey, null, locale);
sendEmail(user.getEmail(), subject, content, false, true);
}
@Async
public void sendActivationEmail(User user) {
log.debug("Sending activation email to '{}'", user.getEmail());
@ -128,4 +146,16 @@ public class MailService {
log.debug("Sending reactivated account mail to '{}'", user.getUser().getEmail());
sendEmailFromTemplate(user.getUser(), "mail/reactivatedAccountEmail", "email.reactivation.title");
}
@Async
public void sendPublishedPrivateMail(UsuarioExtra user, String contrasenna) {
log.debug("Sending reactivated account mail to '{}'", user.getUser().getEmail());
sendEmailFromTemplateEncuesta(user.getUser(), "mail/encuestaPrivadaEmail", "email.private.title", contrasenna);
}
@Async
public void sendPublishedPublicMail(UsuarioExtra user) {
log.debug("Sending reactivated account mail to '{}'", user.getUser().getEmail());
sendEmailFromTemplate(user.getUser(), "mail/encuestaPublicaEmail", "email.public.title");
}
}

View File

@ -394,12 +394,16 @@ public class UserService {
@Transactional(readOnly = true)
public Optional<User> getUserWithAuthoritiesByLogin(String login) {
return userRepository.findOneWithAuthoritiesByLogin(login);
//cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).clear();
}
@Transactional(readOnly = true)
public Optional<User> getUserWithAuthorities() {
return SecurityUtils.getCurrentUserLogin().flatMap(userRepository::findOneWithAuthoritiesByLogin);
//findOneWithAuthoritiesByLogin
//cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).clear();
//return user;
}
/**

View File

@ -8,9 +8,11 @@ import java.util.Optional;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import org.datasurvey.domain.Encuesta;
import org.datasurvey.domain.enumeration.AccesoEncuesta;
import org.datasurvey.repository.EncuestaRepository;
import org.datasurvey.service.EncuestaQueryService;
import org.datasurvey.service.EncuestaService;
import org.datasurvey.service.MailService;
import org.datasurvey.service.criteria.EncuestaCriteria;
import org.datasurvey.web.rest.errors.BadRequestAlertException;
import org.slf4j.Logger;
@ -41,14 +43,18 @@ public class EncuestaResource {
private final EncuestaQueryService encuestaQueryService;
private final MailService mailService;
public EncuestaResource(
EncuestaService encuestaService,
EncuestaRepository encuestaRepository,
EncuestaQueryService encuestaQueryService
EncuestaQueryService encuestaQueryService,
MailService mailService
) {
this.encuestaService = encuestaService;
this.encuestaRepository = encuestaRepository;
this.encuestaQueryService = encuestaQueryService;
this.mailService = mailService;
}
/**
@ -99,6 +105,12 @@ public class EncuestaResource {
}
Encuesta result = encuestaService.save(encuesta);
if (result.getAcceso().equals(AccesoEncuesta.PRIVATE)) {
mailService.sendPublishedPrivateMail(result.getUsuarioExtra(), result.getContrasenna());
} else {
mailService.sendPublishedPublicMail(result.getUsuarioExtra());
}
return ResponseEntity
.ok()
.headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, encuesta.getId().toString()))

View File

@ -39,3 +39,16 @@ email.suspended.title=Your account has been suspended
email.suspended.greeting=Dear {0}
email.suspended.text1=Su cuenta en DatSurvey se encuentra temporalmente suspendida. Si cree que es un error por favor haga clic en el siguiente enlace para enviar una solicitud para reactivar su cuenta:
email.suspended.text2=Saludos,
#PublicEncuesta
email.public.title=Su encuesta ha sido publicada
email.public.greeting=¡Felicidades {0}!
email.public.text1=Su encuesta ha sido publicada de manera publica
email.public.text2=Saludos,
#PrivateEncuesta
email.private.title=Su encuesta ha sido publicada de manera privada
email.private.greeting=¡Felicidades {0}!
email.private.text1=Su encuesta ha sdo publicada de manera privada. Su contraseña de acceso es: {0}
email.private.text2=Saludos,

View File

@ -40,3 +40,15 @@ email.suspended.title=Su cuenta ha sido suspendida
email.suspended.greeting=Estimado {0}
email.suspended.text1=Lamentamos informarle que su cuenta en DatSurvey se encuentra temporalmente suspendida. Si cree que es un error por favor responda a este correo
email.suspended.text2=Saludos,
#PublicEncuesta
email.public.title=Su encuesta ha sido publicada
email.public.greeting=¡Felicidades {0}!
email.public.text1=Su encuesta ha sido publicada de manera publica
email.public.text2=Saludos,
#PrivateEncuesta
email.private.title=Su encuesta ha sido publicada de manera privada
email.private.greeting=¡Felicidades {0}!
email.private.text1=Su encuesta ha sdo publicada de manera privada. Su contraseña de acceso es: {0}
email.private.text2=Saludos,

View File

@ -0,0 +1,319 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" th:lang="${#locale.language}" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width" />
<!-- Forcing initial-scale shouldn't be necessary -->
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- Use the latest (edge) version of IE rendering engine -->
<meta name="x-apple-disable-message-reformatting" />
<!-- Disable auto-scale in iOS 10 Mail entirely -->
<title th:text="#{email.private.title}">JHipster activation</title>
<link rel="icon" th:href="@{|${baseUrl}/favicon.ico|}" />
<link href="https://fonts.googleapis.com/css?family=NotoSansSP:300,400,700" rel="stylesheet" />
<link rel="manifest" href="manifest.webapp" />
<style>
.bg_white {
background: #ffffff;
}
.bg_light {
background: #fafafa;
}
.bg_black {
background: #000000;
}
.bg_dark {
background: rgba(0, 0, 0, 0.8);
}
.email-section {
padding: 2.5em;
}
/*BUTTON*/
.btn {
padding: 10px 15px;
display: inline-block;
}
.btn.btn-primary {
border-radius: 5px;
background: #007bff;
color: #ffffff;
}
.btn.btn-white {
border-radius: 5px;
background: #ffffff;
color: #000000;
}
.btn.btn-white-outline {
border-radius: 5px;
background: transparent;
border: 1px solid #fff;
color: #fff;
}
.btn.btn-black-outline {
border-radius: 0px;
background: transparent;
border: 2px solid #000;
color: #000;
font-weight: 700;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: 'Lato', sans-serif;
color: #000000;
margin-top: 0;
font-weight: 400;
}
body {
font-family: 'Noto Sans JP', sans-serif;
font-weight: 400;
font-size: 15px;
line-height: 1.8;
color: rgba(0, 0, 0, 0.4);
}
a {
color: #30e3ca;
}
table {
}
/*LOGO*/
.logo h1 {
margin: 0;
}
.logo h1 a {
color: #30e3ca;
font-size: 24px;
font-weight: 700;
font-family: 'Lato', sans-serif;
}
/*HERO*/
.hero {
position: relative;
z-index: 0;
}
.hero .text {
color: rgba(0, 0, 0, 0.3);
}
.hero .text h2 {
color: #000;
font-size: 40px;
margin-bottom: 0;
font-weight: 400;
line-height: 1.4;
}
.hero .text h3 {
font-size: 24px;
font-weight: 300;
}
.hero .text h2 span {
font-weight: 600;
color: #30e3ca;
}
/*HEADING SECTION*/
.heading-section {
}
.heading-section h2 {
color: #000000;
font-size: 28px;
margin-top: 0;
line-height: 1.4;
font-weight: 400;
}
.heading-section .subheading {
margin-bottom: 20px !important;
display: inline-block;
font-size: 13px;
text-transform: uppercase;
letter-spacing: 2px;
color: rgba(0, 0, 0, 0.4);
position: relative;
}
.heading-section .subheading::after {
position: absolute;
left: 0;
right: 0;
bottom: -10px;
content: '';
width: 100%;
height: 2px;
background: #30e3ca;
margin: 0 auto;
}
.heading-section-white {
color: rgba(255, 255, 255, 0.8);
}
.heading-section-white h2 {
/*font-family: ;*/
line-height: 1;
padding-bottom: 0;
}
.heading-section-white h2 {
color: #ffffff;
}
.heading-section-white .subheading {
margin-bottom: 0;
display: inline-block;
font-size: 13px;
text-transform: uppercase;
letter-spacing: 2px;
color: rgba(255, 255, 255, 0.4);
}
ul.social {
padding: 0;
}
ul.social li {
display: inline-block;
margin-right: 10px;
}
.footer {
border-top: 1px solid rgba(0, 0, 0, 0.05);
color: rgba(0, 0, 0, 0.5);
}
.footer .heading {
color: #000;
font-size: 20px;
}
.footer ul {
margin: 0;
padding: 0;
}
.footer ul li {
list-style: none;
margin-bottom: 10px;
}
.footer ul li a {
color: rgba(0, 0, 0, 1);
}
</style>
</head>
<body width="100%" style="margin: 0; padding: 0 !important; mso-line-height-rule: exactly; background-color: #f1f1f1">
<center style="width: 100%; background-color: #f1f1f1">
<div
style="
display: none;
font-size: 1px;
max-height: 0px;
max-width: 0px;
opacity: 0;
overflow: hidden;
mso-hide: all;
font-family: sans-serif;
"
>
&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;
</div>
<div style="max-width: 600px; margin: 0 auto" class="email-container">
<!-- BEGIN BODY -->
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="margin: auto">
<tr>
<td valign="top" class="bg_white" style="padding: 1em 2.5em 0 2.5em">
<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="logo" style="text-align: center">
<h1>
<a href="#"
><img
src="https://res.cloudinary.com/marielascloud/image/upload/v1626333881/DataSurveyLogo2_smr2ok.png"
alt=""
width="300"
/></a>
</h1>
</td>
</tr>
</table>
</td>
</tr>
<!-- end tr -->
<tr>
<td valign="middle" class="hero bg_white" style="padding: 3em 0 2em 0">
<img
src="https://res.cloudinary.com/marielascloud/image/upload/v1626333882/email_v7pjtv.png"
alt=""
style="width: 300px; max-width: 600px; height: auto; margin: auto; display: block"
/>
</td>
</tr>
<!-- end tr -->
<tr>
<td valign="middle" class="hero bg_white" style="padding: 2em 0 4em 0">
<table>
<tr>
<td>
<div class="text" style="padding: 0 2.5em; text-align: center">
<h2 th:text="#{email.private.greeting(${user.login})}">¡Hola!</h2>
<h3 th:text="#{email.private.text1(${contrasenna})}">
Your JHipster account has been created, please click on the URL below to activate it:
</h3>
</div>
<div class="text" style="padding: 1em 2.5em; text-align: center">
<p>
<span th:text="#{email.private.text2}">Regards, </span>
<br />
<em th:text="#{email.signature}">JHipster.</em>
</p>
</div>
</td>
</tr>
</table>
</td>
</tr>
<!-- end tr -->
<!-- 1 Column Text + Button : END -->
</table>
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="margin: auto">
<tr>
<td valign="middle" class="bg_light footer email-section">
<table>
<tr>
<td valign="top" width="33.333%" style="padding-top: 20px">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-right: 10px">
<h3 class="heading">Acerca de</h3>
<p>DataSurvey es su compañero más cercano para poder recolectar información valiosa para usted</p>
</td>
</tr>
</table>
</td>
<td valign="top" width="33.333%" style="padding-top: 20px">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-left: 5px; padding-right: 5px">
<h3 class="heading">Información de contacto</h3>
<ul>
<li><span href="mailto:datasurveyapp@gmail.com" class="text">datasurveyapp@gmail.com</span></li>
</ul>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<!-- end: tr -->
<tr>
<td class="bg_light" style="text-align: center">
<p><a href="https://datasurvey.org" style="color: rgba(0, 0, 0, 0.8)">DataSurvey.org</a></p>
</td>
</tr>
</table>
</div>
</center>
</body>
</html>

View File

@ -0,0 +1,319 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" th:lang="${#locale.language}" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width" />
<!-- Forcing initial-scale shouldn't be necessary -->
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- Use the latest (edge) version of IE rendering engine -->
<meta name="x-apple-disable-message-reformatting" />
<!-- Disable auto-scale in iOS 10 Mail entirely -->
<title th:text="#{email.public.title}">JHipster activation</title>
<link rel="icon" th:href="@{|${baseUrl}/favicon.ico|}" />
<link href="https://fonts.googleapis.com/css?family=NotoSansSP:300,400,700" rel="stylesheet" />
<link rel="manifest" href="manifest.webapp" />
<style>
.bg_white {
background: #ffffff;
}
.bg_light {
background: #fafafa;
}
.bg_black {
background: #000000;
}
.bg_dark {
background: rgba(0, 0, 0, 0.8);
}
.email-section {
padding: 2.5em;
}
/*BUTTON*/
.btn {
padding: 10px 15px;
display: inline-block;
}
.btn.btn-primary {
border-radius: 5px;
background: #007bff;
color: #ffffff;
}
.btn.btn-white {
border-radius: 5px;
background: #ffffff;
color: #000000;
}
.btn.btn-white-outline {
border-radius: 5px;
background: transparent;
border: 1px solid #fff;
color: #fff;
}
.btn.btn-black-outline {
border-radius: 0px;
background: transparent;
border: 2px solid #000;
color: #000;
font-weight: 700;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: 'Lato', sans-serif;
color: #000000;
margin-top: 0;
font-weight: 400;
}
body {
font-family: 'Noto Sans JP', sans-serif;
font-weight: 400;
font-size: 15px;
line-height: 1.8;
color: rgba(0, 0, 0, 0.4);
}
a {
color: #30e3ca;
}
table {
}
/*LOGO*/
.logo h1 {
margin: 0;
}
.logo h1 a {
color: #30e3ca;
font-size: 24px;
font-weight: 700;
font-family: 'Lato', sans-serif;
}
/*HERO*/
.hero {
position: relative;
z-index: 0;
}
.hero .text {
color: rgba(0, 0, 0, 0.3);
}
.hero .text h2 {
color: #000;
font-size: 40px;
margin-bottom: 0;
font-weight: 400;
line-height: 1.4;
}
.hero .text h3 {
font-size: 24px;
font-weight: 300;
}
.hero .text h2 span {
font-weight: 600;
color: #30e3ca;
}
/*HEADING SECTION*/
.heading-section {
}
.heading-section h2 {
color: #000000;
font-size: 28px;
margin-top: 0;
line-height: 1.4;
font-weight: 400;
}
.heading-section .subheading {
margin-bottom: 20px !important;
display: inline-block;
font-size: 13px;
text-transform: uppercase;
letter-spacing: 2px;
color: rgba(0, 0, 0, 0.4);
position: relative;
}
.heading-section .subheading::after {
position: absolute;
left: 0;
right: 0;
bottom: -10px;
content: '';
width: 100%;
height: 2px;
background: #30e3ca;
margin: 0 auto;
}
.heading-section-white {
color: rgba(255, 255, 255, 0.8);
}
.heading-section-white h2 {
/*font-family: ;*/
line-height: 1;
padding-bottom: 0;
}
.heading-section-white h2 {
color: #ffffff;
}
.heading-section-white .subheading {
margin-bottom: 0;
display: inline-block;
font-size: 13px;
text-transform: uppercase;
letter-spacing: 2px;
color: rgba(255, 255, 255, 0.4);
}
ul.social {
padding: 0;
}
ul.social li {
display: inline-block;
margin-right: 10px;
}
.footer {
border-top: 1px solid rgba(0, 0, 0, 0.05);
color: rgba(0, 0, 0, 0.5);
}
.footer .heading {
color: #000;
font-size: 20px;
}
.footer ul {
margin: 0;
padding: 0;
}
.footer ul li {
list-style: none;
margin-bottom: 10px;
}
.footer ul li a {
color: rgba(0, 0, 0, 1);
}
</style>
</head>
<body width="100%" style="margin: 0; padding: 0 !important; mso-line-height-rule: exactly; background-color: #f1f1f1">
<center style="width: 100%; background-color: #f1f1f1">
<div
style="
display: none;
font-size: 1px;
max-height: 0px;
max-width: 0px;
opacity: 0;
overflow: hidden;
mso-hide: all;
font-family: sans-serif;
"
>
&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;
</div>
<div style="max-width: 600px; margin: 0 auto" class="email-container">
<!-- BEGIN BODY -->
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="margin: auto">
<tr>
<td valign="top" class="bg_white" style="padding: 1em 2.5em 0 2.5em">
<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="logo" style="text-align: center">
<h1>
<a href="#"
><img
src="https://res.cloudinary.com/marielascloud/image/upload/v1626333881/DataSurveyLogo2_smr2ok.png"
alt=""
width="300"
/></a>
</h1>
</td>
</tr>
</table>
</td>
</tr>
<!-- end tr -->
<tr>
<td valign="middle" class="hero bg_white" style="padding: 3em 0 2em 0">
<img
src="https://res.cloudinary.com/marielascloud/image/upload/v1626333882/email_v7pjtv.png"
alt=""
style="width: 300px; max-width: 600px; height: auto; margin: auto; display: block"
/>
</td>
</tr>
<!-- end tr -->
<tr>
<td valign="middle" class="hero bg_white" style="padding: 2em 0 4em 0">
<table>
<tr>
<td>
<div class="text" style="padding: 0 2.5em; text-align: center">
<h2 th:text="#{email.public.greeting(${user.login})}">¡Hola!</h2>
<h3 th:text="#{email.public.text1}">
Your JHipster account has been created, please click on the URL below to activate it:
</h3>
</div>
<div class="text" style="padding: 1em 2.5em; text-align: center">
<p>
<span th:text="#{email.public.text2}">Regards, </span>
<br />
<em th:text="#{email.signature}">JHipster.</em>
</p>
</div>
</td>
</tr>
</table>
</td>
</tr>
<!-- end tr -->
<!-- 1 Column Text + Button : END -->
</table>
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="margin: auto">
<tr>
<td valign="middle" class="bg_light footer email-section">
<table>
<tr>
<td valign="top" width="33.333%" style="padding-top: 20px">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-right: 10px">
<h3 class="heading">Acerca de</h3>
<p>DataSurvey es su compañero más cercano para poder recolectar información valiosa para usted</p>
</td>
</tr>
</table>
</td>
<td valign="top" width="33.333%" style="padding-top: 20px">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-left: 5px; padding-right: 5px">
<h3 class="heading">Información de contacto</h3>
<ul>
<li><span href="mailto:datasurveyapp@gmail.com" class="text">datasurveyapp@gmail.com</span></li>
</ul>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<!-- end: tr -->
<tr>
<td class="bg_light" style="text-align: center">
<p><a href="https://datasurvey.org" style="color: rgba(0, 0, 0, 0.8)">DataSurvey.org</a></p>
</td>
</tr>
</table>
</div>
</center>
</body>
</html>

View File

@ -72,6 +72,7 @@ export class AccountService {
shareReplay()
);
}
return this.accountCache$;
}

View File

@ -3,6 +3,8 @@ import { IEncuesta } from '../encuesta.model';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { EncuestaService } from '../service/encuesta.service';
import { EstadoEncuesta } from '../../enumerations/estado-encuesta.model';
import { AccesoEncuesta } from '../../enumerations/acceso-encuesta.model';
import { passwordResetFinishRoute } from '../../../account/password-reset/finish/password-reset-finish.route';
@Component({
selector: 'jhi-encuesta-publish-dialog',
@ -24,10 +26,25 @@ export class EncuestaPublishDialogComponent implements OnInit {
encuesta.estado = EstadoEncuesta.ACTIVE;
}
if (encuesta.acceso === AccesoEncuesta.PRIVATE) {
encuesta.contrasenna = this.generatePassword();
}
this.encuestaService.update(encuesta).subscribe(() => {
this.activeModal.close('published');
});
}
generatePassword(): string {
debugger;
const alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
let password = '';
for (let i = 0; i < 5; i++) {
password += alpha.charAt(Math.floor(Math.random() * alpha.length));
}
return password;
}
ngOnInit(): void {}
}

View File

@ -12,7 +12,12 @@
<jhi-alert-error></jhi-alert-error>
<jhi-alert></jhi-alert>
<div *ngIf="successChange" class="alert alert-success alert-dismissible fade show" role="alert">
El estado del usuario fue modificado correctamente
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="alert alert-warning" id="no-result" *ngIf="usuarioExtras?.length === 0">
<span jhiTranslate="dataSurveyApp.usuarioExtra.home.notFound">No usuarioExtras found</span>

View File

@ -17,6 +17,7 @@ export class UsuarioExtraComponent implements OnInit {
usuarioExtras?: IUsuarioExtra[];
publicUsers?: IUser[];
isLoading = false;
successChange = false;
constructor(protected usuarioExtraService: UsuarioExtraService, protected modalService: NgbModal) {}
@ -73,6 +74,7 @@ export class UsuarioExtraComponent implements OnInit {
// unsubscribe not needed because closed completes on modal close
modalRef.closed.subscribe(reason => {
if (reason === 'deleted') {
this.successChange = true;
this.loadAll();
}
});

View File

@ -74,13 +74,18 @@
<p class="mb-4" style="color: rgba(146, 146, 146, 0.664)">Ingrese su correo electrónico y contraseña</p>
</div>
<div class="alert alert-danger" *ngIf="error" jhiTranslate="login.messages.error.authentication" data-cy="loginError">
<div
class="alert alert-danger"
*ngIf="error && !userSuspended"
jhiTranslate="login.messages.error.authentication"
data-cy="loginError"
>
<strong>Failed to sign in!</strong> Please check your credentials and try again.
</div>
<div
class="alert alert-danger"
*ngIf="userSuspended"
*ngIf="userSuspended && !error"
jhiTranslate="login.messages.error.userSuspended"
data-cy="loginError"
></div>

View File

@ -81,6 +81,9 @@ export class LoginComponent implements OnInit, AfterViewInit {
}
authenticacionGoogle(): void {
this.error = false;
this.userSuspended = false;
this.loginService.login({ username: this.user.email, password: this.user.id, rememberMe: false }).subscribe(
() => {
this.authenticationError = false;
@ -123,6 +126,9 @@ export class LoginComponent implements OnInit, AfterViewInit {
}
activateGoogle(): void {
this.error = false;
this.userSuspended = false;
this.registerService
.save({
login: this.user.email,
@ -145,6 +151,8 @@ export class LoginComponent implements OnInit, AfterViewInit {
}
login(): void {
this.error = false;
this.userSuspended = false;
debugger;
this.loginService
.login({
@ -169,8 +177,14 @@ export class LoginComponent implements OnInit, AfterViewInit {
}
// }
},
response => this.processError(response)
response => {
debugger;
if (response.status == 401 && response.error.detail == 'Bad credentials') {
this.error = true;
} else {
this.processError(response);
}
}
);
}
}