email http functions
This commit is contained in:
@@ -28,6 +28,17 @@ const addState = connect(
|
||||
.catch(error => errorToast(error));
|
||||
}
|
||||
|
||||
function setEmail(email) {
|
||||
postData('/account/email', { email })
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
if (!data.success) return errorToast(data.error_message);
|
||||
infoToast('Email set. Please confirm your address.');
|
||||
return true;
|
||||
})
|
||||
.catch(error => errorToast(error));
|
||||
}
|
||||
|
||||
function logout() {
|
||||
postData('/account/logout').then(() => window.location.reload(true));
|
||||
}
|
||||
@@ -42,6 +53,7 @@ const addState = connect(
|
||||
ping,
|
||||
logout,
|
||||
setPassword,
|
||||
setEmail,
|
||||
sendConstructSpawn,
|
||||
};
|
||||
},
|
||||
@@ -54,6 +66,7 @@ class AccountStatus extends Component {
|
||||
|
||||
this.state = {
|
||||
setPassword: { current: '', password: '', confirm: ''},
|
||||
email: null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -63,6 +76,7 @@ class AccountStatus extends Component {
|
||||
ping,
|
||||
logout,
|
||||
setPassword,
|
||||
setEmail,
|
||||
sendConstructSpawn,
|
||||
} = args;
|
||||
|
||||
@@ -84,13 +98,13 @@ class AccountStatus extends Component {
|
||||
<dt>Subscription</dt>
|
||||
<dd>{account.subscribed ? 'some date' : 'unsubscribed'}</dd>
|
||||
</dl>
|
||||
<button><a href={`mailto:support@mnml.gg?subject=Account%20Support:%20${account.name}`}>✉ support</a></button>
|
||||
<button><a href={`mailto:humans@mnml.gg?subject=Account%20Support:%20${account.name}`}>✉ support</a></button>
|
||||
<button onClick={() => logout()}>Logout</button>
|
||||
</div>
|
||||
<div>
|
||||
<label for="email">Email:</label>
|
||||
<label for="email">Email Settings:</label>
|
||||
<dl>
|
||||
<dt>Current Email</dt>
|
||||
<dt>Recovery Email</dt>
|
||||
<dd>{account.email ? account.email : 'No email set'}</dd>
|
||||
<dt>Status</dt>
|
||||
<dd>{account.email_confirmed ? 'Confirmed' : 'Unconfirmed'}</dd>
|
||||
@@ -99,9 +113,11 @@ class AccountStatus extends Component {
|
||||
class="login-input"
|
||||
type="email"
|
||||
name="email"
|
||||
placeholder="new email"
|
||||
value={this.state.email}
|
||||
onInput={linkState(this, 'email')}
|
||||
placeholder="recovery@email.tld"
|
||||
/>
|
||||
<button>Update</button>
|
||||
<button onClick={() => setEmail(this.state.email)}>Update</button>
|
||||
</div>
|
||||
<div>
|
||||
<label for="current">Password:</label>
|
||||
|
||||
Reference in New Issue
Block a user