mirror of
https://github.com/documize/community.git
synced 2025-07-28 17:49:41 +02:00
WIP refactor password reset route to use a component
This commit is contained in:
parent
1eff761336
commit
a66fc70ab3
4 changed files with 78 additions and 20 deletions
57
app/app/components/password-reset.js
Normal file
57
app/app/components/password-reset.js
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
import Ember from 'ember';
|
||||||
|
|
||||||
|
const {
|
||||||
|
isEmpty,
|
||||||
|
isEqual,
|
||||||
|
|
||||||
|
} = Ember;
|
||||||
|
|
||||||
|
export default Ember.Component.extend({
|
||||||
|
password: "",
|
||||||
|
passwordConfirm: "",
|
||||||
|
mustMatch: false,
|
||||||
|
passwordEmpty: computed('passwordError', {
|
||||||
|
get() {
|
||||||
|
if (this.get('passwordError')) {
|
||||||
|
return `error`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
confirmEmpty: computed('passwordConfirmError', {
|
||||||
|
get() {
|
||||||
|
if (this.get('passwordConfirmError')) {
|
||||||
|
return `error`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
reset() {
|
||||||
|
let password = this.get('password');
|
||||||
|
let passwordConfirm = this.get('passwordConfirm');
|
||||||
|
|
||||||
|
if (isEmpty(password)) {
|
||||||
|
Ember.set(this, 'passwordError', true);
|
||||||
|
return $("#newPassword").focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isEmpty(passwordConfirm)) {
|
||||||
|
Ember.set(this, 'passwordConfirmError', true);
|
||||||
|
return $("#passwordConfirm").focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isEqual(password, passwordConfirm)) {
|
||||||
|
$("#newPassword").addClass("error").focus();
|
||||||
|
$("#passwordConfirm").addClass("error");
|
||||||
|
this.set('mustMatch', true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.get('reset')();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
|
@ -2,23 +2,5 @@
|
||||||
<div class="logo">
|
<div class="logo">
|
||||||
<img src="assets/img/logo-color.png" title="Documize" alt="Documize" class="responsive-img" />
|
<img src="assets/img/logo-color.png" title="Documize" alt="Documize" class="responsive-img" />
|
||||||
</div>
|
</div>
|
||||||
<div class="login-form">
|
{{password-reset reset=(action 'reset')}}
|
||||||
<form {{action 'reset' on="submit"}}>
|
|
||||||
<div class="input-control">
|
|
||||||
<label>New Password</label>
|
|
||||||
<div class="tip">Choose a strong password</div>
|
|
||||||
{{focus-input type="password" value=password id="newPassword"}}
|
|
||||||
</div>
|
|
||||||
<div class="input-control">
|
|
||||||
<label>Confirm Password</label>
|
|
||||||
<div class="tip">Please type your new password again</div>
|
|
||||||
{{input type="password" value=passwordConfirm id="passwordConfirm"}}
|
|
||||||
</div>
|
|
||||||
<div class="clearfix" />
|
|
||||||
<div class="margin-top-10 margin-bottom-20">
|
|
||||||
<button type="submit" class="regular-button button-blue">Reset</button>
|
|
||||||
<span class="{{unless mustMatch "hide"}} color-red margin-left-20">Passwords must match</span>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
19
app/app/templates/components/password-reset.hbs
Normal file
19
app/app/templates/components/password-reset.hbs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<div class="login-form">
|
||||||
|
<form {{action 'reset' on="submit"}}>
|
||||||
|
<div class="input-control">
|
||||||
|
<label>New Password</label>
|
||||||
|
<div class="tip">Choose a strong password</div>
|
||||||
|
{{focus-input type="password" value=password id="newPassword" class=passwordError}}
|
||||||
|
</div>
|
||||||
|
<div class="input-control">
|
||||||
|
<label>Confirm Password</label>
|
||||||
|
<div class="tip">Please type your new password again</div>
|
||||||
|
{{input type="password" value=passwordConfirm id="passwordConfirm" class=confirmEmpty}}
|
||||||
|
</div>
|
||||||
|
<div class="clearfix" />
|
||||||
|
<div class="margin-top-10 margin-bottom-20">
|
||||||
|
<button type="submit" class="regular-button button-blue">Reset</button>
|
||||||
|
<span class="{{unless mustMatch "hide"}} color-red margin-left-20">Passwords must match</span>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
Loading…
Add table
Add a link
Reference in a new issue