@igea/oac_frontend 1.0.21 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@igea/oac_frontend",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "Frontend service for the OAC project",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -2,7 +2,7 @@
2
2
  "protocol": "http",
3
3
  "url_register": "http://localhost:4001/register",
4
4
  "port_range": {
5
- "min": 5000, "max": 6000
5
+ "min": 4200, "max": 4299
6
6
  },
7
7
  "jwt_secret": "@igea#"
8
8
  }
@@ -2,7 +2,7 @@
2
2
  "protocol": "http",
3
3
  "url_register": "http://localhost:4001/register",
4
4
  "port_range": {
5
- "min": 5000, "max": 6000
5
+ "min": 4200, "max": 4299
6
6
  },
7
7
  "jwt_secret": "@igea#"
8
8
  }
@@ -40,6 +40,18 @@ module.exports = function(serviceName) {
40
40
 
41
41
  });
42
42
 
43
+ router.get('/reset_password/:id/:token', (req, res) => {
44
+ let data = new DataModel(req, {
45
+ root: serviceName,
46
+ title: 'Reset password',
47
+ user: {
48
+ id: req.params.id,
49
+ token: req.params.token
50
+ }
51
+ });
52
+ res.render('users/reset_password.twig', data.toJson());
53
+ });
54
+
43
55
  return router
44
56
  }
45
57
 
package/src/index.js CHANGED
@@ -12,6 +12,8 @@ const jwtLib = jwtLibFactory({
12
12
  secret: process.env.JWT_SECRET || config.jwt_secret,
13
13
  excludePaths: [
14
14
  `/${serviceName}/`,
15
+ `/${serviceName}/password_recovery`,
16
+ new RegExp(`^/${serviceName}/users/reset_password/[^/]+/[^/]+$`),
15
17
  `/${serviceName}/health`,
16
18
  `/${serviceName}/captcha/random-image`
17
19
  ],
@@ -90,6 +92,9 @@ getPort.default({
90
92
  app.get(`/${serviceName}`, (req, res) => {
91
93
  res.render('login', { root: serviceName, title: 'Login' });
92
94
  });
95
+ app.get(`/${serviceName}/password_recovery`, (req, res) => {
96
+ res.render('password_recovery', { root: serviceName, title: 'Password recovery' });
97
+ });
93
98
  app.get(`/${serviceName}/home`, (req, res) => {
94
99
  let data = new DataModel(req, {
95
100
  root: serviceName,
@@ -4,9 +4,21 @@
4
4
  "title": "Login",
5
5
  "user": "Email or Username",
6
6
  "password": "Password",
7
+ "password_recovery": "Forgot your password?",
8
+ "invalid_user": "Invalid username or password",
7
9
  "sign_in": "Sign in",
8
10
  "anonymous": "Anonymous"
9
11
  },
12
+ "password_recovery": {
13
+ "title": "Password recovery",
14
+ "instructions": "Enter your email address or username to receive password recovery instructions.",
15
+ "email": "Email",
16
+ "send_instructions": "Send instructions",
17
+ "back_to_login": "Back to login",
18
+ "invalid_email": "Invalid email address",
19
+ "email_sent": "Instructions have been sent to your email address, if it exists in our system."
20
+ "password_reset_success": "Your password has been reset successfully. You can now log in with your new password."
21
+ },
10
22
  "users": {
11
23
  "manage": {
12
24
  "title": "Users",
@@ -4,9 +4,21 @@
4
4
  "title": "Accesso",
5
5
  "user": "Email o Nome utente",
6
6
  "password": "Password",
7
+ "password_recovery": "Hai dimenticato la password?",
8
+ "invalid_user": "Nome utente o password non validi",
7
9
  "sign_in": "Accedi",
8
10
  "anonymous": "Anonimo"
9
11
  },
12
+ "password_recovery": {
13
+ "title": "Recupero password",
14
+ "instructions": "Inserisci il tuo indirizzo email o nome utente per ricevere le istruzioni di recupero della password.",
15
+ "email": "Email",
16
+ "send_instructions": "Invia istruzioni",
17
+ "back_to_login": "Torna al login",
18
+ "invalid_email": "Indirizzo email non valido",
19
+ "email_sent": "Le istruzioni sono state inviate al tuo indirizzo email, se esiste nel nostro sistema.",
20
+ "password_reset_success": "La tua password è stata reimpostata con successo. Ora puoi accedere con la tua nuova password."
21
+ },
10
22
  "users": {
11
23
  "manage": {
12
24
  "title": "Utenti",
@@ -1,6 +1,6 @@
1
1
  onSubmit = function(type){
2
-
3
- axios.post("/backend/auth/authenticate", {
2
+ var url = "/backend/auth/authenticate";
3
+ axios.post(url, {
4
4
  type: type,
5
5
  user: (type == "login") ?
6
6
  document.getElementById("username").value : "",
@@ -11,5 +11,4 @@ onSubmit = function(type){
11
11
  }).catch(error => {
12
12
  console.log(error);
13
13
  });
14
-
15
14
  }
@@ -0,0 +1,32 @@
1
+ function passwordrecoveryInit(options={}){
2
+
3
+ window.onSubmit = function(){
4
+ var url = "/backend/auth/password_recovery";
5
+ axios.post(url, {
6
+ user: document.getElementById("username").value
7
+ }).then(response => {
8
+ alert(options.labels.email_sent);
9
+ window.location = "/frontend/";
10
+ }).catch(error => {
11
+ console.log(error);
12
+ });
13
+ }
14
+
15
+ window.onSubmitReset = function(){
16
+
17
+ alert(options.labels.reset_success);
18
+ window.location = "/frontend/";
19
+ /*
20
+ var url = "/backend/auth/password_recovery";
21
+ axios.post(url, {
22
+ user: document.getElementById("username").value
23
+ }).then(response => {
24
+ alert(options.labels.email_sent);
25
+ window.location = "/frontend/";
26
+ }).catch(error => {
27
+ console.log(error);
28
+ });
29
+ */
30
+ }
31
+
32
+ }
@@ -14,12 +14,16 @@
14
14
  <div>
15
15
  <label for="username">{{ t('login.user') }}</label>
16
16
  {% if invalidLogin %}
17
- <span class=".login-message">Invalid credentials</span>
17
+ <span class=".login-message">{{ t('login.invalid_user') }}</span>
18
18
  {% endif %}
19
19
  <input type="text" id="username" name="username" required />
20
20
  <label for="password">{{ t('login.password') }}</label>
21
21
  <input type="password" id="password" name="password" required />
22
22
  <button onclick="onSubmit('login')">{{ t('login.sign_in') }}</button>
23
+ <a href="/{{ root }}/password_recovery">
24
+ <i class="fa-solid fa-key"></i>
25
+ <span>{{ t('login.password_recovery') }}</span>
26
+ </a>
23
27
  <button onclick="onSubmit('anonymous');" style="background: #ff0000">
24
28
  {{ t('login.anonymous') }}</button>
25
29
  </div>
@@ -0,0 +1,28 @@
1
+ {% set showSidebar = false %}
2
+
3
+ {% extends "base.twig" %}
4
+
5
+ {% block extendHead %}
6
+ <link rel="stylesheet" href="/{{ root }}/css/login.css">
7
+ <script src="/{{ root }}/js/login/password_recovery.js"></script>
8
+ {% endblock %}
9
+
10
+ {% block content %}
11
+
12
+ <div class="login-container">
13
+ <h2><i class="fa-solid fa-key"></i> {{ t('password_recovery.title') }}</h2>
14
+ <h6>{{ t('password_recovery.instructions') }}</h6>
15
+ <div>
16
+ <input type="text" id="username" name="username" required />
17
+ <button onclick="onSubmit()">{{ t('password_recovery.send_instructions') }}</button>
18
+ </div>
19
+ </div>
20
+ <script>
21
+ passwordrecoveryInit({
22
+ labels: {
23
+ email_sent: "{{ t('password_recovery.email_sent') }}"
24
+ }
25
+ });
26
+ </script>
27
+
28
+ {% endblock %}
@@ -0,0 +1,36 @@
1
+ {% set showSidebar = false %}
2
+
3
+ {% extends "../base.twig" %}
4
+
5
+ {% block extendHead %}
6
+ <link rel="stylesheet" href="/{{ root }}/css/login.css">
7
+ <script src="/{{ root }}/js/login/password_recovery.js"></script>
8
+ {% endblock %}
9
+
10
+ {% block content %}
11
+
12
+ <div class="login-container">
13
+ <h2><i class="fa-solid fa-key"></i> {{ t('password_recovery.title') }}</h2>
14
+ <div>
15
+
16
+ <label for="password">{{ t('users.edit.password') }}</label>
17
+ <input type="password" id="password" name="password" required />
18
+
19
+ <label for="re_password">{{ t('users.edit.confirm_password') }}</label>
20
+ <input type="password" id="re_password" name="re_password" required />
21
+
22
+ <button onclick="onSubmitReset()">{{ t('users.edit.save') }}</button>
23
+
24
+ </div>
25
+ </div>
26
+ <script>
27
+ passwordrecoveryInit({
28
+ user: {{ user.id}},
29
+ token: "{{ user.token}}",
30
+ labels: {
31
+ reset_success: "{{ t('password_recovery.password_reset_success') }}"
32
+ }
33
+ });
34
+ </script>
35
+
36
+ {% endblock %}