Skip to content

Commit

Permalink
remove setusername
Browse files Browse the repository at this point in the history
  • Loading branch information
indiv0 committed Mar 9, 2023
1 parent 08a96d3 commit 84721bc
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 132 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import * as error from "../../error";
const MESSAGES = {
signUpSuccess: "We have sent you an email with further instructions!",
confirmSignUpSuccess: "Your account has been confirmed! Please log in.",
setUsernameSuccess: "Your username has been set!",
signInWithPasswordSuccess: "Successfully logged in!",
pleaseWait: "Please wait...",
};
Expand Down Expand Up @@ -83,11 +82,6 @@ export interface PartialUserSession {
interface AuthContextType {
signUp: (email: string, password: string) => Promise<void>;
confirmSignUp: (email: string, code: string) => Promise<void>;
setUsername: (
accessToken: string,
username: string,
email: string
) => Promise<void>;
signInWithGoogle: () => Promise<null>;
signInWithGitHub: () => Promise<null>;
signInWithPassword: (email: string, password: string) => Promise<void>;
Expand Down Expand Up @@ -238,25 +232,6 @@ export const AuthProvider = (props: AuthProviderProps) => {
navigate(app.LOGIN_PATH);
});

const setUsername = async (
accessToken: string,
username: string,
email: string
) => {
const body: backendService.SetUsernameRequestBody = {
userName: username,
userEmail: email,
};

// TODO [NP]: https://github.com/enso-org/cloud-v2/issues/343
// Don't create a new API client here, reuse the one from the context.
const backend = backendService.createBackend(accessToken, logger);

await backend.setUsername(body);
navigate(app.DASHBOARD_PATH);
toast.success(MESSAGES.setUsernameSuccess);
};

const signInWithPassword = async (email: string, password: string) =>
cognito.signInWithPassword(email, password).then((result) => {
if (result.ok) {
Expand All @@ -274,7 +249,6 @@ export const AuthProvider = (props: AuthProviderProps) => {
const value = {
signUp: withLoadingToast(signUp),
confirmSignUp: withLoadingToast(confirmSignUp),
setUsername,
signInWithGoogle: cognito.signInWithGoogle,
signInWithGitHub: cognito.signInWithGitHub,
signInWithPassword: withLoadingToast(signInWithPassword),
Expand Down Expand Up @@ -342,10 +316,6 @@ export const ProtectedLayout = () => {
export const GuestLayout = () => {
const { session } = useAuth();

if (session?.state == "partial") {
return <router.Navigate to={app.SET_USERNAME_PATH} />;
}

if (session?.state == "full") {
return <router.Navigate to={app.DASHBOARD_PATH} />;
}
Expand All @@ -355,16 +325,6 @@ export const GuestLayout = () => {



// =============================
// === usePartialUserSession ===
// =============================

export const usePartialUserSession = () => {
return router.useOutletContext<PartialUserSession>();
};



// ==========================
// === useFullUserSession ===
// ==========================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import DashboardContainer from "../dashboard/components/dashboard";
import LoginContainer from "../authentication/components/login";
import RegistrationContainer from "../authentication/components/registration";
import ConfirmRegistrationContainer from "../authentication/components/confirmRegistration";
import SetUsernameContainer from "../authentication/components/setUsername";
import * as authService from "../authentication/service";
import withRouter from "../navigation";
import * as loggerProvider from "../providers/logger";
Expand All @@ -29,8 +28,6 @@ export const LOGIN_PATH = "/login";
export const REGISTRATION_PATH = "/registration";
/** Path to the confirm registration page. */
export const CONFIRM_REGISTRATION_PATH = "/confirmation";
/** Path to the set username page. */
export const SET_USERNAME_PATH = "/set-username";



Expand Down Expand Up @@ -124,10 +121,6 @@ const AppRouter = (props: AppProps) => {
<DashboardContainer />
}
/>
<router.Route
path={SET_USERNAME_PATH}
element={<SetUsernameContainer />}
/>
</router.Route>
{/* Other pages are visible to unauthenticated and authenticated users. */}
<router.Route
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ const DEFAULT_OPEN_PROJECT_BODY: OpenProjectRequestBody = {
forceCreate: false,
};

/** Relative HTTP path to the "set username" endpoint of the Cloud backend API. */
const SET_USER_NAME_PATH = "users";
/** Relative HTTP path to the "get user" endpoint of the Cloud backend API. */
const GET_USER_PATH = "users/me";
/** Relative HTTP path to the "list projects" endpoint of the Cloud backend API. */
Expand Down Expand Up @@ -103,12 +101,6 @@ export interface Project {
// === Endpoints ===
// =================

/** HTTP request body for the "set username" endpoint. */
export interface SetUsernameRequestBody {
userName: string;
userEmail: string;
}

/** HTTP response body for the "list projects" endpoint. */
interface ListProjectsResponseBody {
projects: Project[];
Expand Down Expand Up @@ -162,13 +154,6 @@ export class Backend {
throw new Error(message);
};

/** Sets the username of the current user, on the Cloud backend API. */
setUsername = (body: SetUsernameRequestBody): Promise<Organization> =>
this.post(SET_USER_NAME_PATH)
.json(body)
.send()
.then((response) => response.model());

/** Returns organization info for the current user, from the Cloud backend API.
*
* @returns `null` if status code 401 or 404 was received. */
Expand Down

0 comments on commit 84721bc

Please sign in to comment.