diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index c088b90d8680..4a6887766900 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -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: { diff --git a/app/client/src/ce/api/UserApi.tsx b/app/client/src/ce/api/UserApi.tsx index f8a8b7a55fa8..c6a2e1f506c2 100644 --- a/app/client/src/ce/api/UserApi.tsx +++ b/app/client/src/ce/api/UserApi.tsx @@ -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; } @@ -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; } @@ -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"; @@ -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> { - return Api.post(UserApi.usersURL, request); - } - static async updateUser( request: UpdateUserRequest, ): Promise> { return Api.put(UserApi.usersURL, request); } - static async fetchUser( - request: FetchUserRequest, - ): Promise> { - return Api.get(UserApi.usersURL + "/" + request.id); - } - static async getCurrentUser(): Promise> { return Api.get(UserApi.currentUserURL); } diff --git a/app/client/src/ce/constants/ReduxActionConstants.tsx b/app/client/src/ce/constants/ReduxActionConstants.tsx index 7e7375ede276..a4ef8ae1d025 100644 --- a/app/client/src/ce/constants/ReduxActionConstants.tsx +++ b/app/client/src/ce/constants/ReduxActionConstants.tsx @@ -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", @@ -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", diff --git a/app/client/src/ce/sagas/userSagas.tsx b/app/client/src/ce/sagas/userSagas.tsx index 51baf2931703..8daba706b682 100644 --- a/app/client/src/ce/sagas/userSagas.tsx +++ b/app/client/src/ce/sagas/userSagas.tsx @@ -9,8 +9,6 @@ import { } from "ee/constants/ReduxActionConstants"; import { reset } from "redux-form"; import type { - CreateUserRequest, - CreateUserResponse, ForgotPasswordRequest, VerifyTokenRequest, TokenPasswordUpdateRequest, @@ -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, -) { - 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; diff --git a/app/client/src/ee/sagas/userSagas.tsx b/app/client/src/ee/sagas/userSagas.tsx index 8682e062475d..2094e1c3c723 100644 --- a/app/client/src/ee/sagas/userSagas.tsx +++ b/app/client/src/ee/sagas/userSagas.tsx @@ -1,6 +1,5 @@ export * from "ce/sagas/userSagas"; import { - createUserSaga, getCurrentUserSaga, runUserSideEffectsSaga, forgotPasswordSaga, @@ -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, diff --git a/app/client/src/pages/UserAuth/helpers.ts b/app/client/src/pages/UserAuth/helpers.ts index 89ac86029809..aa901b8ca366 100644 --- a/app/client/src/pages/UserAuth/helpers.ts +++ b/app/client/src/pages/UserAuth/helpers.ts @@ -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"; @@ -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 => { - 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 => { + dispatch: Dispatch, +): Promise => { const { email, password, token } = values; - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { dispatch({ type: ReduxActionTypes.RESET_USER_PASSWORD_INIT, payload: { @@ -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 => { - 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 => { + dispatch: Dispatch, +): Promise => { const { email } = values; - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { dispatch({ type: ReduxActionTypes.FORGOT_PASSWORD_INIT, payload: { diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/UserControllerCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/UserControllerCE.java index dcc6b6f7aaa1..b7813b5505bb 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/UserControllerCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/UserControllerCE.java @@ -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; @@ -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> 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) diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/configurations/CommonConfigTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/configurations/CommonConfigTest.java index 6d29deb3eb3b..661657535189 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/configurations/CommonConfigTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/configurations/CommonConfigTest.java @@ -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); + JSONAssert.assertEquals("{\"proficiency\":\"abcd\"}", value, true); } }