fix: Update email action should hit API
This commit is contained in:
@ -22,6 +22,7 @@ const propTypes = {
|
||||
replace: PropTypes.bool,
|
||||
routesMap: PropTypes.object,
|
||||
shouldDispatch: PropTypes.bool,
|
||||
style: PropTypes.object,
|
||||
target: PropTypes.string,
|
||||
to: PropTypes.oneOfType([ PropTypes.object, PropTypes.string ]).isRequired
|
||||
};
|
||||
@ -36,6 +37,7 @@ export const Link = (
|
||||
replace,
|
||||
routesMap,
|
||||
shouldDispatch = true,
|
||||
style,
|
||||
target,
|
||||
to
|
||||
}
|
||||
@ -70,6 +72,7 @@ export const Link = (
|
||||
return (
|
||||
<a
|
||||
onClick={ handler }
|
||||
style={ style }
|
||||
{ ...localProps }
|
||||
>
|
||||
{children}
|
||||
|
@ -24,7 +24,7 @@ export const updateUserFlag = createAction(
|
||||
);
|
||||
// updateUserEmail(username: String, email: String) => Action
|
||||
export const updateUserEmail = createAction(
|
||||
types.updateUserFlag,
|
||||
types.updateUserEmail,
|
||||
(username, email) => ({ username, email })
|
||||
);
|
||||
// updateUserLang(username: String, lang: String) => Action
|
||||
|
@ -184,7 +184,7 @@ export class Settings extends React.Component {
|
||||
className='btn-link-social'
|
||||
onClick={ toggleNightMode }
|
||||
>
|
||||
NightMode
|
||||
Toggle Night Mode
|
||||
</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
|
@ -6,7 +6,6 @@ import { makeToast } from '../../../Toasts/redux';
|
||||
import {
|
||||
fetchChallenges,
|
||||
doActionOnError,
|
||||
|
||||
userSelector
|
||||
} from '../../../redux';
|
||||
import {
|
||||
@ -41,7 +40,7 @@ export function updateUserEmailEpic(actions, { getState }) {
|
||||
const ajaxUpdate = postJSON$('/update-my-email', body)
|
||||
.map(({ message }) => makeToast({ message }))
|
||||
.catch(doActionOnError(() => oldEmail ?
|
||||
updateUserFlag(username, oldEmail) :
|
||||
updateUserEmail(username, oldEmail) :
|
||||
null
|
||||
));
|
||||
return Observable.merge(optimisticUpdate, ajaxUpdate);
|
||||
|
@ -12,7 +12,7 @@ import { reduxForm } from 'redux-form';
|
||||
import { isEmail } from 'validator';
|
||||
|
||||
import { Link } from '../../../../Router';
|
||||
import { getValidationState } from '../../../../utils/form';
|
||||
import { getValidationState, DOMOnlyProps } from '../../../../utils/form';
|
||||
import {
|
||||
onRouteSettings,
|
||||
updateMyEmail
|
||||
@ -93,10 +93,10 @@ export class UpdateEmail extends React.Component {
|
||||
validationState={ getValidationState(email) }
|
||||
>
|
||||
<FormControl
|
||||
autofocus={ true }
|
||||
autoFocus={ true }
|
||||
placeholder='Enter your new email'
|
||||
type='email'
|
||||
{ ...email }
|
||||
{ ...DOMOnlyProps(email) }
|
||||
/>
|
||||
{
|
||||
!email.error ?
|
||||
@ -112,7 +112,7 @@ export class UpdateEmail extends React.Component {
|
||||
<FormControl
|
||||
placeholder='re-type your email address'
|
||||
type='email'
|
||||
{ ...duplicate }
|
||||
{ ...DOMOnlyProps(duplicate) }
|
||||
/>
|
||||
{
|
||||
!duplicate.error ?
|
||||
@ -131,7 +131,10 @@ export class UpdateEmail extends React.Component {
|
||||
{ buttonCopy }
|
||||
</Button>
|
||||
<div className='button-spacer' />
|
||||
<Link to={ onRouteSettings() }>
|
||||
<Link
|
||||
style={{ textDecoration: 'none' }}
|
||||
to={ onRouteSettings() }
|
||||
>
|
||||
<Button
|
||||
block={ true }
|
||||
bsSize='lg'
|
||||
|
@ -574,6 +574,7 @@ module.exports = function(User) {
|
||||
) {
|
||||
const ownEmail = newEmail === this.email;
|
||||
if (!isEmail('' + newEmail)) {
|
||||
debug('invalid email:', newEmail );
|
||||
return Observable.throw(createEmailError());
|
||||
}
|
||||
// email is already associated and verified with this account
|
||||
|
Reference in New Issue
Block a user