mirror of
https://github.com/flarum/framework.git
synced 2025-06-19 16:51:23 +08:00
Log in immediately after registration
Newly-created accounts are allowed to log in straight away, but they still have the permissions of a guest until they've confirmed their email address. Instead of showing a success message after registration, we reload the page since they're already logged in. Still todo: show a message explaining that they need to verify their email address to do anything, and allow it to be resent.
This commit is contained in:
@ -39,13 +39,6 @@ export default class SignUpModal extends Modal {
|
|||||||
* @type {Function}
|
* @type {Function}
|
||||||
*/
|
*/
|
||||||
this.password = m.prop(this.props.password || '');
|
this.password = m.prop(this.props.password || '');
|
||||||
|
|
||||||
/**
|
|
||||||
* The user that has been signed up and that should be welcomed.
|
|
||||||
*
|
|
||||||
* @type {null|User}
|
|
||||||
*/
|
|
||||||
this.welcomeUser = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
className() {
|
className() {
|
||||||
@ -68,7 +61,7 @@ export default class SignUpModal extends Modal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
body() {
|
body() {
|
||||||
const body = [
|
return [
|
||||||
this.props.token ? '' : <LogInButtons/>,
|
this.props.token ? '' : <LogInButtons/>,
|
||||||
|
|
||||||
<div className="Form Form--centered">
|
<div className="Form Form--centered">
|
||||||
@ -105,36 +98,6 @@ export default class SignUpModal extends Modal {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
];
|
];
|
||||||
|
|
||||||
if (this.welcomeUser) {
|
|
||||||
const user = this.welcomeUser;
|
|
||||||
|
|
||||||
const fadeIn = (element, isInitialized) => {
|
|
||||||
if (isInitialized) return;
|
|
||||||
$(element).hide().fadeIn();
|
|
||||||
};
|
|
||||||
|
|
||||||
body.push(
|
|
||||||
<div className="SignUpModal-welcome" style={{background: user.color()}} config={fadeIn}>
|
|
||||||
<div className="darkenBackground">
|
|
||||||
<div className="container">
|
|
||||||
{avatar(user)}
|
|
||||||
<h3>{app.translator.trans('core.forum.sign_up.welcome_text', {user})}</h3>
|
|
||||||
|
|
||||||
<p>{app.translator.trans('core.forum.sign_up.confirmation_message', {email: <strong>{user.email()}</strong>})}</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<Button className="Button Button--primary" onclick={this.hide.bind(this)}>
|
|
||||||
{app.translator.trans('core.forum.sign_up.dismiss_button')}
|
|
||||||
</Button>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return body;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
footer() {
|
footer() {
|
||||||
@ -181,19 +144,7 @@ export default class SignUpModal extends Modal {
|
|||||||
data,
|
data,
|
||||||
errorHandler: this.onerror.bind(this)
|
errorHandler: this.onerror.bind(this)
|
||||||
}).then(
|
}).then(
|
||||||
payload => {
|
() => window.location.reload(),
|
||||||
const user = app.store.pushPayload(payload);
|
|
||||||
|
|
||||||
// If the user's new account has been activated, then we can assume
|
|
||||||
// that they have been logged in too. Thus, we will reload the page.
|
|
||||||
// Otherwise, we will show a message asking them to check their email.
|
|
||||||
if (user.isActivated()) {
|
|
||||||
window.location.reload();
|
|
||||||
} else {
|
|
||||||
this.welcomeUser = user;
|
|
||||||
this.loaded();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
this.loaded.bind(this)
|
this.loaded.bind(this)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user