Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions app/client/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -937,9 +937,6 @@ Cypress.Commands.add("SignupFromAPI", (uname, pword) => {
cy.request({
method: "POST",
url: "api/v1/users",
headers: {
"content-type": "application/json",
},
followRedirect: false,
form: true,
body: {
Expand Down
36 changes: 0 additions & 36 deletions app/client/src/ce/api/UserApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,6 @@ import type { ApiResponse } from "api/ApiResponses";
import type { FeatureFlags } from "ee/entities/FeatureFlag";
import type { ProductAlert } from "../../reducers/uiReducers/usersReducer";

export interface LoginUserRequest {
email: string;
password: string;
}

export interface CreateUserRequest {
email: string;
password: string;
}

export type CreateUserResponse = ApiResponse & {
email: string;
id: string;
};

export interface ForgotPasswordRequest {
email: string;
}
Expand All @@ -34,14 +19,6 @@ export interface VerifyTokenRequest {
token: string;
}

export type FetchUserResponse = ApiResponse & {
id: string;
};

export interface FetchUserRequest {
id: string;
}

export interface LeaveWorkspaceRequest {
workspaceId: string;
}
Expand Down Expand Up @@ -79,7 +56,6 @@ export class UserApi extends Api {
static inviteUserURL = "v1/users/invite";
static verifyInviteTokenURL = `${UserApi.inviteUserURL}/verify`;
static confirmUserInviteURL = `${UserApi.inviteUserURL}/confirm`;
static addWorkspaceURL = `${UserApi.usersURL}/addWorkspace`;
static leaveWorkspaceURL = `${UserApi.usersURL}/leaveWorkspace`;
static logoutURL = "v1/logout";
static currentUserURL = "v1/users/me";
Expand All @@ -89,24 +65,12 @@ export class UserApi extends Api {
static restartServerURL = "v1/admin/restart";
static sendTestEmailURL = "/v1/admin/send-test-email";

static async createUser(
request: CreateUserRequest,
): Promise<AxiosPromise<CreateUserResponse>> {
return Api.post(UserApi.usersURL, request);
}

static async updateUser(
request: UpdateUserRequest,
): Promise<AxiosPromise<ApiResponse>> {
return Api.put(UserApi.usersURL, request);
}

static async fetchUser(
request: FetchUserRequest,
): Promise<AxiosPromise<FetchUserResponse>> {
return Api.get(UserApi.usersURL + "/" + request.id);
}

static async getCurrentUser(): Promise<AxiosPromise<ApiResponse>> {
return Api.get(UserApi.currentUserURL);
}
Expand Down
3 changes: 0 additions & 3 deletions app/client/src/ce/constants/ReduxActionConstants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,6 @@ const SnippingModeActionTypes = {
};

const UserAuthActionTypes = {
CREATE_USER_INIT: "CREATE_USER_INIT",
CREATE_USER_SUCCESS: "CREATE_USER_SUCCESS",
RESET_USER_PASSWORD_INIT: "RESET_USER_PASSWORD_INIT",
RESET_USER_PASSWORD_SUCCESS: "RESET_USER_PASSWORD_SUCCESS",
FORGOT_PASSWORD_INIT: "FORGOT_PASSWORD_INIT",
Expand All @@ -370,7 +368,6 @@ const UserAuthActionTypes = {
GET_OAUTH_ACCESS_TOKEN_SUCCESS: "GET_OAUTH_ACCESS_TOKEN_SUCCESS",
};
const UserAuthActionErrorTypes = {
CREATE_USER_ERROR: "CREATE_USER_ERROR",
RESET_USER_PASSWORD_ERROR: "RESET_USER_PASSWORD_ERROR",
FORGOT_PASSWORD_ERROR: "FORGOT_PASSWORD_ERROR",
RESET_PASSWORD_VERIFY_TOKEN_ERROR: "RESET_PASSWORD_VERIFY_TOKEN_ERROR",
Expand Down
52 changes: 0 additions & 52 deletions app/client/src/ce/sagas/userSagas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import {
} from "ee/constants/ReduxActionConstants";
import { reset } from "redux-form";
import type {
CreateUserRequest,
CreateUserResponse,
ForgotPasswordRequest,
VerifyTokenRequest,
TokenPasswordUpdateRequest,
Expand Down Expand Up @@ -87,56 +85,6 @@ import type {
} from "reducers/uiReducers/usersReducer";
import { selectFeatureFlags } from "ee/selectors/featureFlagsSelectors";
import { getFromServerWhenNoPrefetchedResult } from "sagas/helper";
import * as Sentry from "@sentry/react";
import { Severity } from "@sentry/react";
export function* createUserSaga(
action: ReduxActionWithPromise<CreateUserRequest>,
) {
const { email, password, reject, resolve } = action.payload;

try {
const request: CreateUserRequest = { email, password };
const response: CreateUserResponse = yield callAPI(
UserApi.createUser,
request,
);
//TODO(abhinav): DRY this
const isValidResponse: boolean = yield validateResponse(response);

if (!isValidResponse) {
const errorMessage = getResponseErrorMessage(response);

yield call(reject, { _error: errorMessage });
} else {
//@ts-expect-error: response is of type unknown
const { email, id, name } = response.data;

yield put({
type: ReduxActionTypes.CREATE_USER_SUCCESS,
payload: {
email,
name,
id,
},
});
yield call(resolve);
}
} catch (error) {
yield call(reject, { _error: (error as Error).message });
yield put({
type: ReduxActionErrorTypes.CREATE_USER_ERROR,
payload: {
error,
},
});
Sentry.captureException("Sign up failed", {
level: Severity.Error,
extra: {
error: error,
},
});
}
}

export function* waitForSegmentInit(skipWithAnonymousId: boolean) {
if (skipWithAnonymousId && AnalyticsUtil.getAnonymousId()) return;
Expand Down
2 changes: 0 additions & 2 deletions app/client/src/ee/sagas/userSagas.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export * from "ce/sagas/userSagas";
import {
createUserSaga,
getCurrentUserSaga,
runUserSideEffectsSaga,
forgotPasswordSaga,
Expand All @@ -23,7 +22,6 @@ import { takeLatest, all } from "redux-saga/effects";

export default function* userSagas() {
yield all([
takeLatest(ReduxActionTypes.CREATE_USER_INIT, createUserSaga),
takeLatest(ReduxActionTypes.FETCH_USER_INIT, getCurrentUserSaga),
takeLatest(
ReduxActionTypes.FETCH_USER_DETAILS_SUCCESS,
Expand Down
74 changes: 7 additions & 67 deletions app/client/src/pages/UserAuth/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ReduxActionTypes } from "ee/constants/ReduxActionConstants";
import { SubmissionError } from "redux-form";
import { useCallback, useEffect, useState } from "react";
import type { Dispatch } from "redux";
import * as Sentry from "@sentry/react";
import UserApi from "ee/api/UserApi";
import { toast } from "@appsmith/ads";
Expand All @@ -24,48 +25,17 @@ export interface ResetPasswordFormValues {
email?: string;
}

export type CreatePasswordFormValues = ResetPasswordFormValues;

export interface ForgotPasswordFormValues {
email?: string;
}

export const signupFormSubmitHandler = async (
values: SignupFormValues,
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
dispatch: any,
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
): Promise<any> => {
const { email, password } = values;

return new Promise((resolve, reject) => {
dispatch({
type: ReduxActionTypes.CREATE_USER_INIT,
payload: {
resolve,
reject,
email,
password,
},
});
}).catch((error) => {
throw new SubmissionError(error);
});
};

export const resetPasswordSubmitHandler = async (
values: ResetPasswordFormValues,
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
dispatch: any,
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
): Promise<any> => {
dispatch: Dispatch,
): Promise<undefined> => {
const { email, password, token } = values;

return new Promise((resolve, reject) => {
return new Promise<undefined>((resolve, reject) => {
dispatch({
type: ReduxActionTypes.RESET_USER_PASSWORD_INIT,
payload: {
Expand All @@ -81,43 +51,13 @@ export const resetPasswordSubmitHandler = async (
});
};

export const createPasswordSubmitHandler = async (
values: CreatePasswordFormValues,
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
dispatch: any,
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
): Promise<any> => {
const { email, password, token } = values;

return new Promise((resolve, reject) => {
dispatch({
type: ReduxActionTypes.INVITED_USER_SIGNUP_INIT,
payload: {
resolve,
reject,
token,
email,
password,
},
});
}).catch((error) => {
throw new SubmissionError(error);
});
};

export const forgotPasswordSubmitHandler = async (
values: ForgotPasswordFormValues,
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
dispatch: any,
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
): Promise<any> => {
dispatch: Dispatch,
): Promise<undefined> => {
const { email } = values;

return new Promise((resolve, reject) => {
return new Promise<undefined>((resolve, reject) => {
dispatch({
type: ReduxActionTypes.FORGOT_PASSWORD_INIT,
payload: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.appsmith.server.solutions.UserAndAccessManagementService;
import com.appsmith.server.solutions.UserSignup;
import com.fasterxml.jackson.annotation.JsonView;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
Expand Down Expand Up @@ -53,15 +52,6 @@ public class UserControllerCE {
private final UserDataService userDataService;
private final UserAndAccessManagementService userAndAccessManagementService;

@JsonView(Views.Public.class)
@PostMapping(consumes = {MediaType.APPLICATION_JSON_VALUE})
@ResponseStatus(HttpStatus.CREATED)
public Mono<ResponseDTO<User>> create(@Valid @RequestBody User resource, ServerWebExchange exchange) {
return userSignup
.signupAndLogin(resource, exchange)
.map(created -> new ResponseDTO<>(HttpStatus.CREATED.value(), created, null));
}

@JsonView(Views.Public.class)
@PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE})
@ResponseStatus(HttpStatus.CREATED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public void objectMapper_BeanCreated_WithPublicJsonViewAsDefault() throws JsonPr
userData.setUserPermissions(null);

String value = objectMapper.writeValueAsString(userData);
JSONAssert.assertEquals("{\"proficiency\":\"abcd\",\"role\":\"new_role\"}", value, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure of why the test case got updated as part of this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Case of working on the wrong branch. 🙂
This change is already on release.

JSONAssert.assertEquals("{\"proficiency\":\"abcd\"}", value, true);
}
}