[FIX] When creating a new user, "Custom Fields" are breaking functionality (#4501)
This commit is contained in:
parent
1bc3f542f2
commit
cf7b9a09f4
|
@ -13,6 +13,7 @@ interface ILoginRequest extends Action {
|
|||
credentials: any;
|
||||
logoutOnError?: boolean;
|
||||
isFromWebView?: boolean;
|
||||
registerCustomFields?: any;
|
||||
}
|
||||
|
||||
interface ILoginSuccess extends Action {
|
||||
|
@ -56,13 +57,15 @@ export type TActionsLogin = ILoginRequest &
|
|||
export function loginRequest(
|
||||
credentials: Partial<ICredentials>,
|
||||
logoutOnError?: boolean,
|
||||
isFromWebView?: boolean
|
||||
isFromWebView?: boolean,
|
||||
registerCustomFields?: any
|
||||
): ILoginRequest {
|
||||
return {
|
||||
type: types.LOGIN.REQUEST,
|
||||
credentials,
|
||||
logoutOnError,
|
||||
isFromWebView
|
||||
isFromWebView,
|
||||
registerCustomFields
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,12 @@ const loginWithPasswordCall = args => Services.loginWithPassword(args);
|
|||
const loginCall = (credentials, isFromWebView) => Services.login(credentials, isFromWebView);
|
||||
const logoutCall = args => logout(args);
|
||||
|
||||
const handleLoginRequest = function* handleLoginRequest({ credentials, logoutOnError = false, isFromWebView = false }) {
|
||||
const handleLoginRequest = function* handleLoginRequest({
|
||||
credentials,
|
||||
logoutOnError = false,
|
||||
isFromWebView = false,
|
||||
registerCustomFields
|
||||
}) {
|
||||
logEvent(events.LOGIN_DEFAULT_LOGIN);
|
||||
try {
|
||||
let result;
|
||||
|
@ -78,6 +83,10 @@ const handleLoginRequest = function* handleLoginRequest({ credentials, logoutOnE
|
|||
}
|
||||
});
|
||||
yield put(loginSuccess(result));
|
||||
if (registerCustomFields) {
|
||||
const updatedUser = yield call(Services.saveUserProfile, {}, { ...registerCustomFields });
|
||||
yield put(setUser({ ...result, ...updatedUser.user }));
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (e?.data?.message && /you've been logged out by the server/i.test(e.data.message)) {
|
||||
|
|
|
@ -127,14 +127,13 @@ class RegisterView extends React.Component<IProps, any> {
|
|||
const { dispatch, Accounts_EmailVerification, navigation, Accounts_ManuallyApproveNewUsers } = this.props;
|
||||
|
||||
try {
|
||||
await Services.register({
|
||||
const user = await Services.register({
|
||||
name,
|
||||
email,
|
||||
pass: password,
|
||||
username,
|
||||
...customFields
|
||||
username
|
||||
});
|
||||
|
||||
if (user.success) {
|
||||
if (Accounts_EmailVerification) {
|
||||
await navigation.goBack();
|
||||
showErrorAlert(I18n.t('Verify_email_desc'), I18n.t('Registration_Succeeded'));
|
||||
|
@ -142,7 +141,8 @@ class RegisterView extends React.Component<IProps, any> {
|
|||
await navigation.goBack();
|
||||
showErrorAlert(I18n.t('Wait_activation_warning'), I18n.t('Registration_Succeeded'));
|
||||
} else {
|
||||
dispatch(loginRequest({ user: email, password }));
|
||||
dispatch(loginRequest({ user: email, password }, false, false, customFields));
|
||||
}
|
||||
}
|
||||
} catch (e: any) {
|
||||
if (e.data?.errorType === 'username-invalid') {
|
||||
|
|
Loading…
Reference in New Issue