Skip to content

EspoCRM – Open Source CRM Application

login form view password

Yuri Kuznetsov3008f4762050
diff --git a/client/res/templates/login.tpl b/client/res/templates/login.tpl
index b581e9608c..13dc12a06b 100644
--- a/client/res/templates/login.tpl
+++ b/client/res/templates/login.tpl
@@ -29,7 +29,7 @@
</div>
{{/if}}
<div class="form-group cell" data-name="username">
- <label for="field-username">{{translate 'Username'}}</label>
+ <label for="field-userName">{{translate 'Username'}}</label>
<input
type="text"
name="username"
@@ -43,16 +43,24 @@
>
</div>
<div class="form-group cell" data-name="password">
- <label for="login">{{translate 'Password'}}</label>
- <input
- type="password"
- name="password"
- id="field-password"
- class="form-control"
- tabindex="2"
- autocomplete="current-password"
- maxlength="255"
- >
+ <label for="field-password">{{translate 'Password'}}</label>
+ <div data-role="password-input-container">
+ <input
+ type="password"
+ name="password"
+ id="field-password"
+ class="form-control"
+ tabindex="2"
+ autocomplete="current-password"
+ maxlength="255"
+ >
+ <a
+ role="button"
+ data-action="toggleShowPassword"
+ class="text-soft"
+ title="{{translate 'View'}}"
+ ><span class="far fa-eye"></span></a>
+ </div>
</div>
{{#if anotherUser}}
<div class="form-group cell">
diff --git a/client/src/views/login.js b/client/src/views/login.js
index 14e2441fed..a4ccfecc7c 100644
--- a/client/src/views/login.js
+++ b/client/src/views/login.js
@@ -127,6 +127,8 @@ class LoginView extends View {
/** @inheritDoc */
setup() {
+ this.addActionHandler('toggleShowPassword', () => this.toggleShowPassword());
+
this.anotherUser = this.options.anotherUser || null;
const loginData = this.getConfig().get('loginData') || {};
@@ -435,6 +437,30 @@ class LoginView extends View {
Espo.Ui.notify(false);
});
}
+
+ /**
+ * @private
+ */
+ toggleShowPassword() {
+ const input = this.element.querySelector('[id="field-password"]');
+ const button = this.element.querySelector('[data-action="toggleShowPassword"]');
+
+ if (!(input instanceof HTMLInputElement)) {
+ return;
+ }
+
+ if (input.type === 'password') {
+ input.type = 'text';
+
+ button.classList.remove('text-soft');
+ button.classList.add('text-primary');
+ } else {
+ input.type = 'password';
+
+ button.classList.remove('text-primary');
+ button.classList.add('text-soft');
+ }
+ }
}
export default LoginView;
diff --git a/frontend/less/espo/custom.less b/frontend/less/espo/custom.less
index 4467bda108..b210ee01fd 100644
--- a/frontend/less/espo/custom.less
+++ b/frontend/less/espo/custom.less
@@ -4280,6 +4280,21 @@ body > .autocomplete-suggestions.text-search-suggestions {
}
}
+[data-role="password-input-container"] {
+ position: relative;
+
+ input {
+ padding-right: var(--32px);
+ }
+
+ a[data-action="toggleShowPassword"] {
+ position: absolute;
+ right: var(--8px);
+ top: var(--8px);
+ user-select: none;
+ }
+}
+
@import "misc/kanban.less";
@import "misc/wysiwyg.less";