diff --git a/js/forum/src/components/login-modal.js b/js/forum/src/components/login-modal.js index 8b794409d..e298787b2 100644 --- a/js/forum/src/components/login-modal.js +++ b/js/forum/src/components/login-modal.js @@ -9,8 +9,8 @@ export default class LoginModal extends FormModal { constructor(props) { super(props); - this.email = m.prop(); - this.password = m.prop(); + this.email = m.prop(this.props.email || ''); + this.password = m.prop(this.props.password || ''); } view() { @@ -19,10 +19,10 @@ export default class LoginModal extends FormModal { title: 'Log In', body: [ m('div.form-group', [ - m('input.form-control[name=email][placeholder=Username or Email]', {onchange: m.withAttr('value', this.email), disabled: this.loading()}) + m('input.form-control[name=email][placeholder=Username or Email]', {value: this.email(), onchange: m.withAttr('value', this.email), disabled: this.loading()}) ]), m('div.form-group', [ - m('input.form-control[type=password][name=password][placeholder=Password]', {onchange: m.withAttr('value', this.password), disabled: this.loading()}) + m('input.form-control[type=password][name=password][placeholder=Password]', {value: this.password(), onchange: m.withAttr('value', this.password), disabled: this.loading()}) ]), m('div.form-group', [ m('button.btn.btn-primary.btn-block[type=submit]', {disabled: this.loading()}, 'Log In') @@ -32,7 +32,12 @@ export default class LoginModal extends FormModal { m('p.forgot-password-link', m('a[href=javascript:;]', {onclick: () => app.modal.show(new ForgotPasswordModal({email: this.email()}))}, 'Forgot password?')), m('p.sign-up-link', [ 'Don\'t have an account? ', - m('a[href=javascript:;]', {onclick: () => app.modal.show(new SignupModal())}, 'Sign Up') + m('a[href=javascript:;]', {onclick: () => { + var props = {password: this.password()}; + var email = this.email(); + props[email.indexOf('@') !== -1 ? 'email' : 'username'] = email; + app.modal.show(new SignupModal(props)); + }}, 'Sign Up') ]) ] }); diff --git a/js/forum/src/components/signup-modal.js b/js/forum/src/components/signup-modal.js index a7cadf3be..8777b991e 100644 --- a/js/forum/src/components/signup-modal.js +++ b/js/forum/src/components/signup-modal.js @@ -9,9 +9,9 @@ export default class SignupModal extends FormModal { constructor(props) { super(props); - this.username = m.prop(); - this.email = m.prop(); - this.password = m.prop(); + this.username = m.prop(this.props.username || ''); + this.email = m.prop(this.props.email || ''); + this.password = m.prop(this.props.password || ''); this.welcomeUser = m.prop(); } @@ -24,13 +24,13 @@ export default class SignupModal extends FormModal { title: 'Sign Up', body: [ m('div.form-group', [ - m('input.form-control[name=username][placeholder=Username]', {onchange: m.withAttr('value', this.username), disabled: this.loading()}) + m('input.form-control[name=username][placeholder=Username]', {value: this.username(), onchange: m.withAttr('value', this.username), disabled: this.loading()}) ]), m('div.form-group', [ - m('input.form-control[name=email][placeholder=Email]', {onchange: m.withAttr('value', this.email), disabled: this.loading()}) + m('input.form-control[name=email][placeholder=Email]', {value: this.email(), onchange: m.withAttr('value', this.email), disabled: this.loading()}) ]), m('div.form-group', [ - m('input.form-control[type=password][name=password][placeholder=Password]', {onchange: m.withAttr('value', this.password), disabled: this.loading()}) + m('input.form-control[type=password][name=password][placeholder=Password]', {value: this.password(), onchange: m.withAttr('value', this.password), disabled: this.loading()}) ]), m('div.form-group', [ m('button.btn.btn-primary.btn-block[type=submit]', {disabled: this.loading()}, 'Sign Up') @@ -39,7 +39,7 @@ export default class SignupModal extends FormModal { footer: [ m('p.log-in-link', [ 'Already have an account? ', - m('a[href=javascript:;]', {onclick: () => app.modal.show(new LoginModal())}, 'Log In') + m('a[href=javascript:;]', {onclick: () => app.modal.show(new LoginModal({email: this.email() || this.username(), password: this.password()}))}, 'Log In') ]) ] });