chore: Remove unused JSON signup API handler (#37387)

This PR removes the JSON-version of signup API handler, and its unused
references. We use the other Form-body-version of this API, but not
this. So this isn't needed.

Fewer things there are, fewer there are to protect.

## Automation

/test sanity authentication

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/11838832000>
> Commit: f27d2c9fa7d9b154eb6649b1f9885fd54d1921b5
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11838832000&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity, @tag.Authentication`
> Spec:
> <hr>Thu, 14 Nov 2024 14:49:54 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Introduced new Cypress commands for enhanced API interactions and UI
validations.
	- Added a method for handling user creation through form-encoded data.

- **Bug Fixes**
	- Improved error handling and validation checks in various commands.

- **Documentation**
- Updated type definitions and submit handler functions for better
clarity and maintainability.

- **Chores**
- Removed unused user management functionalities, streamlining the
codebase.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Shrikant Sharat Kandula 2024-11-15 12:39:29 +05:30 committed by GitHub
parent 6fc632795b
commit 646f29fd5d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 7 additions and 173 deletions

View File

@ -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: {

View File

@ -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<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);
}

View File

@ -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",

View File

@ -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<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;

View File

@ -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,

View File

@ -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<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: {
@ -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: {

View File

@ -17,7 +17,6 @@ import com.appsmith.server.services.UserWorkspaceService;
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<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)